LLDB  mainline
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
SystemRuntimeMacOSX Class Reference

#include <SystemRuntimeMacOSX.h>

Inheritance diagram for SystemRuntimeMacOSX:
Inheritance graph
[legend]
Collaboration diagram for SystemRuntimeMacOSX:
Collaboration graph
[legend]

Public Member Functions

 SystemRuntimeMacOSX (lldb_private::Process *process)
 
 ~SystemRuntimeMacOSX () override
 
void Clear (bool clear_process)
 
void Detach () override
 Called before detaching from a process. More...
 
const std::vector< lldb_private::ConstString > & GetExtendedBacktraceTypes () override
 Return a list of thread origin extended backtraces that may be available. More...
 
lldb::ThreadSP GetExtendedBacktraceThread (lldb::ThreadSP thread, lldb_private::ConstString type) override
 Return a Thread which shows the origin of this thread's creation. More...
 
lldb::ThreadSP GetExtendedBacktraceForQueueItem (lldb::QueueItemSP queue_item_sp, lldb_private::ConstString type) override
 Get the extended backtrace thread for a QueueItem. More...
 
lldb::ThreadSP GetExtendedBacktraceFromItemRef (lldb::addr_t item_ref)
 
void PopulateQueueList (lldb_private::QueueList &queue_list) override
 Populate the Process' QueueList with libdispatch / GCD queues that exist. More...
 
void PopulateQueuesUsingLibBTR (lldb::addr_t queues_buffer, uint64_t queues_buffer_size, uint64_t count, lldb_private::QueueList &queue_list)
 
void PopulatePendingQueuesUsingLibBTR (lldb::addr_t items_buffer, uint64_t items_buffer_size, uint64_t count, lldb_private::Queue *queue)
 
std::string GetQueueNameFromThreadQAddress (lldb::addr_t dispatch_qaddr) override
 Get the queue name for a thread given a thread's dispatch_qaddr. More...
 
lldb::queue_id_t GetQueueIDFromThreadQAddress (lldb::addr_t dispatch_qaddr) override
 Get the QueueID for the libdispatch queue given the thread's dispatch_qaddr. More...
 
lldb::addr_t GetLibdispatchQueueAddressFromThreadQAddress (lldb::addr_t dispatch_qaddr) override
 Get the libdispatch_queue_t address for the queue given the thread's dispatch_qaddr. More...
 
void PopulatePendingItemsForQueue (lldb_private::Queue *queue) override
 Get the pending work items for a libdispatch Queue. More...
 
void CompleteQueueItem (lldb_private::QueueItem *queue_item, lldb::addr_t item_ref) override
 Complete the fields in a QueueItem. More...
 
lldb::QueueKind GetQueueKind (lldb::addr_t dispatch_queue_addr) override
 Retrieve the Queue kind for the queue at a thread's dispatch_qaddr. More...
 
void AddThreadExtendedInfoPacketHints (lldb_private::StructuredData::ObjectSP dict) override
 Add key-value pairs to the StructuredData dictionary object with information debugserver may need when constructing the jThreadExtendedInfo packet. More...
 
bool SafeToCallFunctionsOnThisThread (lldb::ThreadSP thread_sp) override
 Determine whether it is safe to run an expression on a given thread. More...
 
lldb_private::ConstString GetPluginName () override
 
uint32_t GetPluginVersion () override
 
- Public Member Functions inherited from lldb_private::SystemRuntime
 SystemRuntime (lldb_private::Process *process)
 Construct with a process. More...
 
 ~SystemRuntime () override
 Destructor. More...
 
virtual void DidAttach ()
 Called after attaching to a process. More...
 
virtual void DidLaunch ()
 Called after launching a process. More...
 
virtual void ModulesDidLoad (lldb_private::ModuleList &module_list)
 Called when modules have been loaded in the process. More...
 
- Public Member Functions inherited from lldb_private::PluginInterface
virtual ~PluginInterface ()
 

Static Public Member Functions

static void Initialize ()
 
static void Terminate ()
 
static lldb_private::ConstString GetPluginNameStatic ()
 
static const char * GetPluginDescriptionStatic ()
 
static lldb_private::SystemRuntimeCreateInstance (lldb_private::Process *process)
 
