9#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
10#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
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 =
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 =
139 std::function<
void(
Error)> WarningHandler =
141 bool ThreadSafe =
false);
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();
357 void clearLineTableForUnit(
DWARFUnit *U);
387 DIEsForAddress getDIEsForAddress(
uint64_t Address,
bool CheckDWO =
false);
389 std::optional<DILineInfo> getLineInfoForAddress(
392 std::optional<DILineInfo>
416 template <
typename... Ts>
418 std::error_code EC,
char const *Fmt,
424 Stream <<
format(Fmt, Vals...)
425 <<
" has unsupported address size: " << AddressSize
426 <<
" (supported are ";
429 Stream << LS <<
Size;
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 =
450 std::function<
void(
Error)> WarningHandler =
452 bool ThreadSafe =
false);
454 static std::unique_ptr<DWARFContext>
455 create(
const StringMap<std::unique_ptr<MemoryBuffer>> &Sections,
457 std::function<
void(
Error)> RecoverableErrorHandler =
459 std::function<
void(
Error)> WarningHandler =
461 bool ThreadSafe =
false);
496 std::vector<DILocal> &Result);
This file defines the StringMap class.
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
DIContext(DIContextKind K)
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
LLVM_ABI std::unique_ptr< DWARFDebugMacro > parseMacroOrMacinfo(MacroSecType SectionType)
Parse a macro[.dwo] or macinfo[.dwo] section.
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()
DWARFContext(std::unique_ptr< const DWARFObject > DObj, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler, bool ThreadSafe=false)
unsigned getNumTypeUnits()
Get the number of type units in this context.
DWARFUnitVector::iterator_range unit_iterator_range
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.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, std::array< std::optional< uint64_t >, DIDT_ID_Count > DumpOffsets)
Dump a textual representation to OS.
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()
A parsed .debug_frame or .eh_frame section.
.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.
llvm::iterator_range< typename UnitVector::iterator > iterator_range
decltype(make_filter_range(std::declval< iterator_range >(), isCompileUnit)) compile_unit_range
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
A helper class to return the specified delimiter string after the first invocation of operator String...
An inferface for inquiring the load address of a loaded object file to be used by the DIContext imple...
This interface provides simple read-only access to a block of memory, and provides simple methods for...
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.
static LLVM_ABI void defaultWarningHandler(Error Warning)
Implement default handling for Warning.
static LLVM_ABI void defaultErrorHandler(Error Err)
Implement default handling for Error.
An efficient, type-erasing, non-owning reference to a callable.
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.
constexpr bool IsLittleEndianHost
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
SmallVector< std::pair< uint64_t, DILineInfo >, 16 > DILineInfoTable
static CompileUnit * getUnitForOffset(const UnitListTy &Units, uint64_t Offset)
Similar to DWARFUnitSection::getUnitForOffset(), but returning our CompileUnit object instead.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
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.
DWARFCompileUnit * CompileUnit