9#ifndef LLDB_SYMBOL_OBJECTFILE_H
10#define LLDB_SYMBOL_OBJECTFILE_H
22#include "llvm/Support/Threading.h"
23#include "llvm/Support/VersionTuple.h"
41class ObjectFile :
public std::enable_shared_from_this<ObjectFile>,
102 ObjectFile(
const lldb::ModuleSP &module_sp,
const lldb::ProcessSP &process_sp,
144 static lldb::ObjectFileSP
164 static lldb::ObjectFileSP
FindPlugin(
const lldb::ModuleSP &module_sp,
165 const lldb::ProcessSP &process_sp,
167 lldb::WritableDataBufferSP file_data_sp);
172 lldb::DataBufferSP data_sp = lldb::DataBufferSP());
175 lldb::DataBufferSP &data_sp,
209 virtual bool isA(
const void *ClassID)
const {
return ClassID == &
ID; }
345 bool verify_unique) {
398 bool value_is_offset) {
492 return std::string();
532 bool &value_is_offset,
UUID &uuid,
535 value_is_offset =
false;
540 virtual lldb::RegisterContextSP
542 return lldb::RegisterContextSP();
585 virtual llvm::VersionTuple
GetVersion() {
return llvm::VersionTuple(); }
597 return llvm::VersionTuple();
633 static lldb::DataBufferSP
ReadMemory(
const lldb::ProcessSP &process_sp,
661 virtual llvm::StringRef
671 llvm::StringRef name,
764 raw_ostream &OS, StringRef Style);
769 raw_ostream &OS, StringRef Style);
774 llvm::json::Path path);
A section + offset based address class.
An architecture specification class.
A uniqued constant string class.
A mix in class that contains a pointer back to the module that owns the object which inherits from it...
A class that describes an executable image and its associated object and symbol files.
A plug-in interface definition class for object file parsers.
virtual std::string GetIdentifierString()
Some object files may have an identifier string embedded in them, e.g.
ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, lldb::DataBufferSP data_sp)
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 const FileSpec & GetFileSpec() const
Get const accessor to the object file specification.
DataExtractor m_data
The data for this object file so things can be parsed lazily.
virtual void Dump(Stream *s)=0
Dump a description of this object to a Stream.
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
std::unique_ptr< lldb_private::SectionList > m_sections_up
const ObjectFile & operator=(const ObjectFile &)=delete
static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset)
virtual std::vector< LoadableData > GetLoadableData(Target &target)
Loads this objfile to memory.
virtual llvm::StringRef StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const
~ObjectFile() override
Destructor.
std::unique_ptr< lldb_private::Symtab > m_symtab_up
virtual uint32_t GetDependentModules(FileSpecList &file_list)=0
Extract the dependent modules from an object file.
const lldb::addr_t m_memory_addr
Set if the object file only exists in memory.
virtual bool IsStripped()=0
Detect if this object file has been stripped of local symbols.
virtual lldb::RegisterContextSP GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread)
virtual uint32_t GetNumThreadContexts()
static size_t g_initial_bytes_to_read
The number of bytes to read when going through the plugins.
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
virtual bool LoadCoreFileImages(lldb_private::Process &process)
Load binaries listed in a corefile.
virtual void ParseSymtab(Symtab &symtab)=0
Parse the symbol table into the provides symbol table object.
virtual AddressClass GetAddressClass(lldb::addr_t file_addr)
Get the address type given a file address in an object file.
virtual lldb::addr_t GetFileOffset() const
Returns the offset into a file at which this object resides.
static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp, lldb::addr_t addr, size_t byte_size)
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...
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.
size_t GetData(lldb::offset_t offset, size_t length, DataExtractor &data) const
virtual Strata CalculateStrata()=0
The object file should be able to calculate the strata of the object file.
@ eTypeExecutable
A normal executable.
@ eTypeDebugInfo
An object file that contains only debug information.
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
@ eTypeObjectFile
An intermediate object file.
@ eTypeDynamicLinker
The platform's dynamic linker executable.
@ eTypeCoreFile
A core file that has a checkpoint of a program's execution state.
@ eTypeSharedLibrary
A shared library that can be used during execution.
@ eTypeJIT
JIT code that has symbols, sections and possibly debug info.
virtual void SetType(Type type)
In cases where the type can't be calculated (elf files), this routine allows someone to explicitly se...
virtual Symbol * ResolveSymbolForAddress(const Address &so_addr, bool verify_unique)
Appends a Symbol for the specified so_addr to the symbol table.
lldb::addr_t m_file_offset
The offset in bytes into the file, or the address in memory.
static lldb::SymbolType GetSymbolTypeFromName(llvm::StringRef name, lldb::SymbolType symbol_type_hint=lldb::eSymbolTypeUndefined)
virtual bool IsExecutable() const =0
Tells whether this object file is capable of being the main executable for a process.
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, lldb::WritableDataBufferSP file_data_sp)
Find a ObjectFile plug-in that can parse a file in memory.
virtual std::unique_ptr< CallFrameInfo > CreateCallFrameInfo()
Creates a plugin-specific call frame info.
virtual void ClearSymtab()
Frees the symbol table.
bool SetModulesArchitecture(const ArchSpec &new_arch)
Sets the architecture for a module.
virtual llvm::VersionTuple GetMinimumOSVersion()
Get the minimum OS version this object file can run on.
virtual bool ParseHeader()=0
Attempts to parse the object header.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
virtual Type CalculateType()=0
The object file should be able to calculate its type by looking at its file header and possibly the s...
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())
ObjectFile(const ObjectFile &)=delete
virtual bool CanTrustAddressRanges()
Can we trust the address ranges accelerator associated with this object file to be complete.
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
virtual bool AllowAssemblyEmulationUnwindPlans()
Returns if the function bounds for symbols in this symbol file are likely accurate.
virtual llvm::VersionTuple GetVersion()
Get the object file version numbers.
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.
virtual void CreateSections(SectionList &unified_section_list)=0
virtual bool isA(const void *ClassID) const
size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const
virtual void SectionFileAddressesChanged()
Notify the ObjectFile that the file addresses in the Sections for this module have been changed.
virtual uint32_t GetAddressByteSize() const =0
Gets the address size in bytes for the current object file.
virtual void RelocateSection(lldb_private::Section *section)
Perform relocations on the section if necessary.
std::optional< uint32_t > m_cache_hash
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
virtual UUID GetUUID()=0
Gets the UUID for this object file.
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.
bool IsInMemory() const
Returns true if the object file exists only in memory.
lldb::ProcessWP m_process_wp
uint32_t GetCacheHash()
Get a hash that can be used for caching object file releated information.
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...
virtual lldb::addr_t GetAddressMask()
Some object files may have the number of bits used for addressing embedded in them,...
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 size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
BinaryType
If we have a corefile binary hint, this enum specifies the binary type which we can use to select the...
@ eBinaryTypeUser
kernel binary
@ eBinaryTypeStandalone
user process binary
virtual lldb_private::Address GetBaseAddress()
Returns base address of this object file.
virtual bool GetIsDynamicLinkEditor()
Return true if this file is a dynamic link editor (dyld)
virtual llvm::VersionTuple GetSDKVersion()
Get the SDK OS version this object file was built with.
virtual lldb::addr_t GetByteSize() const
virtual lldb_private::FileSpecList GetReExportedLibraries()
Gets the file spec list of libraries re-exported by this object file.
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
A plug-in interface definition class for debugging a process.
A stream class that can stream formatted output to a file.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
ByteOrder
Byte ordering definitions.
bool fromJSON(const llvm::json::Value &value, lldb_private::JSONSection §ion, llvm::json::Path path)
llvm::ArrayRef< uint8_t > Contents