LLDB  mainline
AppleGetPendingItemsHandler.h
Go to the documentation of this file.
1 //===-- AppleGetPendingItemsHandler.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_APPLEGETPENDINGITEMSHANDLER_H
11 #define LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETPENDINGITEMSHANDLER_H
12 
13 #include <map>
14 #include <mutex>
15 #include <vector>
16 
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_get_pending_items()
24 // function. The function in the inferior will return a struct by value
25 // with these members:
26 //
27 // struct get_pending_items_return_values
28 // {
29 // introspection_dispatch_item_info_ref *items_buffer;
30 // uint64_t items_buffer_size;
31 // uint64_t count;
32 // };
33 //
34 // The items_buffer pointer is an address in the inferior program's address
35 // space (items_buffer_size in size) which must be mach_vm_deallocate'd by
36 // lldb. count is the number of items that were stored in the buffer.
37 //
38 // The AppleGetPendingItemsHandler object should persist so that the
39 // UtilityFunction
40 // can be reused multiple times.
41 
42 namespace lldb_private {
43 
45 public:
47 
49 
52  LLDB_INVALID_ADDRESS; /* the address of the pending items buffer
53  from libBacktraceRecording */
54  lldb::addr_t items_buffer_size = 0; /* the size of the pending items buffer
55  from libBacktraceRecording */
56  uint64_t count = 0; /* the number of pending items included in the buffer */
57 
58  GetPendingItemsReturnInfo() = default;
59  };
60 
61  /// Get the list of pending items for a given queue via a call to
62  /// __introspection_dispatch_queue_get_pending_items. If there's a page of
63  /// memory that needs to be freed, pass in the address and size and it will
64  /// be freed before getting the list of queues.
65  ///
66  /// \param [in] thread
67  /// The thread to run this plan on.
68  ///
69  /// \param [in] queue
70  /// The dispatch_queue_t value for the queue of interest.
71  ///
72  /// \param [in] page_to_free
73  /// An address of an inferior process vm page that needs to be
74  /// deallocated,
75  /// LLDB_INVALID_ADDRESS if this is not needed.
76  ///
77  /// \param [in] page_to_free_size
78  /// The size of the vm page that needs to be deallocated if an address was
79  /// passed in to page_to_free.
80  ///
81  /// \param [out] error
82  /// This object will be updated with the error status / error string from
83  /// any failures encountered.
84  ///
85  /// \returns
86  /// The result of the inferior function call execution. If there was a
87  /// failure of any kind while getting
88  /// the information, the items_buffer_ptr value will be
89  /// LLDB_INVALID_ADDRESS.
91  lldb::addr_t page_to_free,
92  uint64_t page_to_free_size,
94 
95  void Detach();
96 
97 private:
100  ValueList &get_pending_items_arglist);
101 
104 
106  std::unique_ptr<UtilityFunction> m_get_pending_items_impl_code;
108 
111 };
112 
113 } // using namespace lldb_private
114 
115 #endif // LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETPENDINGITEMSHANDLER_H
lldb_private::AppleGetPendingItemsHandler
Definition: AppleGetPendingItemsHandler.h:44
lldb-public.h
lldb_private::AppleGetPendingItemsHandler::AppleGetPendingItemsHandler
AppleGetPendingItemsHandler(lldb_private::Process *process)
Definition: AppleGetPendingItemsHandler.cpp:99
lldb_private::Process
Definition: Process.h:341
lldb_private::AppleGetPendingItemsHandler::g_get_pending_items_function_code
static const char * g_get_pending_items_function_code
Definition: AppleGetPendingItemsHandler.h:103
lldb_private::AppleGetPendingItemsHandler::m_get_pending_items_function_mutex
std::mutex m_get_pending_items_function_mutex
Definition: AppleGetPendingItemsHandler.h:107
lldb_private::ValueList
Definition: Value.h:157
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::count
uint64_t count
Definition: AppleGetPendingItemsHandler.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Thread
Definition: Thread.h:62
lldb_private::AppleGetPendingItemsHandler::m_get_pending_items_retbuffer_mutex
std::mutex m_get_pending_items_retbuffer_mutex
Definition: AppleGetPendingItemsHandler.h:110
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::GetPendingItemsReturnInfo
GetPendingItemsReturnInfo()=default
lldb_private::AppleGetPendingItemsHandler::Detach
void Detach()
Definition: AppleGetPendingItemsHandler.cpp:107
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::items_buffer_size
lldb::addr_t items_buffer_size
Definition: AppleGetPendingItemsHandler.h:54
CompilerType.h
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo
Definition: AppleGetPendingItemsHandler.h:50
lldb_private::Status
Definition: Status.h:44
lldb_private::AppleGetPendingItemsHandler::~AppleGetPendingItemsHandler
~AppleGetPendingItemsHandler()
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::AppleGetPendingItemsHandler::g_get_pending_items_function_name
static const char * g_get_pending_items_function_name
Definition: AppleGetPendingItemsHandler.h:102
Status.h
lldb_private::AppleGetPendingItemsHandler::m_process
lldb_private::Process * m_process
Definition: AppleGetPendingItemsHandler.h:105
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::items_buffer_ptr
lldb::addr_t items_buffer_ptr
Definition: AppleGetPendingItemsHandler.h:51
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::AppleGetPendingItemsHandler::SetupGetPendingItemsFunction
lldb::addr_t SetupGetPendingItemsFunction(Thread &thread, ValueList &get_pending_items_arglist)
Definition: AppleGetPendingItemsHandler.cpp:131
lldb_private::AppleGetPendingItemsHandler::m_get_pending_items_return_buffer_addr
lldb::addr_t m_get_pending_items_return_buffer_addr
Definition: AppleGetPendingItemsHandler.h:109
lldb_private::AppleGetPendingItemsHandler::m_get_pending_items_impl_code
std::unique_ptr< UtilityFunction > m_get_pending_items_impl_code
Definition: AppleGetPendingItemsHandler.h:106
lldb_private::AppleGetPendingItemsHandler::GetPendingItems
GetPendingItemsReturnInfo GetPendingItems(Thread &thread, lldb::addr_t queue, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the list of pending items for a given queue via a call to __introspection_dispatch_queue_get_pend...
Definition: AppleGetPendingItemsHandler.cpp:211