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

#include <DynamicLoaderDarwinKernel.h>

Inheritance diagram for DynamicLoaderDarwinKernel:
Inheritance graph
[legend]

Classes

class  KextImageInfo
 
struct  OSKextLoadedKextSummaryHeader
 

Public Member Functions

 DynamicLoaderDarwinKernel (lldb_private::Process *process, lldb::addr_t kernel_addr)
 
 ~DynamicLoaderDarwinKernel () override
 
void DidAttach () override
 Called after attaching a process.
 
void DidLaunch () override
 Called after attaching a process.
 
lldb::ThreadPlanSP GetStepThroughTrampolinePlan (lldb_private::Thread &thread, bool stop_others) override
 Provides a plan to step through the dynamic loader trampoline for the current state of thread.
 
lldb_private::Status CanLoadImage () override
 Ask if it is ok to try and load or unload an shared library (image).
 
llvm::StringRef GetPluginName () override
 
- Public Member Functions inherited from lldb_private::DynamicLoader
 DynamicLoader (Process *process)
 Construct with a process.
 
virtual void DidAttach ()=0
 Called after attaching a process.
 
virtual void DidLaunch ()=0
 Called after launching a process.
 
virtual bool ProcessDidExec ()
 Helper function that can be used to detect when a process has called exec and is now a new and different process.
 
bool GetStopWhenImagesChange () const
 Get whether the process should stop when images change.
 
void SetStopWhenImagesChange (bool stop)
 Set whether the process should stop when images change.
 
virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan (Thread &thread, bool stop_others)=0
 Provides a plan to step through the dynamic loader trampoline for the current state of thread.
 
virtual void FindEquivalentSymbols (Symbol *original_symbol, ModuleList &module_list, SymbolContextList &equivalent_symbols)
 Some dynamic loaders provide features where there are a group of symbols "equivalent to" a given symbol one of which will be chosen when the symbol is bound.
 
virtual Status CanLoadImage ()=0
 Ask if it is ok to try and load or unload an shared library (image).
 
virtual bool AlwaysRelyOnEHUnwindInfo (SymbolContext &sym_ctx)
 Ask if the eh_frame information for the given SymbolContext should be relied on even when it's the first frame in a stack unwind.
 
virtual lldb::addr_t GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr)
 Retrieves the per-module TLS block for a given thread.
 
virtual lldb::ModuleSP LoadModuleAtAddress (const lldb_private::FileSpec &file, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset)
 Locates or creates a module given by file and updates/loads the resulting module at the virtual base address base_addr.
 
virtual bool GetSharedCacheInformation (lldb::addr_t &base_address, UUID &uuid, LazyBool &using_shared_cache, LazyBool &private_shared_cache)
 Get information about the shared cache for a process, if possible.
 
virtual bool IsFullyInitialized ()
 Return whether the dynamic loader is fully initialized and it's safe to call its APIs.
 
virtual std::optional< lldb_private::AddressGetStartAddress ()
 Return the start address in the dynamic loader module.
 
- Public Member Functions inherited from lldb_private::PluginInterface
 PluginInterface ()=default
 
virtual ~PluginInterface ()=default
 
virtual llvm::StringRef GetPluginName ()=0
 
 PluginInterface (const PluginInterface &)=delete
 
PluginInterfaceoperator= (const PluginInterface &)=delete
 

Static Public Member Functions

static void Initialize ()
 
static void Terminate ()
 
static llvm::StringRef GetPluginNameStatic ()
 
static llvm::StringRef GetPluginDescriptionStatic ()
 
static lldb_private::DynamicLoaderCreateInstance (lldb_private::Process *process, bool force)
 
static void DebuggerInitialize (lldb_private::Debugger &debugger)
 
static lldb::addr_t SearchForDarwinKernel (lldb_private::Process *process)
 
- Static Public Member Functions inherited from lldb_private::DynamicLoader
static DynamicLoaderFindPlugin (Process *process, llvm::StringRef plugin_name)
 Find a dynamic loader plugin for a given process.
 
