/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- AppleGetThreadItemInfoHandler.h ----------------------------*- C++ |
2 | | //-*-===// |
3 | | // |
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 |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | |
10 | | #ifndef LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETTHREADITEMINFOHANDLER_H |
11 | | #define LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETTHREADITEMINFOHANDLER_H |
12 | | |
13 | | #include <map> |
14 | | #include <mutex> |
15 | | #include <vector> |
16 | | |
17 | | #include "lldb/Symbol/CompilerType.h" |
18 | | #include "lldb/Utility/Status.h" |
19 | | #include "lldb/lldb-public.h" |
20 | | |
21 | | // This class will insert a UtilityFunction into the inferior process for |
22 | | // calling libBacktraceRecording's |
23 | | // __introspection_dispatch_thread_get_item_info() |
24 | | // function. The function in the inferior will return a struct by value |
25 | | // with these members: |
26 | | // |
27 | | // struct get_thread_item_info_return_values |
28 | | // { |
29 | | // introspection_dispatch_item_info_ref *item_buffer; |
30 | | // uint64_t item_buffer_size; |
31 | | // }; |
32 | | // |
33 | | // The item_buffer pointer is an address in the inferior program's address |
34 | | // space (item_buffer_size in size) which must be mach_vm_deallocate'd by |
35 | | // lldb. |
36 | | // |
37 | | // The AppleGetThreadItemInfoHandler object should persist so that the |
38 | | // UtilityFunction |
39 | | // can be reused multiple times. |
40 | | |
41 | | namespace lldb_private { |
42 | | |
43 | | class AppleGetThreadItemInfoHandler { |
44 | | public: |
45 | | AppleGetThreadItemInfoHandler(lldb_private::Process *process); |
46 | | |
47 | | ~AppleGetThreadItemInfoHandler(); |
48 | | |
49 | | struct GetThreadItemInfoReturnInfo { |
50 | | lldb::addr_t item_buffer_ptr = LLDB_INVALID_ADDRESS; /* the address of the |
51 | | item buffer from libBacktraceRecording */ |
52 | | lldb::addr_t item_buffer_size = 0; /* the size of the item buffer from |
53 | | libBacktraceRecording */ |
54 | | |
55 | 0 | GetThreadItemInfoReturnInfo() = default; |
56 | | }; |
57 | | |
58 | | /// Get the information about a work item by calling |
59 | | /// __introspection_dispatch_thread_get_item_info. If there's a page of |
60 | | /// memory that needs to be freed, pass in the address and size and it will |
61 | | /// be freed before getting the list of queues. |
62 | | /// |
63 | | /// \param [in] thread_id |
64 | | /// The thread to get the extended backtrace for. |
65 | | /// |
66 | | /// \param [in] page_to_free |
67 | | /// An address of an inferior process vm page that needs to be |
68 | | /// deallocated, |
69 | | /// LLDB_INVALID_ADDRESS if this is not needed. |
70 | | /// |
71 | | /// \param [in] page_to_free_size |
72 | | /// The size of the vm page that needs to be deallocated if an address was |
73 | | /// passed in to page_to_free. |
74 | | /// |
75 | | /// \param [out] error |
76 | | /// This object will be updated with the error status / error string from |
77 | | /// any failures encountered. |
78 | | /// |
79 | | /// \returns |
80 | | /// The result of the inferior function call execution. If there was a |
81 | | /// failure of any kind while getting |
82 | | /// the information, the item_buffer_ptr value will be |
83 | | /// LLDB_INVALID_ADDRESS. |
84 | | GetThreadItemInfoReturnInfo GetThreadItemInfo(Thread &thread, |
85 | | lldb::tid_t thread_id, |
86 | | lldb::addr_t page_to_free, |
87 | | uint64_t page_to_free_size, |
88 | | lldb_private::Status &error); |
89 | | |
90 | | void Detach(); |
91 | | |
92 | | private: |
93 | | lldb::addr_t |
94 | | SetupGetThreadItemInfoFunction(Thread &thread, |
95 | | ValueList &get_thread_item_info_arglist); |
96 | | |
97 | | static const char *g_get_thread_item_info_function_name; |
98 | | static const char *g_get_thread_item_info_function_code; |
99 | | |
100 | | lldb_private::Process *m_process; |
101 | | std::unique_ptr<UtilityFunction> m_get_thread_item_info_impl_code; |
102 | | std::mutex m_get_thread_item_info_function_mutex; |
103 | | |
104 | | lldb::addr_t m_get_thread_item_info_return_buffer_addr; |
105 | | std::mutex m_get_thread_item_info_retbuffer_mutex; |
106 | | }; |
107 | | |
108 | | } // using namespace lldb_private |
109 | | |
110 | | #endif // LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETTHREADITEMINFOHANDLER_H |