23DwarfFormat DWARFDebugMacro::MacroHeader::getDwarfFormat()
const {
27uint8_t DWARFDebugMacro::MacroHeader::getOffsetByteSize()
const {
31void DWARFDebugMacro::MacroHeader::dumpMacroHeader(
raw_ostream &
OS)
const {
33 OS <<
format(
"macro header: version = 0x%04" PRIx16, Version)
34 <<
format(
", flags = 0x%02" PRIx8, Flags)
36 if (Flags & MACRO_DEBUG_LINE_OFFSET)
37 OS <<
format(
", debug_line_offset = 0x%0*" PRIx64, 2 * getOffsetByteSize(),
43 unsigned IndLevel = 0;
44 for (
const auto &Macros : MacroLists) {
45 OS <<
format(
"0x%08" PRIx64
":\n", Macros.Offset);
46 if (Macros.IsDebugMacro)
47 Macros.Header.dumpMacroHeader(
OS);
48 for (
const Entry &E : Macros.Macros) {
54 for (
unsigned I = 0;
I < IndLevel;
I++)
58 if (Macros.IsDebugMacro)
80 case DW_MACRO_define_strp:
81 case DW_MACRO_undef_strp:
82 case DW_MACRO_define_strx:
83 case DW_MACRO_undef_strx:
84 OS <<
" - lineno: " << E.Line;
85 OS <<
" macro: " << E.MacroStr;
87 case DW_MACRO_start_file:
88 OS <<
" - lineno: " << E.Line;
89 OS <<
" filenum: " << E.File;
92 OS <<
format(
" - import offset: 0x%0*" PRIx64,
93 2 * Macros.Header.getOffsetByteSize(), E.ImportOffset);
95 case DW_MACRO_end_file:
98 OS <<
" - constant: " << E.ExtConstant;
99 OS <<
" string: " << E.ExtStr;
107Error DWARFDebugMacro::parseImpl(
108 std::optional<DWARFUnitVector::compile_unit_range> Units,
112 MacroList *M =
nullptr;
114 MacroToUnitsMap MacroToUnits;
118 for (
const auto &U : *Units)
119 if (
auto CUDIE = U->getUnitDIE())
126 MacroLists.emplace_back();
127 M = &MacroLists.back();
129 M->IsDebugMacro = IsMacro;
131 auto Err = M->Header.parseMacroHeader(
Data, &
Offset);
137 M->Macros.emplace_back();
138 Entry &E =
M->Macros.back();
160 case DW_MACRO_define:
167 case DW_MACRO_define_strp:
168 case DW_MACRO_undef_strp: {
181 Data.getRelocatedValue(
M->Header.getOffsetByteSize(), &
Offset);
182 assert(StringExtractor &&
"String Extractor not found");
183 E.MacroStr = StringExtractor->getCStr(&StrOffset);
186 case DW_MACRO_define_strx:
187 case DW_MACRO_undef_strx: {
196 auto MacroContributionOffset = MacroToUnits.find(
M->Offset);
197 if (MacroContributionOffset == MacroToUnits.end())
199 "Macro contribution of the unit not found");
201 MacroContributionOffset->second->getStringOffsetSectionItem(
206 MacroContributionOffset->second->getStringExtractor().getCStr(
210 case DW_MACRO_start_file:
216 case DW_MACRO_end_file:
218 case DW_MACRO_import:
220 Data.getRelocatedValue(
M->Header.getOffsetByteSize(), &
Offset);
239 if (FlagData & MACRO_OPCODE_OPERANDS_TABLE)
241 "opcode_operands_table is not supported");
243 if (Flags & MACRO_DEBUG_LINE_OFFSET)
244 DebugLineOffset =
Data.getUnsigned(
Offset, getOffsetByteSize());
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void dump(raw_ostream &OS) const
Print the macro list found within the debug_macinfo/debug_macro section.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
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.
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.
StringRef MacroString(unsigned Encoding)
StringRef FormatString(DwarfFormat Format)
StringRef GnuMacroString(unsigned Encoding)
StringRef MacinfoString(unsigned Encoding)
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.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.