LLDB mainline
AppleGetThreadItemInfoHandler.h
Go to the documentation of this file.
1//===-- AppleGetThreadItemInfoHandler.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_APPLEGETTHREADITEMINFOHANDLER_H
11#define LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETTHREADITEMINFOHANDLER_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_thread_get_item_info()
24// function. The function in the inferior will return a struct by value
25// with these members:
26//
27// struct get_thread_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 AppleGetThreadItemInfoHandler object should persist so that the
38// UtilityFunction
39// can be reused multiple times.
40
41namespace lldb_private {
42
44public:
46
48
51 item buffer from libBacktraceRecording */
52 lldb::addr_t item_buffer_size = 0; /* the size of the item buffer from
53 libBacktraceRecording */
54
56 };
57
58 /// Get the information about a work item by calling
59 /// __introspection_dispatch_thread_get_item_info. 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_id
64 /// The thread to get the extended backtrace for.
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 item_buffer_ptr value will be
83 /// LLDB_INVALID_ADDRESS.
85 lldb::tid_t thread_id,
86 lldb::addr_t page_to_free,
87 uint64_t page_to_free_size,
89
90 void Detach();
91
92private:
95 ValueList &get_thread_item_info_arglist);
96
99
101 std::unique_ptr<UtilityFunction> m_get_thread_item_info_impl_code;
103
106};
107
108} // using namespace lldb_private
109
110#endif // LLDB_SOURCE_PLUGINS_SYSTEMRUNTIME_MACOSX_APPLEGETTHREADITEMINFOHANDLER_H
static llvm::raw_ostream & error(Stream &strm)
GetThreadItemInfoReturnInfo GetThreadItemInfo(Thread &thread, lldb::tid_t thread_id, 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_thread_get_item_info.
std::unique_ptr< UtilityFunction > m_get_thread_item_info_impl_code
lldb::addr_t SetupGetThreadItemInfoFunction(Thread &thread, ValueList &get_thread_item_info_arglist)
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.
Definition: SBAttachInfo.h:14
uint64_t addr_t
Definition: lldb-types.h:79
uint64_t tid_t
Definition: lldb-types.h:82