- Static Public Member Functions inherited from lldb_private::SystemRuntime
static SystemRuntimeFindPlugin (Process *process)
 Find a system runtime plugin for a given process. More...
 

Protected Attributes

lldb::user_id_t m_break_id
 
std::recursive_mutex m_mutex
 
- Protected Attributes inherited from lldb_private::SystemRuntime
Processm_process
 
std::vector< ConstStringm_types
 

Detailed Description

Definition at line 31 of file SystemRuntimeMacOSX.h.

Constructor & Destructor Documentation

◆ SystemRuntimeMacOSX()

SystemRuntimeMacOSX::SystemRuntimeMacOSX ( lldb_private::Process process)

Definition at line 77 of file SystemRuntimeMacOSX.cpp.

◆ ~SystemRuntimeMacOSX()

SystemRuntimeMacOSX::~SystemRuntimeMacOSX ( )
override

Definition at line 92 of file SystemRuntimeMacOSX.cpp.

References Clear().

Member Function Documentation

◆ AddThreadExtendedInfoPacketHints()

void SystemRuntimeMacOSX::AddThreadExtendedInfoPacketHints ( lldb_private::StructuredData::ObjectSP  dict)
overridevirtual

Add key-value pairs to the StructuredData dictionary object with information debugserver may need when constructing the jThreadExtendedInfo packet.

Parameters
[out]dictDictionary to which key-value pairs should be added; they will be sent to the remote gdb server stub as arguments in the jThreadExtendedInfo request.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 192 of file SystemRuntimeMacOSX.cpp.

References lldb_private::StructuredData::Dictionary::AddIntegerItem(), and lldb_private::StructuredData::Object::GetAsDictionary().

◆ Clear()

void SystemRuntimeMacOSX::Clear ( bool  clear_process)

◆ CompleteQueueItem()

void SystemRuntimeMacOSX::CompleteQueueItem ( lldb_private::QueueItem queue_item,
lldb::addr_t  item_ref 
)
overridevirtual

◆ CreateInstance()

SystemRuntime * SystemRuntimeMacOSX::CreateInstance ( lldb_private::Process process)
static

◆ Detach()

void SystemRuntimeMacOSX::Detach ( )
overridevirtual

Called before detaching from a process.

This will give a SystemRuntime plugin a chance to free any resources in the inferior process before we detach.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 94 of file SystemRuntimeMacOSX.cpp.

References lldb_private::AppleGetQueuesHandler::Detach(), lldb_private::AppleGetThreadItemInfoHandler::Detach(), lldb_private::AppleGetItemInfoHandler::Detach(), and lldb_private::AppleGetPendingItemsHandler::Detach().

◆ GetExtendedBacktraceForQueueItem()

ThreadSP SystemRuntimeMacOSX::GetExtendedBacktraceForQueueItem ( lldb::QueueItemSP  queue_item_sp,
lldb_private::ConstString  type 
)
overridevirtual

Get the extended backtrace thread for a QueueItem.

A QueueItem represents a function/block that will be executed on a libdispatch queue in the future, or it represents a function/block that is currently executing on a thread.

This method will report a thread backtrace of the function that enqueued it originally, if possible.

Parameters
[in]queue_item_spThe QueueItem that we are getting an extended backtrace for.
[in]typeThe type of extended backtrace to fetch. The types supported are returned from SystemRuntime::GetExtendedBacktraceTypes.
Returns
If an extended backtrace is available, it is returned. Else an empty ThreadSP is returned.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 553 of file SystemRuntimeMacOSX.cpp.

References lldb_private::SymbolContextList::Clear(), lldb::eSymbolTypeData, lldb_private::ModuleList::FindSymbolsWithNameAndType(), lldb_private::SymbolContext::GetAddressRange(), lldb_private::AddressRange::GetBaseAddress(), lldb_private::SymbolContextList::GetContextAtIndex(), lldb_private::Target::GetImages(), lldb_private::Address::GetLoadAddress(), lldb_private::Process::GetStopID(), lldb_private::Process::GetTarget(), LLDB_INVALID_ADDRESS, lldb_private::SystemRuntime::m_process, lldb_private::Process::ReadUnsignedIntegerFromMemory(), and lldb_private::Status::Success().

◆ GetExtendedBacktraceFromItemRef()

