1 //===-- AppleGetItemInfoHandler.h ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_AppleGetItemInfoHandler_h_
11 #define lldb_AppleGetItemInfoHandler_h_
19 // Other libraries and framework includes
21 #include "lldb/lldb-public.h"
22 #include "lldb/Core/Error.h"
23 #include "lldb/Expression/UtilityFunction.h"
24 #include "lldb/Symbol/CompilerType.h"
26 // This class will insert a UtilityFunction into the inferior process for
27 // calling libBacktraceRecording's __introspection_dispatch_queue_item_get_info()
28 // function. The function in the inferior will return a struct by value
29 // with these members:
31 // struct get_item_info_return_values
33 // introspection_dispatch_item_info_ref *item_buffer;
34 // uint64_t item_buffer_size;
37 // The item_buffer pointer is an address in the inferior program's address
38 // space (item_buffer_size in size) which must be mach_vm_deallocate'd by
41 // The AppleGetItemInfoHandler object should persist so that the UtilityFunction
42 // can be reused multiple times.
44 namespace lldb_private
47 class AppleGetItemInfoHandler {
50 AppleGetItemInfoHandler (lldb_private::Process *process);
52 ~AppleGetItemInfoHandler();
54 struct GetItemInfoReturnInfo
56 lldb::addr_t item_buffer_ptr; /* the address of the item buffer from libBacktraceRecording */
57 lldb::addr_t item_buffer_size; /* the size of the item buffer from libBacktraceRecording */
59 GetItemInfoReturnInfo() :
60 item_buffer_ptr(LLDB_INVALID_ADDRESS),
65 //----------------------------------------------------------
66 /// Get the information about a work item by calling
67 /// __introspection_dispatch_queue_item_get_info. If there's a page of
68 /// memory that needs to be freed, pass in the address and size and it will
69 /// be freed before getting the list of queues.
71 /// @param [in] thread
72 /// The thread to run this plan on.
75 /// The introspection_dispatch_item_info_ref value for the item of interest.
77 /// @param [in] page_to_free
78 /// An address of an inferior process vm page that needs to be deallocated,
79 /// LLDB_INVALID_ADDRESS if this is not needed.
81 /// @param [in] page_to_free_size
82 /// The size of the vm page that needs to be deallocated if an address was
83 /// passed in to page_to_free.
85 /// @param [out] error
86 /// This object will be updated with the error status / error string from any failures encountered.
89 /// The result of the inferior function call execution. If there was a failure of any kind while getting
90 /// the information, the item_buffer_ptr value will be LLDB_INVALID_ADDRESS.
91 //----------------------------------------------------------
93 GetItemInfo (Thread &thread, lldb::addr_t item, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Error &error);
102 SetupGetItemInfoFunction (Thread &thread, ValueList &get_item_info_arglist);
104 static const char *g_get_item_info_function_name;
105 static const char *g_get_item_info_function_code;
107 lldb_private::Process *m_process;
108 std::unique_ptr<UtilityFunction> m_get_item_info_impl_code;
109 std::mutex m_get_item_info_function_mutex;
111 lldb::addr_t m_get_item_info_return_buffer_addr;
112 std::mutex m_get_item_info_retbuffer_mutex;
115 } // using namespace lldb_private
117 #endif // lldb_AppleGetItemInfoHandler_h_