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_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETITEMINFOHANDLER_H
10 #define LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_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 
50  item buffer from libBacktraceRecording */
51  lldb::addr_t item_buffer_size = 0; /* the size of the item buffer from
52  libBacktraceRecording */
53 
54  GetItemInfoReturnInfo() = default;
55  };
56 
57  /// Get the information about a work item by calling
58  /// __introspection_dispatch_queue_item_get_info. If there's a page of
59  /// memory that needs to be freed, pass in the address and size and it will
60  /// be freed before getting the list of queues.
61  ///
62  /// \param [in] thread
63  /// The thread to run this plan on.
64  ///
65  /// \param [in] item
66  /// The introspection_dispatch_item_info_ref value for the item of
67  /// interest.
68  ///
69  /// \param [in] page_to_free
70  /// An address of an inferior process vm page that needs to be
71  /// deallocated,
72  /// LLDB_INVALID_ADDRESS if this is not needed.
73  ///
74  /// \param [in] page_to_free_size
75  /// The size of the vm page that needs to be deallocated if an address was
76  /// passed in to page_to_free.
77  ///
78  /// \param [out] error
79  /// This object will be updated with the error status / error string from
80  /// any failures encountered.
81  ///
82  /// \returns
83  /// The result of the inferior function call execution. If there was a
84  /// failure of any kind while getting
85  /// the information, the item_buffer_ptr value will be
86  /// LLDB_INVALID_ADDRESS.
88  lldb::addr_t page_to_free,
89  uint64_t page_to_free_size,
91 
92  void Detach();
93 
94 private:
96  ValueList &get_item_info_arglist);
97 
98  static const char *g_get_item_info_function_name;
99  static const char *g_get_item_info_function_code;
100 
102  std::unique_ptr<UtilityFunction> m_get_item_info_impl_code;
104 
107 };
108 
109 } // using namespace lldb_private
110 
111 #endif // LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETITEMINFOHANDLER_H
lldb-public.h
lldb_private::AppleGetItemInfoHandler::m_get_item_info_retbuffer_mutex
std::mutex m_get_item_info_retbuffer_mutex
Definition: AppleGetItemInfoHandler.h:106
lldb_private::AppleGetItemInfoHandler::SetupGetItemInfoFunction
lldb::addr_t SetupGetItemInfoFunction(Thread &thread, ValueList &get_item_info_arglist)
Definition: AppleGetItemInfoHandler.cpp:128
lldb_private::Process
Definition: Process.h:341
lldb_private::ValueList
Definition: Value.h:157
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::AppleGetItemInfoHandler::AppleGetItemInfoHandler
AppleGetItemInfoHandler(lldb_private::Process *process)
Definition: AppleGetItemInfoHandler.cpp:95
lldb_private::AppleGetItemInfoHandler::m_get_item_info_impl_code
std::unique_ptr< UtilityFunction > m_get_item_info_impl_code
Definition: AppleGetItemInfoHandler.h:102
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::AppleGetItemInfoHandler::Detach
void Detach()
Definition: AppleGetItemInfoHandler.cpp:103
lldb_private::Thread
Definition: Thread.h:60
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo::item_buffer_size
lldb::addr_t item_buffer_size
Definition: AppleGetItemInfoHandler.h:51
lldb_private::AppleGetItemInfoHandler::~AppleGetItemInfoHandler
~AppleGetItemInfoHandler()
lldb_private::AppleGetItemInfoHandler::m_process
lldb_private::Process * m_process
Definition: AppleGetItemInfoHandler.h:101
CompilerType.h
UtilityFunction.h
lldb_private::AppleGetItemInfoHandler
Definition: AppleGetItemInfoHandler.h:42
lldb_private::AppleGetItemInfoHandler::m_get_item_info_function_mutex
std::mutex m_get_item_info_function_mutex
Definition: AppleGetItemInfoHandler.h:103
lldb_private::AppleGetItemInfoHandler::GetItemInfo
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.
Definition: AppleGetItemInfoHandler.cpp:212
lldb_private::Status
Definition: Status.h:44
lldb_private::AppleGetItemInfoHandler::g_get_item_info_function_code
static const char * g_get_item_info_function_code
Definition: AppleGetItemInfoHandler.h:99
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo::item_buffer_ptr
lldb::addr_t item_buffer_ptr
Definition: AppleGetItemInfoHandler.h:49
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo
Definition: AppleGetItemInfoHandler.h:48
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo::GetItemInfoReturnInfo
GetItemInfoReturnInfo()=default
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::AppleGetItemInfoHandler::g_get_item_info_function_name
static const char * g_get_item_info_function_name
Definition: AppleGetItemInfoHandler.h:98
lldb_private::AppleGetItemInfoHandler::m_get_item_info_return_buffer_addr
lldb::addr_t m_get_item_info_return_buffer_addr
Definition: AppleGetItemInfoHandler.h:105