ThreadSP SystemRuntimeMacOSX::GetExtendedBacktraceFromItemRef ( lldb::addr_t  item_ref)

◆ GetExtendedBacktraceThread()

ThreadSP SystemRuntimeMacOSX::GetExtendedBacktraceThread ( lldb::ThreadSP  thread,
lldb_private::ConstString  type 
)
overridevirtual

Return a Thread which shows the origin of this thread's creation.

This likely returns a HistoryThread which shows how thread was originally created (e.g. "pthread" type), or how the work that is currently executing on it was originally enqueued (e.g. "libdispatch" type).

There may be a chain of thread-origins; it may be informative to the end user to query the returned ThreadSP for its origins as well.

Parameters
[in]threadThe thread to examine.
[in]typeThe type of thread origin being requested. The types supported are returned from SystemRuntime::GetExtendedBacktraceTypes.
Returns
A ThreadSP which will have a StackList of frames. This Thread will not appear in the Process' list of current threads. Normal thread operations like stepping will not be available. This is a historical view thread and may be only useful for showing a backtrace.

An empty ThreadSP will be returned if no thread origin is available.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 454 of file SystemRuntimeMacOSX.cpp.

References lldb_private::Process::GetAddressByteSize(), lldb_private::Process::GetByteOrder(), lldb_private::DataBufferHeap::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::ThreadList::GetExpressionExecutionThread(), GetExtendedBacktraceFromItemRef(), lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfo(), lldb_private::Process::GetThreadList(), LLDB_INVALID_ADDRESS, lldb_private::SystemRuntime::m_process, lldb_private::Process::ReadMemory(), and lldb_private::Status::Success().

◆ GetExtendedBacktraceTypes()

const std::vector< ConstString > & SystemRuntimeMacOSX::GetExtendedBacktraceTypes ( )
overridevirtual

Return a list of thread origin extended backtraces that may be available.

A System Runtime may be able to provide a backtrace of when this thread was originally created. Furthermore, it may be able to provide that extended backtrace for different styles of creation. On a system with both pthreads and libdispatch, aka Grand Central Dispatch, queues, the system runtime may be able to provide the pthread creation of the thread and it may also be able to provide the backtrace of when this GCD queue work block was enqueued. The caller may request these different origins by name.

The names will be provided in the order that they are most likely to be requested. For instance, a most natural order may be to request the GCD libdispatch queue origin. If there is none, then request the pthread origin.

Returns
A vector of ConstStrings with names like "pthread" or "libdispatch". An empty vector may be returned if no thread origin extended backtrace capabilities are available.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 684 of file SystemRuntimeMacOSX.cpp.

References lldb_private::SystemRuntime::m_types.

◆ GetLibdispatchQueueAddressFromThreadQAddress()

lldb::addr_t SystemRuntimeMacOSX::GetLibdispatchQueueAddressFromThreadQAddress ( lldb::addr_t  dispatch_qaddr)
overridevirtual

Get the libdispatch_queue_t address for the queue given the thread's dispatch_qaddr.

On systems using libdispatch queues, a thread may be associated with a queue. There will be a call to get the thread's dispatch_qaddr. Given the thread's dispatch_qaddr, find the libdispatch_queue_t address and return it.

Parameters
[in]dispatch_qaddrThe address of the dispatch_qaddr pointer for this thread.
Returns
The libdispatch_queue_t address, or LLDB_INVALID_ADDRESS if unavailable/not found.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 156 of file SystemRuntimeMacOSX.cpp.

References LLDB_INVALID_ADDRESS, lldb_private::SystemRuntime::m_process, lldb_private::Process::ReadPointerFromMemory(), and lldb_private::Status::Success().

◆ GetPluginDescriptionStatic()

const char * SystemRuntimeMacOSX::GetPluginDescriptionStatic ( )
static

Definition at line 1002 of file SystemRuntimeMacOSX.cpp.

Referenced by Initialize().

◆ GetPluginName()

lldb_private::ConstString SystemRuntimeMacOSX::GetPluginName ( )
overridevirtual

Implements lldb_private::PluginInterface.

Definition at line 1007 of file SystemRuntimeMacOSX.cpp.

References GetPluginNameStatic().

◆ GetPluginNameStatic()

lldb_private::ConstString SystemRuntimeMacOSX::GetPluginNameStatic ( )
static

