class DwarfBinary
Defined at line 42 of file ../../src/developer/debug/zxdb/symbols/dwarf_binary.h
Represents the low-level DWARF file. It provides a mockable wrapper around a llvm::DWARFContext.
Unlike LLVM, a DwarfBinary represents one DWARF file on disk. In the case of Debug Fission
(--gsplit-dwarf mode where each compilation unit has its own symbols in a .dwo file), there will
be a separate DwarfBinary for each .dwo file as well as the main binary. These are linked
together by ModuleSymbols which represents the symbols for a .so or executable file.
In LLVM there will be one llvm::DWARFContext that covers everything but their support for Debug
Fission is not complete enough for our use case so we roll our own.
This is currently a very leaky abstraction because a lot of code was written before it was
created and that coded uses llvm objects directly. As a result, this has some accessors for
the underlying LLVM objects. Mocks may return null for these. If a new test needs to be written
for such code, wrappers should be added so that the code no longer needs the llvm objects and
can use the mockable wrappers.
Public Methods
std::string GetName ()
Getters for basic binary information.
std::string GetBuildID ()
std::time_t GetModificationTime ()
const DwarfSymbolFactory * GetSymbolFactory ()
bool HasBinary ()
Return whether this module has been given the opportunity to include symbols from the binary
itself, such as PLT entries.
llvm::object::ObjectFile * GetLLVMObjectFile ()
Returns underlying LLVM objects. May be null in tests since the mock won't have this. See the
class comment above.
llvm::DWARFContext * GetLLVMContext ()
uint64_t GetMappedLength ()
Returns the extent of the mapped segments in memory.
const std::map<std::string, llvm::ELF::Elf64_Sym> & GetELFSymbols ()
Returns symbols from the ELF File.
const std::map<std::string, uint64_t> GetPLTSymbols ()
uint32_t GetNormalUnitCount ()
Allows access to compile units in this binary. There are two categories, the "normal" units in
.debug_info and the DWO units in .debug_info.dwo. Normally there are only one or the other,
but this isn't guaranteed.
uint32_t GetDWOUnitCount ()
fxl::RefPtr<DwarfUnit> GetUnitAtIndex (UnitIndex i)
void ~DwarfBinary ()
Defined at line 44 of file ../../src/developer/debug/zxdb/symbols/dwarf_binary.h
fxl::RefPtr<DwarfUnit> UnitForAddress (const SymbolContext & symbol_context, TargetPointer absolute_address)
Returns the DwarfUnit covering the given absolute address location. Can be null if there's
no unit that covers this area.
Defined at line 78 of file ../../src/developer/debug/zxdb/symbols/dwarf_binary.h
fxl::RefPtr<DwarfUnit> UnitForRelativeAddress (uint64_t relative_address)
Like UnitForAddress but takes an address relative to the load address of the binary.
std::optional<uint64_t> GetDebugAddrEntry (uint64_t addr_base, uint64_t index)
Returns the 64-bit value from the .debug_addr section.
The addr_base is an attribute on the compilation unit. This is the byte offset of the address
table in the .debug_addr section of that compilation unit's address table.
The index is the address index within that compilation unit's table. This is an index into the
table (of address-sized entries) rather than a byte index.
fxl::RefPtr<DwarfUnit> GetDwoUnit ()
Returns the main unit in a .dwo file. When using DWARF "debug fission" the main binary will
have "skeleton units" that reference .dwo files containing the real unit information. These
files will normally have exactly one unit in them. This getter returns that unit.
It's theoretically possible for a .dwo file to have more than one unit. If that happens, it
would be possible to disambiguate them by name. Currently this does not happen so this just
returns the first DWO unit.
Defined at line 102 of file ../../src/developer/debug/zxdb/symbols/dwarf_binary.h
llvm::DWARFDie GetLLVMDieAtOffset (uint64_t offset)
Looks up a DIE by offset. This DIE can be in any unit.
void ClearLLVMCache ()