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
39namespace lldb_private {
40
42public:
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
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
91private:
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
static llvm::raw_ostream & error(Stream &strm)
std::unique_ptr< UtilityFunction > m_get_queues_impl_code_up
lldb::addr_t SetupGetQueuesFunction(Thread &thread, ValueList &get_queues_arglist)
static const char * g_get_current_queues_function_name
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_...
static const char * g_get_current_queues_function_code
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
An error handling class.
Definition: Status.h:44
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
A class that represents a running process on the host machine.
uint64_t addr_t
Definition: lldb-types.h:80