1 //===-- Genealogy.h ---------------------------------------------*- C++ -*-===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_GENEALOGY_H
11 #define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_GENEALOGY_H
13 #include <mach/task.h>
19 #include "GenealogySPI.h"
20 #include "MachThreadList.h"
31 uint32_t breadcrumb_id
;
38 uint64_t activity_start
;
41 std::string activity_name
;
50 uint8_t type
; // OS_TRACE_TYPE_RELEASE, OS_TRACE_TYPE_DEBUG,
51 // OS_TRACE_TYPE_ERROR, OS_TRACE_TYPE_FAULT
52 uint32_t process_info_index
; // index # of the image uuid/file path, 0 means
57 typedef std::vector
<Message
> MessageList
;
58 typedef std::vector
<Breadcrumb
> BreadcrumbList
;
59 typedef std::vector
<Activity
> ActivityList
;
61 struct ThreadActivity
{
62 Activity current_activity
;
64 BreadcrumbList breadcrumbs
; // should be 0 or 1 breadcrumbs; no more than 1
65 // BC for any given activity
68 typedef std::shared_ptr
<ThreadActivity
> ThreadActivitySP
;
70 ThreadActivitySP
GetGenealogyInfoForThread(pid_t pid
, nub_thread_t tid
,
71 const MachThreadList
&thread_list
,
72 task_t task
, bool &timed_out
);
74 struct ProcessExecutableInfo
{
75 std::string image_path
;
79 typedef std::shared_ptr
<ProcessExecutableInfo
> ProcessExecutableInfoSP
;
81 ProcessExecutableInfoSP
GetProcessExecutableInfosAtIndex(size_t idx
);
83 uint32_t AddProcessExecutableInfo(ProcessExecutableInfoSP process_exe_info
);
86 void GetActivities(pid_t pid
, const MachThreadList
&thread_list
, task_t task
);
88 // the spi we need to call into libtrace - look them up via dlsym at runtime
89 bool (*m_os_activity_diagnostic_for_pid
)(pid_t pid
, os_activity_t activity
,
91 os_diagnostic_block_t block
);
92 void (*m_os_activity_iterate_processes
)(
93 os_activity_process_list_t processes
,
94 bool (^iterator
)(os_activity_process_t process_info
));
95 void (*m_os_activity_iterate_breadcrumbs
)(
96 os_activity_process_t process_info
,
97 bool (^iterator
)(os_activity_breadcrumb_t breadcrumb
));
98 void (*m_os_activity_iterate_messages
)(
99 os_trace_message_list_t messages
, os_activity_process_t process_info
,
100 bool (^iterator
)(os_trace_message_t tracemsg
));
101 void (*m_os_activity_iterate_activities
)(
102 os_activity_list_t activities
, os_activity_process_t process_info
,
103 bool (^iterator
)(os_activity_entry_t activity
));
104 uint8_t (*m_os_trace_get_type
)(os_trace_message_t trace_msg
);
105 char *(*m_os_trace_copy_formatted_message
)(os_trace_message_t trace_msg
);
106 os_activity_t (*m_os_activity_for_thread
)(os_activity_process_t process
,
108 os_activity_t (*m_os_activity_for_task_thread
)(task_t target
,
110 os_trace_message_list_t (*m_os_activity_messages_for_thread
)(
111 os_activity_process_t process
, os_activity_t activity
,
114 std::map
<nub_thread_t
, ThreadActivitySP
> m_thread_activities
;
115 std::vector
<ProcessExecutableInfoSP
> m_process_executable_infos
;
116 bool m_diagnosticd_call_timed_out
;
119 #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_GENEALOGY_H