Go to the documentation of this file.
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
32 class AppleAcceleratorTable;
33 class DWARFCompileUnit;
34 class DWARFDebugAbbrev;
35 class DWARFDebugAranges;
36 class DWARFDebugFrame;
38 class DWARFDebugMacro;
39 class DWARFDebugNames;
50 std::unique_ptr<DWARFUnitIndex> CUIndex;
51 std::unique_ptr<DWARFGdbIndex> GdbIndex;
52 std::unique_ptr<DWARFUnitIndex> TUIndex;
53 std::unique_ptr<DWARFDebugAbbrev> Abbrev;
54 std::unique_ptr<DWARFDebugLoc> Loc;
55 std::unique_ptr<DWARFDebugAranges> Aranges;
56 std::unique_ptr<DWARFDebugLine> Line;
57 std::unique_ptr<DWARFDebugFrame> DebugFrame;
58 std::unique_ptr<DWARFDebugFrame> EHFrame;
59 std::unique_ptr<DWARFDebugMacro> Macro;
60 std::unique_ptr<DWARFDebugMacro> Macinfo;
61 std::unique_ptr<DWARFDebugNames> Names;
62 std::unique_ptr<AppleAcceleratorTable> AppleNames;
63 std::unique_ptr<AppleAcceleratorTable> AppleTypes;
64 std::unique_ptr<AppleAcceleratorTable> AppleNamespaces;
65 std::unique_ptr<AppleAcceleratorTable> AppleObjC;
69 std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
70 std::unique_ptr<DWARFDebugMacro> MacinfoDWO;
71 std::unique_ptr<DWARFDebugMacro> MacroDWO;
74 unsigned MaxVersion = 0;
78 std::unique_ptr<DWARFContext>
Context;
81 std::weak_ptr<DWOFile> DWP;
82 bool CheckedForDWP =
false;
85 std::unique_ptr<MCRegisterInfo>
RegInfo;
94 void parseNormalUnits();
100 enum { EagerParse =
false, LazyParse =
true };
101 void parseDWOUnits(
bool Lazy =
false);
103 std::unique_ptr<const DWARFObject> DObj;
116 std::string DWPName =
"",
139 dump(OS, DumpOpts, DumpOffsets);
151 NormalUnits.begin() +
164 NormalUnits.begin() + NormalUnits.
getNumInfoUnits(), NormalUnits.end());
242 return NormalUnits[
index].get();
248 return DWOUnits[
index].get();
391 template <
typename... Ts>
393 std::error_code EC,
char const *Fmt,
399 Stream <<
format(Fmt, Vals...)
400 <<
" has unsupported address size: " << AddressSize
401 <<
" (supported are ";
404 Stream <<
LS << Size;
406 return make_error<StringError>(Stream.str(), EC);
414 return RecoverableErrorHandler;
421 static std::unique_ptr<DWARFContext>
430 static std::unique_ptr<DWARFContext>
459 std::unique_ptr<DWARFDebugMacro>
463 std::vector<DILocal> &Result);
468 #endif // LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
const DWARFDebugNames & getDebugNames()
Get a reference to the parsed accelerator table object.
const DWARFDebugLine::LineTable * getLineTableForUnit(DWARFUnit *U)
Get a pointer to a parsed line table corresponding to a compile unit.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override
This is an optimization pass for GlobalISel generic memory operations.
unit_iterator_range types_section_units()
Get units from .debug_types in this context.
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, ProcessDebugRelocations RelocAction=ProcessDebugRelocations::Process, const LoadedObjectInfo *L=nullptr, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler)
Expected< const DWARFDebugFrame * > getEHFrame()
Get a pointer to the parsed eh frame information object.
DWARFUnitVector::iterator_range unit_iterator_range
DWARFUnitVector::compile_unit_range compile_unit_range
A format-neutral container for inlined code description.
Controls which fields of DILineInfo container should be filled with data.
const AppleAcceleratorTable & getAppleNames()
Get a reference to the parsed accelerator table object.
A raw_ostream that writes to an std::string.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
unsigned getNumTypeUnits()
Get the number of type units in this context.
DWARFCompileUnit * getDWOCompileUnitForHash(uint64_t Hash)
static ErrorSuccess success()
Create a success value.
DILineInfoTable getLineInfoForAddressRange(object::SectionedAddress Address, uint64_t Size, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
virtual const object::ObjectFile * getFile() const
DataExtractor getStringExtractor() const
unit_iterator_range info_section_units()
Get units from .debug_info in this context.
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
static void defaultErrorHandler(Error Err)
Implement default handling for Error.
DILineInfo getLineInfoForDataAddress(object::SectionedAddress Address) override
virtual Triple::ArchType getArch() const =0
static SmallVector< uint8_t, 3 > getSupportedAddressSizes()
const DWARFDebugAbbrev * getDebugAbbrevDWO()
Get a pointer to the parsed dwo abbreviations object.
Tagged union holding either a T or a Error.
unit_iterator_range dwo_types_section_units()
Get units from .debug_types.dwo in the DWO context.
unsigned getNumTypesUnits() const
Returns number of units from all .debug_types[.dwo] sections.
std::vector< DILocal > getLocalsForAddress(object::SectionedAddress Address) override
const DWARFDebugMacro * getDebugMacroDWO()
Get a pointer to the parsed DebugMacroDWO information object.
static void defaultWarningHandler(Error Warning)
Implement default handling for Warning.
DIInliningInfo getInliningInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
const AppleAcceleratorTable & getAppleObjC()
Get a reference to the parsed accelerator table object.
const DWARFDebugMacro * getDebugMacinfo()
Get a pointer to the parsed DebugMacinfo information object.
const DWARFDebugAranges * getDebugAranges()
Get a pointer to the parsed DebugAranges object.
const DWARFUnitVector & getDWOUnitsVector()
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
unit_iterator_range dwo_info_section_units()
Get units from .debug_info..dwo in the DWO context.
const DWARFDebugMacro * getDebugMacinfoDWO()
Get a pointer to the parsed DebugMacinfoDWO information object.
unsigned getNumCompileUnits()
Get the number of compile units in this context.
Triple::ArchType getArch() const
static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)
This class implements an extremely fast bulk output stream that can only output to a stream.
DataExtractor getStringDWOExtractor() const
DWARFContext & operator=(DWARFContext &)=delete
compile_unit_range compile_units()
Get compile units in this context.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
unsigned getMaxDWOVersion()
const DWARFDebugMacro * getDebugMacro()
Get a pointer to the parsed DebugMacro information object.
unit_iterator_range dwo_units()
Get all units in the DWO context.
bool verify(raw_ostream &OS, DIDumpOptions DumpOpts={}) override
An efficient, type-erasing, non-owning reference to a callable.
const DWARFUnitVector & getNormalUnitsVector()
DWARFTypeUnit * getTypeUnitForHash(uint16_t Version, uint64_t Hash, bool IsDWO)
unsigned getNumDWOTypeUnits()
Get the number of type units in the DWO context.
const DWARFDebugAbbrev * getDebugAbbrev()
Get a pointer to the parsed DebugAbbrev object.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
void clearLineTableForUnit(DWARFUnit *U)
uint8_t getCUAddrSize()
Get address size from CUs.
compile_unit_range dwo_compile_units()
Get compile units in the DWO context.
A format-neutral container for source line information.
function_ref< void(Error)> getWarningHandler()
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
static bool isAddressSizeSupported(unsigned AddressSize)
DWARFUnit * getUnitAtIndex(unsigned index)
Get the unit at the specified index.
print Print MemDeps of function
const DWARFUnitIndex & getTUIndex()
DIEsForAddress getDIEsForAddress(uint64_t Address)
Get the compilation unit, the function DIE and lexical block DIE for the given address where applicab...
DWARFGdbIndex & getGdbIndex()
std::shared_ptr< DWARFContext > getDWOContext(StringRef AbsolutePath)
Expected< const DWARFDebugFrame * > getDebugFrame()
Get a pointer to the parsed frame information object.
bool isLittleEndian() const
const DWARFDebugLoc * getDebugLoc()
Get a pointer to the parsed DebugLoc object.
StringRef - Represent a constant reference to a string, i.e.
This class is the base class for all object file types.
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
unit_iterator_range normal_units()
Get all normal compile/type units in this context.
DataExtractor getLineStringExtractor() const
This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
unsigned getNumDWOCompileUnits()
Get the number of compile units in the DWO context.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
DWARFDie getDIEForOffset(uint64_t Offset)
Get a DIE given an exact offset.
const DWARFUnitIndex & getCUIndex()
DILineInfo getLineInfoForAddress(object::SectionedAddress Address, DILineInfoSpecifier Specifier=DILineInfoSpecifier()) override
void setMaxVersionIfGreater(unsigned Version)
DWARFUnit * getDWOUnitAtIndex(unsigned index)
Get the unit at the specified index for the DWO units.
const MCRegisterInfo * getRegisterInfo() const
Lightweight error class with error context and mandatory checking.
DWARFCompileUnit * getCompileUnitForOffset(uint64_t Offset)
Return the compile unit that includes an offset (relative to .debug_info).
function_ref< void(Error)> getRecoverableErrorHandler()
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
static bool classof(const DIContext *DICtx)
static const bool IsLittleEndianHost
const DWARFObject & getDWARFObj() const
A range adaptor for a pair of iterators.
bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)
DWARFCompileUnit * getCompileUnitForAddress(uint64_t Address)
Return the compile unit which contains instruction with provided address.
llvm::iterator_range< typename UnitVector::iterator > iterator_range
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
.debug_names section consists of one or more units.
DWARFContext(std::unique_ptr< const DWARFObject > DObj, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler)
Wraps the returned DIEs for a given address.
static bool isSupportedVersion(unsigned version)
const AppleAcceleratorTable & getAppleTypes()
Get a reference to the parsed accelerator table object.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, std::array< Optional< uint64_t >, DIDT_ID_Count > DumpOffsets)
Dump a textual representation to OS.
const AppleAcceleratorTable & getAppleNamespaces()
Get a reference to the parsed accelerator table object.
Error loadRegisterInfo(const object::ObjectFile &Obj)
Loads register info for the architecture of the provided object file.
static unsigned getMaxSupportedVersion()
SectionType
These are the section type and attributes fields.
DIContextKind getKind() const
Container for dump options that control which debug information will be dumped.
Describe a collection of units.