1 //===-- GenealogySPI.h ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //===----------------------------------------------------------------------===//
7 
8 #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_GENEALOGYSPI_H
9 #define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_GENEALOGYSPI_H
10 
11 #include <xpc/xpc.h>
12 
13 typedef void *os_activity_process_list_t;
14 typedef void *os_activity_list_t;
15 typedef void *os_trace_message_list_t;
16 typedef struct os_activity_watch_s *os_activity_watch_t;
17 typedef uint64_t os_activity_t;
18 
19 struct os_activity_breadcrumb_s {
20   uint32_t breadcrumb_id;
21   uint64_t activity_id;
22   uint64_t timestamp;
23   const char *name;
24 };
25 
26 typedef struct os_activity_breadcrumb_s *os_activity_breadcrumb_t;
27 
28 typedef struct os_trace_message_s {
29   uint64_t trace_id;
30   uint64_t thread;
31   uint64_t timestamp;
32   uint32_t offset;
33   xpc_object_t __unsafe_unretained payload;
34   const uint8_t *image_uuid;
35   const char *image_path;
36   const char *format;
37   const void *buffer;
38   size_t bufferLen;
39 } * os_trace_message_t;
40 
41 typedef struct os_activity_process_s {
42   os_activity_process_list_t child_procs;
43   os_trace_message_list_t messages;
44   os_activity_list_t activities;
45   void *breadcrumbs;
46   uint64_t proc_id;
47   const uint8_t *image_uuid;
48   const char *image_path;
49   pid_t pid;
50 } * os_activity_process_t;
51 
52 typedef struct os_activity_entry_s {
53   uint64_t activity_start;
54   os_activity_t activity_id;
55   os_activity_t parent_id;
56   const char *activity_name;
57   const char *reason;
58   os_trace_message_list_t messages;
59 } * os_activity_entry_t;
60 
61 enum {
62   OS_ACTIVITY_DIAGNOSTIC_DEFAULT = 0x00000000,
63   OS_ACTIVITY_DIAGNOSTIC_PROCESS_ONLY = 0x00000001,
64   OS_ACTIVITY_DIAGNOSTIC_SKIP_DECODE = 0x00000002,
65   OS_ACTIVITY_DIAGNOSTIC_FLATTENED = 0x00000004,
66   OS_ACTIVITY_DIAGNOSTIC_ALL_ACTIVITIES = 0x00000008,
67   OS_ACTIVITY_DIAGNOSTIC_MAX = 0x0000000f
68 };
69 typedef uint32_t os_activity_diagnostic_flag_t;
70 
71 enum {
72   OS_ACTIVITY_WATCH_DEFAULT = 0x00000000,
73   OS_ACTIVITY_WATCH_PROCESS_ONLY = 0x00000001,
74   OS_ACTIVITY_WATCH_SKIP_DECODE = 0x00000002,
75   OS_ACTIVITY_WATCH_PAYLOAD = 0x00000004,
76   OS_ACTIVITY_WATCH_ERRORS = 0x00000008,
77   OS_ACTIVITY_WATCH_FAULTS = 0x00000010,
78   OS_ACTIVITY_WATCH_MAX = 0x0000001f
79 };
80 typedef uint32_t os_activity_watch_flag_t;
81 
82 // Return values from os_trace_get_type()
83 #define OS_TRACE_TYPE_RELEASE (1u << 0)
84 #define OS_TRACE_TYPE_DEBUG (1u << 1)
85 #define OS_TRACE_TYPE_ERROR ((1u << 6) | (1u << 0))
86 #define OS_TRACE_TYPE_FAULT ((1u << 7) | (1u << 6) | (1u << 0))
87 
88 typedef void (^os_activity_watch_block_t)(os_activity_watch_t watch,
89                                           os_activity_process_t process_info,
90                                           bool canceled);
91 typedef void (^os_diagnostic_block_t)(os_activity_process_list_t processes,
92                                       int error);
93 
94 #endif
95