Definition at line 997 of file SystemRuntimeMacOSX.cpp.

Referenced by GetPluginName(), and Initialize().

◆ GetPluginVersion()

uint32_t SystemRuntimeMacOSX::GetPluginVersion ( )
overridevirtual

Implements lldb_private::PluginInterface.

Definition at line 1011 of file SystemRuntimeMacOSX.cpp.

◆ GetQueueIDFromThreadQAddress()

lldb::queue_id_t SystemRuntimeMacOSX::GetQueueIDFromThreadQAddress ( lldb::addr_t  dispatch_qaddr)
overridevirtual

Get the QueueID for the libdispatch queue given the thread's dispatch_qaddr.

On systems using libdispatch queues, a thread may be associated with a queue. There will be a call to get the thread's dispatch_qaddr. At the dispatch_qaddr we will find the address of this thread's dispatch_queue_t structure. Given the address of the dispatch_queue_t structure for a thread, get the queue ID and return it.

Parameters
[in]dispatch_qaddrThe address of the dispatch_qaddr pointer for this thread.
Returns
The queue ID, or if it could not be retrieved, LLDB_INVALID_QUEUE_ID.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 234 of file SystemRuntimeMacOSX.cpp.

References lldb_private::ClangASTContext::CreateRecordType(), lldb::eAccessPublic, lldb::eEncodingUint, lldb::eLanguageTypeC, lldb::eSymbolTypeData, lldb_private::ModuleList::FindFirstModule(), lldb_private::Process::GetAddressByteSize(), lldb_private::ClangASTContext::getASTContext(), lldb_private::ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(), lldb_private::Process::GetByteOrder(), lldb_private::ProcessStructReader::GetField(), lldb_private::Target::GetImages(), lldb_private::Symbol::GetLoadAddress(), lldb_private::Target::GetScratchClangASTContext(), lldb_private::Process::GetTarget(), LLDB_INVALID_ADDRESS, LLDB_INVALID_QUEUE_ID, lldb_private::SystemRuntime::m_process, lldb_private::Process::ReadMemory(), lldb_private::Process::ReadPointerFromMemory(), lldb_private::Target::ReadUnsignedIntegerFromMemory(), lldb_private::Process::ReadUnsignedIntegerFromMemory(), lldb_private::Target::ResolveLoadAddress(), and lldb_private::Status::Success().

◆ GetQueueKind()

lldb::QueueKind SystemRuntimeMacOSX::GetQueueKind ( lldb::addr_t  dispatch_qaddr)
overridevirtual

Retrieve the Queue kind for the queue at a thread's dispatch_qaddr.

Retrieve the Queue kind - either eQueueKindSerial or eQueueKindConcurrent, indicating that this queue processes work items serially or concurrently.

Returns
The Queue kind, if it could be read, else eQueueKindUnknown.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 168 of file SystemRuntimeMacOSX.cpp.

References lldb::eQueueKindConcurrent, lldb::eQueueKindSerial, lldb::eQueueKindUnknown, LLDB_INVALID_ADDRESS, lldb_private::SystemRuntime::m_process, lldb_private::Process::ReadUnsignedIntegerFromMemory(), and lldb_private::Status::Success().

Referenced by PopulateQueueList(), and PopulateQueuesUsingLibBTR().

◆ GetQueueNameFromThreadQAddress()

std::string SystemRuntimeMacOSX::GetQueueNameFromThreadQAddress ( lldb::addr_t  dispatch_qaddr)
overridevirtual

Get the queue name for a thread given a thread's dispatch_qaddr.

On systems using libdispatch queues, a thread may be associated with a queue. There will be a call to get the thread's dispatch_qaddr. At the dispatch_qaddr we will find the address of this thread's dispatch_queue_t structure. Given the address of the dispatch_queue_t structure for a thread, get the queue name and return it.

Parameters
[in]dispatch_qaddrThe address of the dispatch_qaddr pointer for this thread.
Returns
The string of this queue's name. An empty string is returned if the name could not be found.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 114 of file SystemRuntimeMacOSX.cpp.

References LLDB_INVALID_ADDRESS, lldb_private::SystemRuntime::m_process, lldb_private::Process::ReadCStringFromMemory(), lldb_private::Process::ReadMemory(), lldb_private::Process::ReadPointerFromMemory(), and lldb_private::Status::Success().

