LLDB  mainline
AppleGetItemInfoHandler.h
Go to the documentation of this file.
1 //===-- AppleGetItemInfoHandler.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 
9 #ifndef lldb_AppleGetItemInfoHandler_h_
10 #define lldb_AppleGetItemInfoHandler_h_
11 
12 #include <map>
13 #include <mutex>
14 #include <vector>
15 
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_queue_item_get_info()
24 // function. The function in the inferior will return a struct by value
25 // with these members:
26 //
27 // struct get_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 AppleGetItemInfoHandler object should persist so that the UtilityFunction
38 // can be reused multiple times.
39 
40 namespace lldb_private {
41 
43 public:
45 
47 
49  lldb::addr_t item_buffer_ptr; /* the address of the item buffer from
50  libBacktraceRecording */
51  lldb::addr_t item_buffer_size; /* the size of the item buffer from
52  libBacktraceRecording */
53 
55  : item_buffer_ptr(LLDB_INVALID_ADDRESS), item_buffer_size(0) {}
56  };
57 
58  /// Get the information about a work item by calling
59  /// __introspection_dispatch_queue_item_get_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
64  /// The thread to run this plan on.
65  ///
66  /// \param [in] item
67  /// The introspection_dispatch_item_info_ref value for the item of
68  /// interest.
69  ///
70  /// \param [in] page_to_free
71  /// An address of an inferior process vm page that needs to be
72  /// deallocated,
73  /// LLDB_INVALID_ADDRESS if this is not needed.
74  ///
75  /// \param [in] page_to_free_size
76  /// The size of the vm page that needs to be deallocated if an address was
77  /// passed in to page_to_free.
78  ///
79  /// \param [out] error
80  /// This object will be updated with the error status / error string from
81  /// any failures encountered.
82  ///
83  /// \returns
84  /// The result of the inferior function call execution. If there was a
85  /// failure of any kind while getting
86  /// the information, the item_buffer_ptr value will be
87  /// LLDB_INVALID_ADDRESS.
89  lldb::addr_t page_to_free,
90  uint64_t page_to_free_size,
91  lldb_private::Status &error);
92 
93  void Detach();
94 
95 private:
96  lldb::addr_t SetupGetItemInfoFunction(Thread &thread,
97  ValueList &get_item_info_arglist);
98 
99  static const char *g_get_item_info_function_name;
100  static const char *g_get_item_info_function_code;
101 
102  lldb_private::Process *m_process;
103  std::unique_ptr<UtilityFunction> m_get_item_info_impl_code;
104  std::mutex m_get_item_info_function_mutex;
105 
106  lldb::addr_t m_get_item_info_return_buffer_addr;
107  std::mutex m_get_item_info_retbuffer_mutex;
108 };
109 
110 } // using namespace lldb_private
111 
112 #endif // lldb_AppleGetItemInfoHandler_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
AppleGetItemInfoHandler(lldb_private::Process *process)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
A plug-in interface definition class for debugging a process.
Definition: Process.h:353
GetItemInfoReturnInfo GetItemInfo(Thread &thread, lldb::addr_t item, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the information about a work item by calling __introspection_dispatch_queue_item_get_info.
uint64_t addr_t
Definition: lldb-types.h:83
An error handling class.
Definition: Status.h:44