static lldb::ModuleSP LoadBinaryWithUUIDAndAddress (Process *process, llvm::StringRef name, UUID uuid, lldb::addr_t value, bool value_is_offset, bool force_symbol_search, bool notify, bool set_address_in_target, bool allow_memory_image_last_resort)
 Find/load a binary into lldb given a UUID and the address where it is loaded in memory, or a slide to be applied to the file address.
 

Protected Types

enum  { KERNEL_MODULE_MAX_NAME = 64u , KERNEL_MODULE_ENTRY_SIZE_VERSION_1 = 64u + 16u + 8u + 8u + 8u + 4u + 4u }
 

Protected Member Functions

void PrivateInitialize (lldb_private::Process *process)
 
void PrivateProcessStateChanged (lldb_private::Process *process, lldb::StateType state)
 
void UpdateIfNeeded ()
 
void LoadKernelModuleIfNeeded ()
 
void Clear (bool clear_process)
 
void PutToLog (lldb_private::Log *log) const
 
bool BreakpointHit (lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
 
uint32_t GetAddrByteSize ()
 
void RegisterNotificationCallbacks ()
 
void UnregisterNotificationCallbacks ()
 
void SetNotificationBreakpointIfNeeded ()
 
bool ReadAllKextSummaries ()
 
bool ReadKextSummaryHeader ()
 
bool ParseKextSummaries (const lldb_private::Address &kext_summary_addr, uint32_t count)
 
void UpdateImageInfosHeaderAndLoadCommands (KextImageInfo::collection &image_infos, uint32_t infos_count, bool update_executable)
 
uint32_t ReadKextSummaries (const lldb_private::Address &kext_summary_addr, uint32_t image_infos_count, KextImageInfo::collection &image_infos)
 
- Protected Member Functions inherited from lldb_private::DynamicLoader
lldb::ModuleSP FindModuleViaTarget (const FileSpec &file)
 
lldb::ModuleSP GetTargetExecutable ()
 Checks to see if the target module has changed, updates the target accordingly and returns the target executable module.
 
virtual void UpdateLoadedSections (lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset)
 Updates the load address of every allocatable section in module.
 
void UpdateLoadedSectionsCommon (lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset)
 
virtual void UnloadSections (const lldb::ModuleSP module)
 Removes the loaded sections from the target in module.
 
void UnloadSectionsCommon (const lldb::ModuleSP module)
 
const lldb_private::SectionListGetSectionListFromModule (const lldb::ModuleSP module) const
 
int64_t ReadUnsignedIntWithSizeInBytes (lldb::addr_t addr, int size_in_bytes)
 
lldb::addr_t ReadPointer (lldb::addr_t addr)
 
void LoadOperatingSystemPlugin (bool flush)
 

Static Protected Member Functions

static bool BreakpointHitCallback (void *baton, lldb_private::StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
 
static lldb::ByteOrder GetByteOrderFromMagic (uint32_t magic)
 
static lldb::addr_t SearchForKernelAtSameLoadAddr (lldb_private::Process *process)
 
static lldb::addr_t SearchForKernelWithDebugHints (lldb_private::Process *process)
 
static lldb::addr_t SearchForKernelNearPC (lldb_private::Process *process)
 
static lldb::addr_t SearchForKernelViaExhaustiveSearch (lldb_private::Process *process)
 
static bool ReadMachHeader (lldb::addr_t addr, lldb_private::Process *process, llvm::MachO::mach_header &mh, bool *read_error=nullptr)
 
static lldb_private::UUID CheckForKernelImageAtAddress (lldb::addr_t addr, lldb_private::Process *process, bool *read_error=nullptr)
 

Protected Attributes

lldb::addr_t m_kernel_load_address
 
KextImageInfo m_kernel
 
lldb_private::Address m_kext_summary_header_ptr_addr
 
lldb_private::Address m_kext_summary_header_addr
 
OSKextLoadedKextSummaryHeader m_kext_summary_header
 
KextImageInfo::collection m_known_kexts
 
std::recursive_mutex m_mutex
 
lldb::user_id_t m_break_id
 
- Protected Attributes inherited from lldb_private::DynamicLoader
Processm_process
 The process that this dynamic loader plug-in is tracking.
 

Private Member Functions

 DynamicLoaderDarwinKernel (const DynamicLoaderDarwinKernel &)=delete
 
const DynamicLoaderDarwinKerneloperator= (const DynamicLoaderDarwinKernel &)=delete
 

Detailed Description

Definition at line 25 of file DynamicLoaderDarwinKernel.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
KERNEL_MODULE_MAX_NAME 
KERNEL_MODULE_ENTRY_SIZE_VERSION_1 

Definition at line 89 of file DynamicLoaderDarwinKernel.h.

Constructor & Destructor Documentation

◆ DynamicLoaderDarwinKernel() [1/2]

DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel ( lldb_private::Process process,
lldb::addr_t  kernel_addr 
)

◆ ~DynamicLoaderDarwinKernel()

DynamicLoaderDarwinKernel::~DynamicLoaderDarwinKernel ( )
override

Definition at line 523 of file DynamicLoaderDarwinKernel.cpp.

References Clear().

◆ DynamicLoaderDarwinKernel() [2/2]

DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel ( const DynamicLoaderDarwinKernel )
privatedelete

Member Function Documentation

◆ BreakpointHit()

bool DynamicLoaderDarwinKernel::BreakpointHit ( lldb_private::StoppointCallbackContext context,
lldb::user_id_t  break_id,
lldb::user_id_t  break_loc_id 
)
protected

◆ BreakpointHitCallback()

bool DynamicLoaderDarwinKernel::BreakpointHitCallback ( void *  baton,
lldb_private::StoppointCallbackContext context,
lldb::user_id_t  break_id,
lldb::user_id_t  break_loc_id 
)
staticprotected

Definition at line 1147 of file DynamicLoaderDarwinKernel.cpp.

References BreakpointHit().

Referenced by SetNotificationBreakpointIfNeeded().

◆ CanLoadImage()

Status DynamicLoaderDarwinKernel::CanLoadImage ( )
overridevirtual

Ask if it is ok to try and load or unload an shared library (image).

The dynamic loader often knows when it would be ok to try and load or unload a shared library. This function call allows the dynamic loader plug-ins to check any current dyld state to make sure it is an ok time to load a shared library.

Returns
true if it is currently ok to try and load a shared library into the process, false otherwise.

Implements lldb_private::DynamicLoader.

Definition at line 1606 of file DynamicLoaderDarwinKernel.cpp.

References error().

◆ CheckForKernelImageAtAddress()

lldb_private::UUID DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress ( lldb::addr_t  addr,
lldb_private::Process process,
bool *  read_error = nullptr 
)
staticprotected

◆ Clear()

void DynamicLoaderDarwinKernel::Clear ( bool  clear_process)
protected

◆ CreateInstance()

DynamicLoader * DynamicLoaderDarwinKernel::CreateInstance ( lldb_private::Process process,
bool  force 
)
static

◆ DebuggerInitialize()

void DynamicLoaderDarwinKernel::DebuggerInitialize ( lldb_private::Debugger debugger)
static

◆ DidAttach()

void DynamicLoaderDarwinKernel::DidAttach ( )
overridevirtual

Called after attaching a process.

We've attached to a remote connection, or read a corefile.

Allow DynamicLoader plug-ins to execute some code after attaching to a process.

Now load the kernel binary and potentially the kexts, add them to the Target.

Implements lldb_private::DynamicLoader.

Definition at line 533 of file DynamicLoaderDarwinKernel.cpp.

References lldb_private::DynamicLoader::m_process, PrivateInitialize(), and UpdateIfNeeded().

◆ DidLaunch()

void DynamicLoaderDarwinKernel::DidLaunch ( )
overridevirtual

Called after attaching a process.

Allow DynamicLoader plug-ins to execute some code after attaching to a process.

Implements lldb_private::DynamicLoader.

Definition at line 542 of file DynamicLoaderDarwinKernel.cpp.

References lldb_private::DynamicLoader::m_process, PrivateInitialize(), and UpdateIfNeeded().

◆ GetAddrByteSize()

uint32_t DynamicLoaderDarwinKernel::GetAddrByteSize ( )
inlineprotected

◆ GetByteOrderFromMagic()

lldb::ByteOrder DynamicLoaderDarwinKernel::GetByteOrderFromMagic ( uint32_t  magic)
staticprotected

◆ GetPluginDescriptionStatic()

llvm::StringRef DynamicLoaderDarwinKernel::GetPluginDescriptionStatic ( )
static

Definition at line 1635 of file DynamicLoaderDarwinKernel.cpp.

Referenced by Initialize().

◆ GetPluginName()

llvm::StringRef DynamicLoaderDarwinKernel::GetPluginName ( )
inlineoverridevirtual

Implements lldb_private::PluginInterface.

Definition at line 62 of file DynamicLoaderDarwinKernel.h.

References GetPluginNameStatic().

◆ GetPluginNameStatic()

static llvm::StringRef DynamicLoaderDarwinKernel::GetPluginNameStatic ( )
inlinestatic

◆ GetStepThroughTrampolinePlan()

ThreadPlanSP DynamicLoaderDarwinKernel::GetStepThroughTrampolinePlan ( lldb_private::Thread thread,
bool  stop_others 
)
overridevirtual

Provides a plan to step through the dynamic loader trampoline for the current state of thread.

Parameters
[in]stop_othersWhether the plan should be set to stop other threads.
Returns
A pointer to the plan (caller owned) or NULL if we are not at such a trampoline.

Implements lldb_private::DynamicLoader.

Definition at line 1598 of file DynamicLoaderDarwinKernel.cpp.

References lldb_private::GetLog(), and LLDB_LOGF.

◆ Initialize()

void DynamicLoaderDarwinKernel::Initialize ( )
static

◆ LoadKernelModuleIfNeeded()

void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded ( )
protected

Definition at line 1032 of file DynamicLoaderDarwinKernel.cpp.

References lldb_private::AddressableBits::AddressableBitToMask(), lldb_private::ConstString::AsCString(), DynamicLoaderDarwinKernel::KextImageInfo::Clear(), error(), lldb::eSymbolTypeData, lldb_private::Symbol::GetAddress(), lldb_private::ObjectFile::GetBaseAddress(), lldb_private::Process::GetCodeAddressMask(), lldb_private::Process::GetDataAddressMask(), lldb_private::Target::GetExecutableModule(), lldb_private::Address::GetFileAddress(), DynamicLoaderDarwinKernel::KextImageInfo::GetLoadAddress(), lldb_private::Address::GetLoadAddress(), DynamicLoaderDarwinKernel::KextImageInfo::GetModule(), lldb_private::Process::GetStopID(), lldb_private::Process::GetTarget(), is_kernel(), DynamicLoaderDarwinKernel::KextImageInfo::IsLoaded(), lldb_private::Address::IsValid(), LLDB_INVALID_ADDRESS, DynamicLoaderDarwinKernel::KextImageInfo::LoadImageAtFileAddress(), DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(), lldb_private::DynamicLoader::LoadOperatingSystemPlugin(), m_kernel, m_kernel_load_address, m_kext_summary_header_ptr_addr, lldb_private::DynamicLoader::m_process, ReadAllKextSummaries(), lldb_private::Target::ReadUnsignedIntegerFromMemory(), lldb_private::Process::SetCodeAddressMask(), lldb_private::Process::SetDataAddressMask(), DynamicLoaderDarwinKernel::KextImageInfo::SetIsKernel(), DynamicLoaderDarwinKernel::KextImageInfo::SetLoadAddress(), DynamicLoaderDarwinKernel::KextImageInfo::SetModule(), DynamicLoaderDarwinKernel::KextImageInfo::SetName(), and DynamicLoaderDarwinKernel::KextImageInfo::SetProcessStopId().

Referenced by UpdateIfNeeded().

◆ operator=()

const DynamicLoaderDarwinKernel & DynamicLoaderDarwinKernel::operator= ( const DynamicLoaderDarwinKernel )
privatedelete

◆ ParseKextSummaries()

bool DynamicLoaderDarwinKernel::ParseKextSummaries ( const lldb_private::Address kext_summary_addr,
uint32_t  count 
)
protected

◆ PrivateInitialize()

void DynamicLoaderDarwinKernel::PrivateInitialize ( lldb_private::Process process)
protected

◆ PrivateProcessStateChanged()

void DynamicLoaderDarwinKernel::PrivateProcessStateChanged ( lldb_private::Process process,
lldb::StateType  state 
)
protected

◆ PutToLog()

void DynamicLoaderDarwinKernel::PutToLog ( lldb_private::Log log) const
protected

◆ ReadAllKextSummaries()

bool DynamicLoaderDarwinKernel::ReadAllKextSummaries ( )
protected

◆ ReadKextSummaries()

uint32_t DynamicLoaderDarwinKernel::ReadKextSummaries ( const lldb_private::Address kext_summary_addr,
uint32_t  image_infos_count,
KextImageInfo::collection image_infos 
)
protected

◆ ReadKextSummaryHeader()

bool DynamicLoaderDarwinKernel::ReadKextSummaryHeader ( )
protected

◆ ReadMachHeader()

bool DynamicLoaderDarwinKernel::ReadMachHeader ( lldb::addr_t  addr,
lldb_private::Process process,
llvm::MachO::mach_header &  mh,
bool *  read_error = nullptr 
)
staticprotected

◆ RegisterNotificationCallbacks()

void DynamicLoaderDarwinKernel::RegisterNotificationCallbacks ( )
protected

◆ SearchForDarwinKernel()

lldb::addr_t DynamicLoaderDarwinKernel::SearchForDarwinKernel ( lldb_private::Process process)
static

◆ SearchForKernelAtSameLoadAddr()

lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr ( lldb_private::Process process)
staticprotected

◆ SearchForKernelNearPC()

lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelNearPC ( lldb_private::Process process)
staticprotected

◆ SearchForKernelViaExhaustiveSearch()

lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch ( lldb_private::Process process)
staticprotected

◆ SearchForKernelWithDebugHints()

lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints ( lldb_private::Process process)
staticprotected

◆ SetNotificationBreakpointIfNeeded()

void DynamicLoaderDarwinKernel::SetNotificationBreakpointIfNeeded ( )
protected

◆ Terminate()

void DynamicLoaderDarwinKernel::Terminate ( )
static

◆ UnregisterNotificationCallbacks()

void DynamicLoaderDarwinKernel::UnregisterNotificationCallbacks ( )
protected

◆ UpdateIfNeeded()

void DynamicLoaderDarwinKernel::UpdateIfNeeded ( )
protected

◆ UpdateImageInfosHeaderAndLoadCommands()

void DynamicLoaderDarwinKernel::UpdateImageInfosHeaderAndLoadCommands ( KextImageInfo::collection image_infos,
uint32_t  infos_count,
bool  update_executable 
)
protected

Member Data Documentation

◆ m_break_id

lldb::user_id_t DynamicLoaderDarwinKernel::m_break_id
protected

Definition at line 292 of file DynamicLoaderDarwinKernel.h.

Referenced by Clear(), and SetNotificationBreakpointIfNeeded().

◆ m_kernel

KextImageInfo DynamicLoaderDarwinKernel::m_kernel
protected

◆ m_kernel_load_address

lldb::addr_t DynamicLoaderDarwinKernel::m_kernel_load_address
protected

Definition at line 284 of file DynamicLoaderDarwinKernel.h.

Referenced by LoadKernelModuleIfNeeded().

◆ m_kext_summary_header

OSKextLoadedKextSummaryHeader DynamicLoaderDarwinKernel::m_kext_summary_header
protected

◆ m_kext_summary_header_addr

lldb_private::Address DynamicLoaderDarwinKernel::m_kext_summary_header_addr
protected

◆ m_kext_summary_header_ptr_addr

lldb_private::Address DynamicLoaderDarwinKernel::m_kext_summary_header_ptr_addr
protected

◆ m_known_kexts

KextImageInfo::collection DynamicLoaderDarwinKernel::m_known_kexts
protected

◆ m_mutex

std::recursive_mutex DynamicLoaderDarwinKernel::m_mutex
mutableprotected

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