|
LLDB mainline
|
"lldb/Expression/IRExecutionUnit.h" Contains the IR and, optionally, JIT- compiled code for a module. More...
#include <IRExecutionUnit.h>
Classes | |
| struct | AllocationRecord |
| Encapsulates a single allocation request made by the JIT. More... | |
| struct | JittedEntity |
| class | JittedFunction |
| "lldb/Expression/IRExecutionUnit.h" Encapsulates a single function that has been generated by the JIT. More... | |
| struct | JittedGlobalVariable |
| class | MemoryManager |
Public Member Functions | |
| IRExecutionUnit (std::unique_ptr< llvm::LLVMContext > &context_up, std::unique_ptr< llvm::Module > &module_up, ConstString &name, const lldb::TargetSP &target_sp, const SymbolContext &sym_ctx, std::vector< std::string > &cpu_features) | |
| Constructor. | |
| ~IRExecutionUnit () override | |
| Destructor. | |
| ConstString | GetFunctionName () |
| llvm::Module * | GetModule () |
| llvm::Function * | GetFunction () |
| void | GetRunnableInfo (Status &error, lldb::addr_t &func_addr, lldb::addr_t &func_end) |
| lldb::ByteOrder | GetByteOrder () const override |
| ObjectFileJITDelegate overrides. | |
| uint32_t | GetAddressByteSize () const override |
| void | PopulateSymtab (lldb_private::ObjectFile *obj_file, lldb_private::Symtab &symtab) override |
| void | PopulateSectionList (lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list) override |
| ArchSpec | GetArchitecture () override |
| lldb::TargetSP | GetTargetSP () override |
| Returns the Target this JIT-compiled code was produced for, or null if the delegate that created this ObjectFile no longer exists. | |
| lldb::ModuleSP | GetJITModule () |
| lldb::addr_t | FindSymbol (ConstString name, bool &missing_weak) |
| void | GetStaticInitializers (std::vector< lldb::addr_t > &static_initializers) |
| const std::vector< JittedFunction > & | GetJittedFunctions () |
| const std::vector< JittedGlobalVariable > & | GetJittedGlobalVariables () |
| void | AppendPreferredSymbolContexts (SymbolContextList const &contexts) |
| Public Member Functions inherited from lldb_private::IRMemoryMap | |
| IRMemoryMap (lldb::TargetSP target_sp) | |
| ~IRMemoryMap () | |
| llvm::Expected< lldb::addr_t > | Malloc (size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, bool zero_memory, AllocationPolicy *used_policy=nullptr) |
| void | Leak (lldb::addr_t process_address, Status &error) |
| void | Free (lldb::addr_t process_address, Status &error) |
| void | WriteMemory (lldb::addr_t process_address, const uint8_t *bytes, size_t size, Status &error) |
| void | WriteScalarToMemory (lldb::addr_t process_address, Scalar &scalar, size_t size, Status &error) |
| void | WritePointerToMemory (lldb::addr_t process_address, lldb::addr_t pointer, Status &error) |
| void | ReadMemory (uint8_t *bytes, lldb::addr_t process_address, size_t size, Status &error) |
| void | ReadScalarFromMemory (Scalar &scalar, lldb::addr_t process_address, size_t size, Status &error) |
| void | ReadPointerFromMemory (lldb::addr_t *address, lldb::addr_t process_address, Status &error) |
| bool | GetAllocSize (lldb::addr_t address, size_t &size) |
| void | GetMemoryData (DataExtractor &extractor, lldb::addr_t process_address, size_t size, Status &error) |
| lldb::ByteOrder | GetByteOrder () |
| uint32_t | GetAddressByteSize () |
| ExecutionContextScope * | GetBestExecutionContextScope () const |
| lldb::TargetSP | GetTarget () |
| Public Member Functions inherited from lldb_private::ObjectFileJITDelegate | |
| ObjectFileJITDelegate ()=default | |
| virtual | ~ObjectFileJITDelegate ()=default |
Private Types | |
| enum class | AllocationKind { Stub , Code , Data , Global , Bytes } |
| typedef std::pair< lldb::addr_t, uintptr_t > | AddrRange |
| typedef std::vector< AllocationRecord > | RecordVector |
Private Member Functions | |
| lldb::addr_t | GetRemoteAddressForLocal (lldb::addr_t local_address) |
| Look up the object in m_address_map that contains a given address, find where it was copied to, and return the remote address at the same offset into the copied entity. | |
| AddrRange | GetRemoteRangeForLocal (lldb::addr_t local_address) |
| Look up the object in m_address_map that contains a given address, find where it was copied to, and return its address range in the target process. | |
| bool | CommitAllocations (lldb::ProcessSP &process_sp) |
| Commit all allocations to the process and record where they were stored. | |
| void | ReportAllocations (llvm::ExecutionEngine &engine) |
| Report all committed allocations to the execution engine. | |
| bool | WriteData (lldb::ProcessSP &process_sp) |
| Write the contents of all allocations to the process. | |
| Status | DisassembleFunction (Stream &stream, lldb::ProcessSP &process_sp) |
| void | ReportSymbolLookupError (ConstString name) |
| bool | CommitOneAllocation (lldb::ProcessSP &process_sp, Status &error, AllocationRecord &record) |
Static Private Member Functions | |
| static lldb::SectionType | GetSectionTypeFromSectionName (const llvm::StringRef &name, AllocationKind alloc_kind) |
Private Attributes | |
| RecordVector | m_records |
| std::unique_ptr< llvm::LLVMContext > | m_context_up |
| std::unique_ptr< llvm::ExecutionEngine > | m_execution_engine_up |
| std::unique_ptr< llvm::ObjectCache > | m_object_cache_up |
| std::unique_ptr< llvm::Module > | m_module_up |
| Holder for the module until it's been handed off. | |
| llvm::Module * | m_module |
| Owned by the execution engine. | |
| std::vector< std::string > | m_cpu_features |
| std::vector< JittedFunction > | m_jitted_functions |
| A vector of all functions that have been JITted into machine code. | |
| std::vector< JittedGlobalVariable > | m_jitted_global_variables |
| A vector of all functions that have been JITted into machine code. | |
| const ConstString | m_name |
| ExternalSymbolResolver | m_external_symbol_resolver |
| std::vector< ConstString > | m_failed_lookups |
| std::atomic< bool > | m_did_jit |
| lldb::addr_t | m_function_load_addr |
| lldb::addr_t | m_function_end_load_addr |
| bool | m_reported_allocations |
| True after allocations have been reported. | |
Static Private Attributes | |
| static const unsigned | eSectionIDInvalid = (unsigned)-1 |
Additional Inherited Members | |
| Public Types inherited from lldb_private::IRMemoryMap | |
| enum | AllocationPolicy : uint8_t { eAllocationPolicyInvalid , eAllocationPolicyHostOnly , eAllocationPolicyMirror , eAllocationPolicyProcessOnly } |
| Protected Member Functions inherited from lldb_private::IRMemoryMap | |
| lldb::ProcessWP & | GetProcessWP () |
"lldb/Expression/IRExecutionUnit.h" Contains the IR and, optionally, JIT- compiled code for a module.
This class encapsulates the compiled version of an expression, in IR form (for interpretation purposes) and in raw machine code form (for execution in the target).
This object wraps an IR module that comes from the expression parser, and knows how to use the JIT to make it into executable code. It can then be used as input to the IR interpreter, or the address of the executable code can be passed to a thread plan to run in the target.
This class creates a subclass of LLVM's SectionMemoryManager, because that is how the JIT emits code. Because LLDB needs to move JIT-compiled code into the target process, the IRExecutionUnit knows how to copy the emitted code into the target process.
Definition at line 57 of file IRExecutionUnit.h.
|
private |
Definition at line 177 of file IRExecutionUnit.h.
|
private |
Definition at line 347 of file IRExecutionUnit.h.
|
strongprivate |
| Enumerator | |
|---|---|
| Stub | |
| Code | |
| Data | |
| Global | |
| Bytes | |
Definition at line 311 of file IRExecutionUnit.h.
| IRExecutionUnit::IRExecutionUnit | ( | std::unique_ptr< llvm::LLVMContext > & | context_up, |
| std::unique_ptr< llvm::Module > & | module_up, | ||
| ConstString & | name, | ||
| const lldb::TargetSP & | target_sp, | ||
| const SymbolContext & | sym_ctx, | ||
| std::vector< std::string > & | cpu_features ) |
Constructor.
Definition at line 41 of file IRExecutionUnit.cpp.
References lldb_private::IRMemoryMap::IRMemoryMap(), LLDB_INVALID_ADDRESS, m_context_up, m_cpu_features, m_did_jit, m_external_symbol_resolver, m_function_end_load_addr, m_function_load_addr, m_module, m_module_up, m_name, and m_reported_allocations.
Referenced by lldb_private::IRExecutionUnit::MemoryManager::MemoryManager().
|
override |
Destructor.
Definition at line 454 of file IRExecutionUnit.cpp.
References m_context_up, m_execution_engine_up, and m_module_up.
|
inline |
Definition at line 161 of file IRExecutionUnit.h.
References m_external_symbol_resolver.
|
private |
Commit all allocations to the process and record where they were stored.
| [in] | process_sp | The process to allocate memory in. |
Definition at line 748 of file IRExecutionUnit.cpp.
References CommitOneAllocation(), lldb_private::IRMemoryMap::Free(), LLDB_INVALID_ADDRESS, and m_records.
Referenced by GetRunnableInfo().
|
private |
Definition at line 703 of file IRExecutionUnit.cpp.
References lldb_private::IRMemoryMap::eAllocationPolicyProcessOnly, error(), lldb::eSectionTypeDWARFAppleNames, lldb::eSectionTypeDWARFAppleNamespaces, lldb::eSectionTypeDWARFAppleObjC, lldb::eSectionTypeDWARFAppleTypes, lldb::eSectionTypeDWARFDebugAbbrev, lldb::eSectionTypeDWARFDebugAddr, lldb::eSectionTypeDWARFDebugAranges, lldb::eSectionTypeDWARFDebugCuIndex, lldb::eSectionTypeDWARFDebugFrame, lldb::eSectionTypeDWARFDebugInfo, lldb::eSectionTypeDWARFDebugLine, lldb::eSectionTypeDWARFDebugLoc, lldb::eSectionTypeDWARFDebugLocLists, lldb::eSectionTypeDWARFDebugMacInfo, lldb::eSectionTypeDWARFDebugPubNames, lldb::eSectionTypeDWARFDebugPubTypes, lldb::eSectionTypeDWARFDebugRanges, lldb::eSectionTypeDWARFDebugStr, lldb::eSectionTypeDWARFDebugStrOffsets, lldb::eSectionTypeDWARFGNUDebugAltLink, lldb::eSectionTypeInvalid, lldb_private::Status::FromError(), LLDB_INVALID_ADDRESS, lldb_private::IRExecutionUnit::AllocationRecord::m_alignment, lldb_private::IRExecutionUnit::AllocationRecord::m_permissions, lldb_private::IRExecutionUnit::AllocationRecord::m_process_address, lldb_private::IRExecutionUnit::AllocationRecord::m_sect_type, lldb_private::IRExecutionUnit::AllocationRecord::m_size, and lldb_private::IRMemoryMap::Malloc().
Referenced by CommitAllocations().
|
private |
Definition at line 58 of file IRExecutionUnit.cpp.
References lldb_private::Status::AsCString(), lldb_private::Status::Clear(), lldb_private::InstructionList::Dump(), lldb_private::Expressions, lldb_private::Disassembler::FindPlugin(), lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), lldb_private::Status::FromErrorStringWithFormatv(), lldb_private::ArchSpec::GetAddressByteSize(), lldb_private::Target::GetArchitecture(), lldb_private::ArchSpec::GetArchitectureName(), lldb_private::Process::GetByteOrder(), lldb_private::DataExtractor::GetByteSize(), lldb_private::GetLog(), lldb_private::ExecutionContext::GetProcessPtr(), GetRemoteRangeForLocal(), lldb_private::ExecutionContext::GetTargetPtr(), LLDB_INVALID_ADDRESS, LLDB_LOGF, m_jitted_functions, m_name, lldb_private::DataExtractor::PutToLog(), lldb_private::Process::ReadMemory(), lldb_private::Status::Success(), lldb_private::DataExtractor::TypeUInt8, and UINT32_MAX.
Referenced by GetRunnableInfo().
|
inline |
Definition at line 99 of file IRExecutionUnit.h.
References m_external_symbol_resolver.
|
overridevirtual |
Implements lldb_private::ObjectFileJITDelegate.
Definition at line 821 of file IRExecutionUnit.cpp.
References lldb_private::ExecutionContext::GetAddressByteSize(), and lldb_private::IRMemoryMap::GetBestExecutionContextScope().
|
overridevirtual |
Implements lldb_private::ObjectFileJITDelegate.
Definition at line 849 of file IRExecutionUnit.cpp.
References lldb_private::IRMemoryMap::GetBestExecutionContextScope(), and lldb_private::ExecutionContext::GetTargetPtr().
|
overridevirtual |
ObjectFileJITDelegate overrides.
Implements lldb_private::ObjectFileJITDelegate.
Definition at line 816 of file IRExecutionUnit.cpp.
References lldb_private::IRMemoryMap::GetBestExecutionContextScope(), and lldb_private::ExecutionContext::GetByteOrder().
|
inline |
Definition at line 74 of file IRExecutionUnit.h.
|
inline |
Definition at line 70 of file IRExecutionUnit.h.
References m_name.
| lldb::ModuleSP IRExecutionUnit::GetJITModule | ( | ) |
Definition at line 856 of file IRExecutionUnit.cpp.
References lldb_private::Module::CreateModuleFromObjectFile(), lldb_private::IRMemoryMap::GetBestExecutionContextScope(), and lldb_private::ExecutionContext::GetTargetPtr().
|
inline |
Definition at line 153 of file IRExecutionUnit.h.
References m_jitted_functions.
|
inline |
Definition at line 157 of file IRExecutionUnit.h.
References m_jitted_global_variables.
|
inline |
Definition at line 72 of file IRExecutionUnit.h.
References m_module.
|
private |
Look up the object in m_address_map that contains a given address, find where it was copied to, and return the remote address at the same offset into the copied entity.
| [in] | local_address | The address in the debugger. |
Definition at line 660 of file IRExecutionUnit.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), LLDB_INVALID_ADDRESS, LLDB_LOGF, and m_records.
Referenced by GetRunnableInfo().
|
private |
Look up the object in m_address_map that contains a given address, find where it was copied to, and return its address range in the target process.
| [in] | local_address | The address in the debugger. |
Definition at line 689 of file IRExecutionUnit.cpp.
References LLDB_INVALID_ADDRESS, and m_records.
Referenced by DisassembleFunction(), and GetRunnableInfo().
| void IRExecutionUnit::GetRunnableInfo | ( | Status & | error, |
| lldb::addr_t & | func_addr, | ||
| lldb::addr_t & | func_end ) |
Definition at line 185 of file IRExecutionUnit.cpp.
References lldb_private::Status::AsCString(), CommitAllocations(), lldb_private::FileSpec::CopyByAppendingPathComponent(), DisassembleFunction(), lldb::eByteOrderBig, error(), lldb_private::Expressions, lldb_private::Status::FromErrorString(), lldb_private::Status::FromErrorStringWithFormat(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::DataBufferHeap::GetByteSize(), lldb_private::StreamString::GetData(), lldb_private::GetLog(), lldb_private::FileSpec::GetPath(), lldb_private::IRMemoryMap::GetProcessWP(), GetRemoteAddressForLocal(), GetRemoteRangeForLocal(), lldb_private::StreamString::GetString(), LLDB_INVALID_ADDRESS, LLDB_LOGF, m_cpu_features, m_did_jit, m_execution_engine_up, m_failed_lookups, m_function_end_load_addr, m_function_load_addr, m_jitted_functions, m_jitted_global_variables, m_module, m_module_up, m_name, m_object_cache_up, m_records, lldb_private::Stream::PutCString(), lldb_private::DataExtractor::PutToLog(), lldb_private::IRMemoryMap::ReadMemory(), ReportAllocations(), lldb_private::Status, lldb_private::Status::Success(), lldb_private::DataExtractor::TypeUInt8, and WriteData().
|
staticprivate |
Definition at line 465 of file IRExecutionUnit.cpp.
References Bytes, Code, Data, lldb::eSectionTypeCode, lldb::eSectionTypeData, lldb::eSectionTypeInvalid, lldb::eSectionTypeOther, lldb_private::ObjectFile::GetDWARFSectionTypeFromName(), Global, and Stub.
Referenced by lldb_private::IRExecutionUnit::MemoryManager::allocateCodeSection(), and lldb_private::IRExecutionUnit::MemoryManager::allocateDataSection().
| void IRExecutionUnit::GetStaticInitializers | ( | std::vector< lldb::addr_t > & | static_initializers | ) |
Definition at line 564 of file IRExecutionUnit.cpp.
References lldb_private::Expressions, lldb_private::GetLog(), LLDB_INVALID_ADDRESS, LLDB_LOG, lldbassert, m_jitted_functions, and m_module.
|
inlineoverridevirtual |
Returns the Target this JIT-compiled code was produced for, or null if the delegate that created this ObjectFile no longer exists.
Implements lldb_private::ObjectFileJITDelegate.
Definition at line 95 of file IRExecutionUnit.h.
References lldb_private::IRMemoryMap::GetTarget().
|
overridevirtual |
Implements lldb_private::ObjectFileJITDelegate.
Definition at line 831 of file IRExecutionUnit.cpp.
References lldb_private::SectionList::AddSection(), lldb_private::ModuleChild::GetModule(), and m_records.
|
overridevirtual |
Implements lldb_private::ObjectFileJITDelegate.
Definition at line 826 of file IRExecutionUnit.cpp.
|
private |
Report all committed allocations to the execution engine.
| [in] | engine | The execution engine to notify. |
Definition at line 773 of file IRExecutionUnit.cpp.
References eSectionIDInvalid, LLDB_INVALID_ADDRESS, m_records, and m_reported_allocations.
Referenced by GetRunnableInfo().
|
private |
Definition at line 181 of file IRExecutionUnit.cpp.
References m_failed_lookups.
|
private |
Write the contents of all allocations to the process.
| [in] | process_sp | The process containing the allocations. |
Definition at line 791 of file IRExecutionUnit.cpp.
References LLDB_INVALID_ADDRESS, m_records, lldb_private::Status::Success(), and lldb_private::IRMemoryMap::WriteMemory().
Referenced by GetRunnableInfo().
|
staticprivate |
Definition at line 309 of file IRExecutionUnit.h.
Referenced by ReportAllocations().
|
private |
Definition at line 350 of file IRExecutionUnit.h.
Referenced by IRExecutionUnit(), and ~IRExecutionUnit().
|
private |
Definition at line 356 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), and IRExecutionUnit().
|
private |
Definition at line 369 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), and IRExecutionUnit().
|
private |
Definition at line 351 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), and ~IRExecutionUnit().
|
private |
Definition at line 366 of file IRExecutionUnit.h.
Referenced by AppendPreferredSymbolContexts(), FindSymbol(), and IRExecutionUnit().
|
private |
Definition at line 367 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), and ReportSymbolLookupError().
|
private |
Definition at line 372 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), and IRExecutionUnit().
|
private |
Definition at line 371 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), and IRExecutionUnit().
|
private |
A vector of all functions that have been JITted into machine code.
Definition at line 357 of file IRExecutionUnit.h.
Referenced by DisassembleFunction(), GetJittedFunctions(), GetRunnableInfo(), and GetStaticInitializers().
|
private |
A vector of all functions that have been JITted into machine code.
Definition at line 360 of file IRExecutionUnit.h.
Referenced by GetJittedGlobalVariables(), and GetRunnableInfo().
|
private |
Owned by the execution engine.
Definition at line 355 of file IRExecutionUnit.h.
Referenced by GetFunction(), GetModule(), GetRunnableInfo(), GetStaticInitializers(), and IRExecutionUnit().
|
private |
Holder for the module until it's been handed off.
Definition at line 354 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo(), IRExecutionUnit(), and ~IRExecutionUnit().
|
private |
Definition at line 365 of file IRExecutionUnit.h.
Referenced by DisassembleFunction(), GetFunction(), GetFunctionName(), GetRunnableInfo(), and IRExecutionUnit().
|
private |
Definition at line 352 of file IRExecutionUnit.h.
Referenced by GetRunnableInfo().
|
private |
Definition at line 348 of file IRExecutionUnit.h.
Referenced by CommitAllocations(), GetRemoteAddressForLocal(), GetRemoteRangeForLocal(), GetRunnableInfo(), PopulateSectionList(), ReportAllocations(), and WriteData().
|
private |
True after allocations have been reported.
It is possible that sections will be allocated when this is true, in which case they weren't depended on by any function. (Top-level code defining a variable, but defining no functions using that variable, would do this.) If this is true, any allocations need to be committed immediately – no opportunity for relocation.
Definition at line 374 of file IRExecutionUnit.h.
Referenced by IRExecutionUnit(), and ReportAllocations().