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 
41 namespace lldb_private {
42 
44 public:
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 
55  GetThreadItemInfoReturnInfo() = default;
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 
92 private:
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
lldb_private::AppleGetThreadItemInfoHandler::g_get_thread_item_info_function_name
static const char * g_get_thread_item_info_function_name
Definition: AppleGetThreadItemInfoHandler.h:97
lldb-public.h
lldb_private::Process
Definition: Process.h:341
lldb_private::AppleGetThreadItemInfoHandler::m_process
lldb_private::Process * m_process
Definition: AppleGetThreadItemInfoHandler.h:100
lldb_private::ValueList
Definition: Value.h:157
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::AppleGetThreadItemInfoHandler::AppleGetThreadItemInfoHandler
AppleGetThreadItemInfoHandler(lldb_private::Process *process)
Definition: AppleGetThreadItemInfoHandler.cpp:104
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo::item_buffer_size
lldb::addr_t item_buffer_size
Definition: AppleGetThreadItemInfoHandler.h:52
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo
Definition: AppleGetThreadItemInfoHandler.h:49
lldb_private::AppleGetThreadItemInfoHandler::m_get_thread_item_info_impl_code
std::unique_ptr< UtilityFunction > m_get_thread_item_info_impl_code
Definition: AppleGetThreadItemInfoHandler.h:101
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo::item_buffer_ptr
lldb::addr_t item_buffer_ptr
Definition: AppleGetThreadItemInfoHandler.h:50
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::AppleGetThreadItemInfoHandler
Definition: AppleGetThreadItemInfoHandler.h:43
lldb_private::Thread
Definition: Thread.h:62
lldb_private::AppleGetThreadItemInfoHandler::SetupGetThreadItemInfoFunction
lldb::addr_t SetupGetThreadItemInfoFunction(Thread &thread, ValueList &get_thread_item_info_arglist)
Definition: AppleGetThreadItemInfoHandler.cpp:137
lldb_private::AppleGetThreadItemInfoHandler::~AppleGetThreadItemInfoHandler
~AppleGetThreadItemInfoHandler()
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfo
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.
Definition: AppleGetThreadItemInfoHandler.cpp:217
lldb_private::AppleGetThreadItemInfoHandler::Detach
void Detach()
Definition: AppleGetThreadItemInfoHandler.cpp:112
lldb_private::AppleGetThreadItemInfoHandler::m_get_thread_item_info_return_buffer_addr
lldb::addr_t m_get_thread_item_info_return_buffer_addr
Definition: AppleGetThreadItemInfoHandler.h:104
CompilerType.h
lldb_private::Status
Definition: Status.h:44
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo::GetThreadItemInfoReturnInfo
GetThreadItemInfoReturnInfo()=default
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::AppleGetThreadItemInfoHandler::g_get_thread_item_info_function_code
static const char * g_get_thread_item_info_function_code
Definition: AppleGetThreadItemInfoHandler.h:98
lldb_private::AppleGetThreadItemInfoHandler::m_get_thread_item_info_function_mutex
std::mutex m_get_thread_item_info_function_mutex
Definition: AppleGetThreadItemInfoHandler.h:102
lldb_private::AppleGetThreadItemInfoHandler::m_get_thread_item_info_retbuffer_mutex
std::mutex m_get_thread_item_info_retbuffer_mutex
Definition: AppleGetThreadItemInfoHandler.h:105
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86