◆ Initialize()

void SystemRuntimeMacOSX::Initialize ( )
static

◆ PopulatePendingItemsForQueue()

void SystemRuntimeMacOSX::PopulatePendingItemsForQueue ( lldb_private::Queue queue)
overridevirtual

Get the pending work items for a libdispatch Queue.

If this system/process is using libdispatch and the runtime can do so, retrieve the list of pending work items for the specified Queue and add it to the Queue.

Parameters
[in]queueThe queue of interest.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 835 of file SystemRuntimeMacOSX.cpp.

References lldb_private::Queue::GetLibdispatchQueueAddress(), lldb_private::Process::GetTarget(), lldb_private::SystemRuntime::m_process, lldb_private::Queue::PushPendingQueueItem(), and lldb_private::Target::ResolveLoadAddress().

◆ PopulatePendingQueuesUsingLibBTR()

void SystemRuntimeMacOSX::PopulatePendingQueuesUsingLibBTR ( lldb::addr_t  items_buffer,
uint64_t  items_buffer_size,
uint64_t  count,
lldb_private::Queue queue 
)

◆ PopulateQueueList()

void SystemRuntimeMacOSX::PopulateQueueList ( lldb_private::QueueList queue_list)
overridevirtual

Populate the Process' QueueList with libdispatch / GCD queues that exist.

When process execution is paused, the SystemRuntime may be called to fill in the list of Queues that currently exist.

Parameters
[out]queue_listThis QueueList will be cleared, and any queues that currently exist will be added. An empty QueueList will be returned if no queues exist or if this Systemruntime does not support libdispatch queues.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 693 of file SystemRuntimeMacOSX.cpp.

References lldb_private::QueueList::AddQueue(), lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::count, lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::count, lldb_private::eLazyBoolNo, lldb_private::QueueList::FindQueueByID(), lldb_private::Process::GetAddressByteSize(), lldb_private::Process::GetByteOrder(), lldb_private::DataBufferHeap::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::AppleGetQueuesHandler::GetCurrentQueues(), lldb_private::ThreadList::GetExpressionExecutionThread(), lldb_private::AppleGetPendingItemsHandler::GetPendingItems(), GetQueueKind(), lldb_private::Process::GetThreadList(), lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::items_buffer_ptr, lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::items_buffer_size, LLDB_INVALID_ADDRESS, LLDB_INVALID_QUEUE_ID, lldb_private::SystemRuntime::m_process, PopulateQueuesUsingLibBTR(), lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::queues_buffer_ptr, lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::queues_buffer_size, lldb_private::Process::ReadMemory(), lldb_private::Status::Success(), and lldb_private::Process::Threads().

◆ PopulateQueuesUsingLibBTR()

void SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR ( lldb::addr_t  queues_buffer,
uint64_t  queues_buffer_size,
uint64_t  count,
lldb_private::QueueList queue_list 
)

◆ SafeToCallFunctionsOnThisThread()

bool SystemRuntimeMacOSX::SafeToCallFunctionsOnThisThread ( lldb::ThreadSP  thread_sp)
overridevirtual

Determine whether it is safe to run an expression on a given thread.

If a system must not run functions on a thread in some particular state, this method gives a way for it to flag that the expression should not be run.

Parameters
[in]thread_spThe thread we want to run the expression on.
Returns
True will be returned if there are no known problems with running an expression on this thread. False means that the inferior function call should not be made on this thread.

Reimplemented from lldb_private::SystemRuntime.

Definition at line 219 of file SystemRuntimeMacOSX.cpp.

◆ Terminate()

void SystemRuntimeMacOSX::Terminate ( )
static

Definition at line 993 of file SystemRuntimeMacOSX.cpp.

References CreateInstance().

Referenced by lldb_private::SystemInitializerFull::Terminate().

Member Data Documentation

◆ m_break_id

lldb::user_id_t SystemRuntimeMacOSX::m_break_id
protected

Definition at line 106 of file SystemRuntimeMacOSX.h.

Referenced by Clear().

◆ m_mutex

std::recursive_mutex SystemRuntimeMacOSX::m_mutex
mutableprotected

Definition at line 107 of file SystemRuntimeMacOSX.h.

Referenced by Clear().


The documentation for this class was generated from the following files: