LLDB  mainline
AppleGetQueuesHandler.h
Go to the documentation of this file.
1 //===-- AppleGetQueuesHandler.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_APPLEGETQUEUESHANDLER_H
10 #define LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETQUEUESHANDLER_H
11 
12 #include <map>
13 #include <mutex>
14 #include <vector>
15 
17 #include "lldb/Utility/Status.h"
18 #include "lldb/lldb-public.h"
19 
20 // This class will insert a UtilityFunction into the inferior process for
21 // calling libBacktraceRecording's introspection_get_dispatch_queues()
22 // function. The function in the inferior will return a struct by value
23 // with these members:
24 //
25 // struct get_current_queues_return_values
26 // {
27 // introspection_dispatch_queue_info_t *queues_buffer;
28 // uint64_t queues_buffer_size;
29 // uint64_t count;
30 // };
31 //
32 // The queues_buffer pointer is an address in the inferior program's address
33 // space (queues_buffer_size in size) which must be mach_vm_deallocate'd by
34 // lldb. count is the number of queues that were stored in the buffer.
35 //
36 // The AppleGetQueuesHandler object should persist so that the UtilityFunction
37 // can be reused multiple times.
38 
39 namespace lldb_private {
40 
42 public:
44 
46 
49  LLDB_INVALID_ADDRESS; /* the address of the queues buffer from
50  libBacktraceRecording */
51  lldb::addr_t queues_buffer_size = 0; /* the size of the queues buffer from
52  libBacktraceRecording */
53  uint64_t count = 0; /* the number of queues included in the queues buffer */
54 
55  GetQueuesReturnInfo() = default;
56  };
57 
58  /// Get the list of queues that exist (with any active or pending items) via
59  /// a call to introspection_get_dispatch_queues(). 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] 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 queues_buffer_ptr value will be
83  /// LLDB_INVALID_ADDRESS.
85  lldb::addr_t page_to_free,
86  uint64_t page_to_free_size,
88 
89  void Detach();
90 
91 private:
93  ValueList &get_queues_arglist);
94 
97 
99  std::unique_ptr<UtilityFunction> m_get_queues_impl_code_up;
101 
104 };
105 
106 } // using namespace lldb_private
107 
108 #endif // LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETQUEUESHANDLER_H
lldb-public.h
lldb_private::AppleGetQueuesHandler::GetCurrentQueues
GetQueuesReturnInfo GetCurrentQueues(Thread &thread, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the list of queues that exist (with any active or pending items) via a call to introspection_get_...
Definition: AppleGetQueuesHandler.cpp:217
lldb_private::AppleGetQueuesHandler::m_get_queues_return_buffer_addr
lldb::addr_t m_get_queues_return_buffer_addr
Definition: AppleGetQueuesHandler.h:102
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::AppleGetQueuesHandler::m_get_queues_retbuffer_mutex
std::mutex m_get_queues_retbuffer_mutex
Definition: AppleGetQueuesHandler.h:103
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::AppleGetQueuesHandler::~AppleGetQueuesHandler
~AppleGetQueuesHandler()
lldb_private::Thread
Definition: Thread.h:60
lldb_private::AppleGetQueuesHandler
Definition: AppleGetQueuesHandler.h:41
lldb_private::AppleGetQueuesHandler::g_get_current_queues_function_code
static const char * g_get_current_queues_function_code
Definition: AppleGetQueuesHandler.h:96
lldb_private::AppleGetQueuesHandler::m_process
lldb_private::Process * m_process
Definition: AppleGetQueuesHandler.h:98
lldb_private::AppleGetQueuesHandler::Detach
void Detach()
Definition: AppleGetQueuesHandler.cpp:104
lldb_private::AppleGetQueuesHandler::SetupGetQueuesFunction
lldb::addr_t SetupGetQueuesFunction(Thread &thread, ValueList &get_queues_arglist)
Definition: AppleGetQueuesHandler.cpp:142
CompilerType.h
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::queues_buffer_ptr
lldb::addr_t queues_buffer_ptr
Definition: AppleGetQueuesHandler.h:48
lldb_private::Status
Definition: Status.h:44
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::queues_buffer_size
lldb::addr_t queues_buffer_size
Definition: AppleGetQueuesHandler.h:51
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
Status.h
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo
Definition: AppleGetQueuesHandler.h:47
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::AppleGetQueuesHandler::AppleGetQueuesHandler
AppleGetQueuesHandler(lldb_private::Process *process)
Definition: AppleGetQueuesHandler.cpp:96
lldb_private::AppleGetQueuesHandler::g_get_current_queues_function_name
static const char * g_get_current_queues_function_name
Definition: AppleGetQueuesHandler.h:95
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::count
uint64_t count
Definition: AppleGetQueuesHandler.h:53
lldb_private::AppleGetQueuesHandler::m_get_queues_impl_code_up
std::unique_ptr< UtilityFunction > m_get_queues_impl_code_up
Definition: AppleGetQueuesHandler.h:99
lldb_private::AppleGetQueuesHandler::m_get_queues_function_mutex
std::mutex m_get_queues_function_mutex
Definition: AppleGetQueuesHandler.h:100
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::GetQueuesReturnInfo
GetQueuesReturnInfo()=default