9#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
10#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
34class AppleAcceleratorTable;
35class DWARFCompileUnit;
36class DWARFDebugAbbrev;
37class DWARFDebugAranges;
97 virtual std::shared_ptr<DWARFContext>
104 LLVM_ABI std::unique_ptr<DWARFDebugMacro>
112 std::unique_ptr<DWARFContextState> State;
115 unsigned MaxVersion = 0;
117 std::function<void(
Error)> RecoverableErrorHandler =
118 WithColor::defaultErrorHandler;
119 std::function<void(
Error)> WarningHandler = WithColor::defaultWarningHandler;
125 enum { EagerParse =
false, LazyParse =
true };
128 std::unique_ptr<const DWARFObject> DObj;
132 bool ParseCUTUIndexManually =
false;
136 std::string DWPName =
"",
137 std::function<
void(
Error)> RecoverableErrorHandler =
138 WithColor::defaultErrorHandler,
139 std::function<
void(
Error)> WarningHandler =
140 WithColor::defaultWarningHandler,
141 bool ThreadSafe =
false);
150 return DICtx->
getKind() == CK_DWARF;
156 std::array<std::optional<uint64_t>, DIDT_ID_Count> DumpOffsets);
159 std::array<std::optional<uint64_t>,
DIDT_ID_Count> DumpOffsets;
160 dump(
OS, DumpOpts, DumpOffsets);
172 NormalUnits.
begin() +
177 return State->getNormalUnits();
209 return State->getDWOUnits();
239 return State->getNormalUnits().getNumInfoUnits();
244 return State->getNormalUnits().getNumTypesUnits();
249 return State->getDWOUnits().getNumInfoUnits();
254 return State->getDWOUnits().getNumTypesUnits();
259 return State->getNormalUnits()[index].get();
264 return State->getDWOUnits()[index].get();
281 info_section_units();
287 dwo_info_section_units();
292 if (Version > MaxVersion)
293 MaxVersion = Version;
357 void clearLineTableForUnit(
DWARFUnit *U);
387 DIEsForAddress getDIEsForAddress(
uint64_t Address,
bool CheckDWO =
false);
389 std::optional<DILineInfo> getLineInfoForAddress(
392 std::optional<DILineInfo>
407 return version >= 2 && version <= getMaxSupportedVersion();
416 template <
typename... Ts>
418 std::error_code EC,
char const *Fmt,
420 if (isAddressSizeSupported(AddressSize))
421 return Error::success();
424 Stream <<
format(Fmt, Vals...)
425 <<
" has unsupported address size: " << AddressSize
426 <<
" (supported are ";
428 for (
unsigned Size : DWARFContext::getSupportedAddressSizes())
429 Stream << LS <<
Size;
431 return make_error<StringError>(Buffer, EC);
434 std::shared_ptr<DWARFContext> getDWOContext(
StringRef AbsolutePath);
437 return RecoverableErrorHandler;
444 static std::unique_ptr<DWARFContext>
446 ProcessDebugRelocations RelocAction = ProcessDebugRelocations::Process,
448 std::function<
void(
Error)> RecoverableErrorHandler =
449 WithColor::defaultErrorHandler,
450 std::function<
void(
Error)> WarningHandler =
451 WithColor::defaultWarningHandler,
452 bool ThreadSafe =
false);
454 static std::unique_ptr<DWARFContext>
455 create(
const StringMap<std::unique_ptr<MemoryBuffer>> &Sections,
456 uint8_t AddrSize,
bool isLittleEndian = sys::IsLittleEndianHost,
457 std::function<
void(
Error)> RecoverableErrorHandler =
458 WithColor::defaultErrorHandler,
459 std::function<
void(
Error)> WarningHandler =
460 WithColor::defaultWarningHandler,
461 bool ThreadSafe =
false);
468 return getDWARFObj().getFile()->getArch();
496 std::vector<DILocal> &Result);
This file defines the StringMap class.
ReachingDefAnalysis InstSet InstSet & Ignore
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
This file defines the SmallVector class.
This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...
DIContextKind getKind() const
A format-neutral container for inlined code description.
DWARFContextState This structure contains all member variables for DWARFContext that need to be prote...
virtual void clearLineTableForUnit(DWARFUnit *U)=0
virtual DWARFGdbIndex & getGdbIndex()=0
virtual Expected< const DWARFDebugFrame * > getEHFrame()=0
virtual const DWARFUnitIndex & getCUIndex()=0
MacroSecType
Helper enum to distinguish between macro[.dwo] and macinfo[.dwo] section.
virtual bool isThreadSafe() const =0
virtual const DWARFUnitIndex & getTUIndex()=0
virtual const DWARFDebugMacro * getDebugMacinfoDWO()=0
virtual const DWARFDebugMacro * getDebugMacroDWO()=0
virtual const DenseMap< uint64_t, DWARFTypeUnit * > & getTypeUnitMap(bool IsDWO)=0
virtual Expected< const DWARFDebugLine::LineTable * > getLineTableForUnit(DWARFUnit *U, function_ref< void(Error)> RecoverableErrHandler)=0
virtual const DWARFDebugAbbrev * getDebugAbbrevDWO()=0
virtual const DWARFDebugMacro * getDebugMacro()=0
virtual const DWARFDebugAranges * getDebugAranges()=0
virtual ~DWARFContextState()=default
virtual const AppleAcceleratorTable & getAppleNames()=0
DWARFContextState(DWARFContext &DC)
virtual Expected< const DWARFDebugFrame * > getDebugFrame()=0
virtual DWARFUnitVector & getDWOUnits(bool Lazy=false)=0
virtual const DWARFDebugLoc * getDebugLoc()=0
virtual DWARFUnitVector & getNormalUnits()=0
virtual const DWARFDebugAbbrev * getDebugAbbrev()=0
virtual const DWARFDebugNames & getDebugNames()=0
virtual const AppleAcceleratorTable & getAppleTypes()=0
virtual const AppleAcceleratorTable & getAppleNamespaces()=0
virtual const DWARFDebugMacro * getDebugMacinfo()=0
virtual const AppleAcceleratorTable & getAppleObjC()=0
virtual std::shared_ptr< DWARFContext > getDWOContext(StringRef AbsolutePath)=0
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
static bool isSupportedVersion(unsigned version)
Triple::ArchType getArch() const
function_ref< void(Error)> getRecoverableErrorHandler()
unsigned getNumCompileUnits()
Get the number of compile units in this context.
DWARFUnitVector::compile_unit_range compile_unit_range
static SmallVector< uint8_t, 3 > getSupportedAddressSizes()
unsigned getNumTypeUnits()
Get the number of type units in this context.
static bool classof(const DIContext *DICtx)
compile_unit_range compile_units()
Get compile units in this context.
DWARFUnit * getDWOUnitAtIndex(unsigned index)
Get the unit at the specified index for the DWO units.
DataExtractor getStringExtractor() const
void setParseCUTUIndexManually(bool PCUTU)
Sets whether CU/TU should be populated manually.
unsigned getNumDWOTypeUnits()
Get the number of type units in the DWO context.
static Error checkAddressSizeSupported(unsigned AddressSize, std::error_code EC, char const *Fmt, const Ts &...Vals)
function_ref< void(Error)> getWarningHandler()
bool isLittleEndian() const
DWARFUnit * getUnitAtIndex(unsigned index)
Get the unit at the specified index.
DWARFContext & operator=(DWARFContext &)=delete
void setMaxVersionIfGreater(unsigned Version)
compile_unit_range dwo_compile_units()
Get compile units in the DWO context.
const DWARFUnitVector & getNormalUnitsVector()
unit_iterator_range dwo_types_section_units()
Get units from .debug_types.dwo in the DWO context.
unit_iterator_range normal_units()
Get all normal compile/type units in this context.
static unsigned getMaxSupportedVersion()
unit_iterator_range types_section_units()
Get units from .debug_types in this context.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override
unsigned getNumDWOCompileUnits()
Get the number of compile units in the DWO context.
DWARFContext(DWARFContext &)=delete
DataExtractor getLineStringExtractor() const
unit_iterator_range info_section_units()
Get units from .debug_info in this context.
bool getParseCUTUIndexManually() const
Returns whether CU/TU should be populated manually.
unit_iterator_range dwo_info_section_units()
Get units from .debug_info..dwo in the DWO context.
DataExtractor getStringDWOExtractor() const
static bool isAddressSizeSupported(unsigned AddressSize)
const DWARFUnitVector & getDWOUnitsVector()
unit_iterator_range dwo_units()
Get all units in the DWO context.
const DWARFObject & getDWARFObj() const
unsigned getMaxDWOVersion()
.debug_names section consists of one or more units.
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Describe a collection of units.
unsigned getNumInfoUnits() const
Returns number of units from all .debug_info[.dwo] sections.
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Stores all information relating to a compile unit, be it in its original instance in the object file ...
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class is the base class for all object file types.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
A collection of legacy interfaces for querying information about the current executing process.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
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...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool isCompileUnit(const std::unique_ptr< DWARFUnit > &U)
Container for dump options that control which debug information will be dumped.
Controls which fields of DILineInfo container should be filled with data.
Wraps the returned DIEs for a given address.