Go to the documentation of this file.
9 #ifndef LLDB_SYMBOL_OBJECTFILE_H
10 #define LLDB_SYMBOL_OBJECTFILE_H
22 #include "llvm/Support/Threading.h"
23 #include "llvm/Support/VersionTuple.h"
60 class ObjectFile :
public std::enable_shared_from_this<ObjectFile>,
121 ObjectFile(
const lldb::ModuleSP &module_sp,
const lldb::ProcessSP &process_sp,
163 static lldb::ObjectFileSP
183 static lldb::ObjectFileSP
FindPlugin(
const lldb::ModuleSP &module_sp,
184 const lldb::ProcessSP &process_sp,
186 lldb::WritableDataBufferSP file_data_sp);
191 lldb::DataBufferSP data_sp = lldb::DataBufferSP());
194 lldb::DataBufferSP &data_sp,
228 virtual bool isA(
const void *ClassID)
const {
return ClassID == &
ID; }
364 bool verify_unique) {
408 return FileSpecList();
417 bool value_is_offset) {
551 bool &value_is_offset,
UUID &uuid,
554 value_is_offset =
false;
559 virtual lldb::RegisterContextSP
561 return lldb::RegisterContextSP();
604 virtual llvm::VersionTuple
GetVersion() {
return llvm::VersionTuple(); }
616 return llvm::VersionTuple();
652 static lldb::DataBufferSP
ReadMemory(
const lldb::ProcessSP &process_sp,
680 virtual llvm::StringRef
690 llvm::StringRef name,
783 raw_ostream &OS, StringRef Style);
788 raw_ostream &OS, StringRef Style);
792 #endif // LLDB_SYMBOL_OBJECTFILE_H
static lldb::SymbolType GetSymbolTypeFromName(llvm::StringRef name, lldb::SymbolType symbol_type_hint=lldb::eSymbolTypeUndefined)
static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset)
virtual bool isA(const void *ClassID) const
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
virtual void CreateSections(SectionList &unified_section_list)=0
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
const lldb::addr_t m_memory_addr
Set if the object file only exists in memory.
virtual bool ParseHeader()=0
Attempts to parse the object header.
static size_t GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs, lldb::DataBufferSP data_sp=lldb::DataBufferSP())
@ eTypeExecutable
A normal executable.
lldb::ProcessWP m_process_wp
virtual void RelocateSection(lldb_private::Section *section)
Perform relocations on the section if necessary.
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset)
Find a ObjectFile plug-in that can parse file_spec.
virtual bool AllowAssemblyEmulationUnwindPlans()
Returns if the function bounds for symbols in this symbol file are likely accurate.
std::unique_ptr< lldb_private::Symtab > m_symtab_up
virtual bool IsExecutable() const =0
Tells whether this object file is capable of being the main executable for a process.
virtual AddressClass GetAddressClass(lldb::addr_t file_addr)
Get the address type given a file address in an object file.
const ObjectFile & operator=(const ObjectFile &)=delete
virtual size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
virtual llvm::VersionTuple GetSDKVersion()
Get the SDK OS version this object file was built with.
static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp, lldb::addr_t addr, size_t byte_size)
@ eTypeObjectFile
An intermediate object file.
virtual lldb::ByteOrder GetByteOrder() const =0
std::optional< uint32_t > m_cache_hash
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
virtual Strata CalculateStrata()=0
The object file should be able to calculate the strata of the object file.
virtual bool GetIsDynamicLinkEditor()
Return true if this file is a dynamic link editor (dyld)
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataBufferSP data_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
lldb::addr_t m_length
The length of this object file if it is known (can be zero if length is unknown or can't be determine...
llvm::ArrayRef< uint8_t > Contents
virtual const FileSpec & GetFileSpec() const
Get const accessor to the object file specification.
virtual llvm::StringRef StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
virtual lldb::RegisterContextSP GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread)
virtual lldb_private::Address GetBaseAddress()
Returns base address of this object file.
@ eTypeCoreFile
A core file that has a checkpoint of a program's execution state.
virtual UUID GetUUID()=0
Gets the UUID for this object file.
virtual std::string GetIdentifierString()
Some object files may have an identifier string embedded in them, e.g.
virtual Symbol * ResolveSymbolForAddress(const Address &so_addr, bool verify_unique)
Appends a Symbol for the specified so_addr to the symbol table.
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
@ eBinaryTypeStandalone
user process binary
virtual ArchSpec GetArchitecture()=0
@ eTypeSharedLibrary
A shared library that can be used during execution.
string(SUBSTRING ${p} 10 -1 pStripped) if($
virtual bool IsStripped()=0
Detect if this object file has been stripped of local symbols.
BinaryType
If we have a corefile binary hint, this enum specifies the binary type which we can use to select the...
virtual void Dump(Stream *s)=0
Dump a description of this object to a Stream.
~ObjectFile() override
Destructor.
@ eTypeJIT
JIT code that has symbols, sections and possibly debug info.
@ eBinaryTypeUser
kernel binary
virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list)=0
std::unique_ptr< llvm::once_flag > m_symtab_once_up
We need a llvm::once_flag that we can use to avoid locking the module lock and deadlocking LLDB.
virtual bool LoadCoreFileImages(lldb_private::Process &process)
Load binaries listed in a corefile.
size_t GetData(lldb::offset_t offset, size_t length, DataExtractor &data) const
static bool SplitArchivePathWithObject(llvm::StringRef path_with_object, lldb_private::FileSpec &archive_file, lldb_private::ConstString &archive_object, bool must_exist)
Split a path into a file path with object name.
@ eTypeDebugInfo
An object file that contains only debug information.
virtual llvm::VersionTuple GetMinimumOSVersion()
Get the minimum OS version this object file can run on.
ObjectFileJITDelegate()=default
static size_t g_initial_bytes_to_read
The number of bytes to read when going through the plugins.
virtual lldb::addr_t GetFileOffset() const
Returns the offset into a file at which this object resides.
virtual std::vector< LoadableData > GetLoadableData(Target &target)
Loads this objfile to memory.
virtual void SetType(Type type)
In cases where the type can't be calculated (elf files), this routine allows someone to explicitly se...
virtual bool CanTrustAddressRanges()
Can we trust the address ranges accelerator associated with this object file to be complete.
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
virtual void ParseSymtab(Symtab &symtab)=0
Parse the symbol table into the provides symbol table object.
virtual uint32_t GetNumThreadContexts()
virtual void ClearSymtab()
Frees the symbol table.
DataExtractor m_data
The data for this object file so things can be parsed lazily.
virtual bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset)
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
virtual uint32_t GetAddressByteSize() const =0
lldb::addr_t m_file_offset
The offset in bytes into the file, or the address in memory.
uint32_t GetCacheHash()
Get a hash that can be used for caching object file releated information.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
virtual lldb::addr_t GetByteSize() const
bool IsInMemory() const
Returns true if the object file exists only in memory.
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
virtual llvm::VersionTuple GetVersion()
Get the object file version numbers.
@ eTypeDynamicLinker
The platform's dynamic linker executable.
size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const
bool SetModulesArchitecture(const ArchSpec &new_arch)
Sets the architecture for a module.
virtual Type CalculateType()=0
The object file should be able to calculate its type by looking at its file header and possibly the s...
virtual bool GetCorefileMainBinaryInfo(lldb::addr_t &value, bool &value_is_offset, UUID &uuid, ObjectFile::BinaryType &type)
When the ObjectFile is a core file, lldb needs to locate the "binary" in the core file.
virtual void SectionFileAddressesChanged()
Notify the ObjectFile that the file addresses in the Sections for this module have been changed.
virtual std::unique_ptr< CallFrameInfo > CreateCallFrameInfo()
Creates a plugin-specific call frame info.
virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file, lldb_private::Symtab &symtab)=0
virtual uint32_t GetDependentModules(FileSpecList &file_list)=0
Extract the dependent modules from an object file.
virtual lldb_private::Address GetEntryPointAddress()
Returns the address of the Entry Point in this object file - if the object file doesn't have an entry...
virtual lldb_private::FileSpecList GetReExportedLibraries()
Gets the file spec list of libraries re-exported by this object file.
virtual ~ObjectFileJITDelegate()=default
std::unique_ptr< lldb_private::SectionList > m_sections_up
virtual lldb::addr_t GetAddressMask()
Some object files may have the number of bits used for addressing embedded in them,...
ByteOrder
Byte ordering definitions.