25DwarfFormat DWARFDebugMacro::MacroHeader::getDwarfFormat()
const {
29uint8_t DWARFDebugMacro::MacroHeader::getOffsetByteSize()
const {
33void DWARFDebugMacro::MacroHeader::dumpMacroHeader(raw_ostream &OS)
const {
36 <<
formatv(
", flags = {0:x2}", Flags)
38 if (Flags & MACRO_DEBUG_LINE_OFFSET)
39 OS <<
formatv(
", debug_line_offset = 0x{0:x-}",
41 2 * getOffsetByteSize(),
'0'));
46 unsigned IndLevel = 0;
47 for (
const auto &Macros : MacroLists) {
48 OS <<
formatv(
"{0:x8}:\n", Macros.Offset);
49 if (Macros.IsDebugMacro)
50 Macros.Header.dumpMacroHeader(OS);
51 for (
const Entry &E : Macros.Macros) {
57 for (
unsigned I = 0;
I < IndLevel;
I++)
61 if (Macros.IsDebugMacro)
83 case DW_MACRO_define_strp:
84 case DW_MACRO_undef_strp:
85 case DW_MACRO_define_strx:
86 case DW_MACRO_undef_strx:
87 OS <<
" - lineno: " << E.Line;
88 OS <<
" macro: " << E.MacroStr;
90 case DW_MACRO_start_file:
91 OS <<
" - lineno: " << E.Line;
92 OS <<
" filenum: " << E.File;
95 OS <<
formatv(
" - import offset: 0x{0:x-}",
97 2 * Macros.Header.getOffsetByteSize(),
'0'));
99 case DW_MACRO_end_file:
102 OS <<
" - constant: " << E.ExtConstant;
103 OS <<
" string: " << E.ExtStr;
111Error DWARFDebugMacro::parseImpl(
112 std::optional<DWARFUnitVector::compile_unit_range> Units,
116 MacroList *M =
nullptr;
118 MacroToUnitsMap MacroToUnits;
122 for (
const auto &U : *Units)
123 if (
auto CUDIE = U->getUnitDIE())
126 MacroToUnits.try_emplace(*MacroOffset, U.get());
130 MacroLists.emplace_back();
131 M = &MacroLists.back();
133 M->IsDebugMacro = IsMacro;
135 auto Err = M->Header.parseMacroHeader(
Data, &
Offset);
141 M->Macros.emplace_back();
142 Entry &
E =
M->Macros.back();
164 case DW_MACRO_define:
171 case DW_MACRO_define_strp:
172 case DW_MACRO_undef_strp: {
180 uint64_t StrOffset = 0;
185 Data.getRelocatedValue(
M->Header.getOffsetByteSize(), &
Offset);
186 assert(StringExtractor &&
"String Extractor not found");
187 E.MacroStr = StringExtractor->getCStr(&StrOffset);
190 case DW_MACRO_define_strx:
191 case DW_MACRO_undef_strx: {
200 auto MacroContributionOffset = MacroToUnits.find(
M->Offset);
201 if (MacroContributionOffset == MacroToUnits.end())
203 "Macro contribution of the unit not found");
204 Expected<uint64_t> StrOffset =
205 MacroContributionOffset->second->getStringOffsetSectionItem(
210 MacroContributionOffset->second->getStringExtractor().getCStr(
214 case DW_MACRO_start_file:
220 case DW_MACRO_end_file:
222 case DW_MACRO_import:
224 Data.getRelocatedValue(
M->Header.getOffsetByteSize(), &
Offset);
237Error DWARFDebugMacro::MacroHeader::parseMacroHeader(DWARFDataExtractor
Data,
243 if (FlagData & MACRO_OPCODE_OPERANDS_TABLE)
245 "opcode_operands_table is not supported");
247 if (Flags & MACRO_DEBUG_LINE_OFFSET)
248 DebugLineOffset =
Data.getUnsigned(
Offset, getOffsetByteSize());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
void dump(raw_ostream &OS) const
Print the macro list found within the debug_macinfo/debug_macro section.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Error takeError()
Take ownership of the stored error.
An RAII object that temporarily switches an output stream to a specific color.
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_ABI StringRef MacroString(unsigned Encoding)
LLVM_ABI StringRef FormatString(DwarfFormat Format)
LLVM_ABI StringRef GnuMacroString(unsigned Encoding)
LLVM_ABI StringRef MacinfoString(unsigned Encoding)
Calculates the starting offsets for various sections within the .debug_names section.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
std::optional< uint64_t > toSectionOffset(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract an section offset.
uint8_t getDwarfOffsetByteSize(DwarfFormat Format)
The size of a reference determined by the DWARF 32/64-bit format.
@ DW_MACINFO_invalid
Macinfo type for invalid results.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
FunctionAddr VTableAddr uintptr_t uintptr_t Version
FunctionAddr VTableAddr uintptr_t uintptr_t Data
support::detail::AlignAdapter< T > fmt_align(T &&Item, AlignStyle Where, size_t Amount, char Fill=' ')