DWARFUnitVector DWOUnits;
std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
+ std::unique_ptr<DWARFDebugMacro> MacroDWO;
/// The maximum DWARF version of all units.
unsigned MaxVersion = 0;
/// Get a pointer to the parsed DebugMacro object.
const DWARFDebugMacro *getDebugMacro();
+ /// Get a pointer to the parsed DebugMacroDWO object.
+ const DWARFDebugMacro *getDebugMacroDWO();
+
/// Get a reference to the parsed accelerator table object.
const DWARFDebugNames &getDebugNames();
virtual const DWARFSection &getRangesSection() const { return Dummy; }
virtual const DWARFSection &getRnglistsSection() const { return Dummy; }
virtual StringRef getMacinfoSection() const { return ""; }
+ virtual StringRef getMacinfoDWOSection() const { return ""; }
virtual const DWARFSection &getPubnamesSection() const { return Dummy; }
virtual const DWARFSection &getPubtypesSection() const { return Dummy; }
virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; }
MCSection *DwarfLineDWOSection = nullptr;
MCSection *DwarfLocDWOSection = nullptr;
MCSection *DwarfStrOffDWOSection = nullptr;
+ MCSection *DwarfMacinfoDWOSection = nullptr;
/// The DWARF v5 string offset and address table sections.
MCSection *DwarfStrOffSection = nullptr;
MCSection *getDwarfLoclistsDWOSection() const {
return DwarfLoclistsDWOSection;
}
+ MCSection *getDwarfMacinfoDWOSection() const {
+ return DwarfMacinfoDWOSection;
+ }
MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
auto *CUNode = cast<DICompileUnit>(P.first);
// If compile Unit has macros, emit "DW_AT_macro_info" attribute.
- if (CUNode->getMacros())
+ if (CUNode->getMacros() && !useSplitDwarf())
U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_macro_info,
U.getMacroLabelBegin(),
TLOF.getDwarfMacinfoSection()->getBeginSymbol());
// Emit info into a debug ranges section.
emitDebugRanges();
+ if (useSplitDwarf())
+ // Emit info into a debug macinfo.dwo section.
+ emitDebugMacinfoDWO();
+ else
// Emit info into a debug macinfo section.
- emitDebugMacinfo();
+ emitDebugMacinfo();
if (useSplitDwarf()) {
emitDebugStrDWO();
}
}
+void DwarfDebug::emitDebugMacinfoDWO() {
+ for (const auto &P : CUMap) {
+ auto &TheCU = *P.second;
+ auto *SkCU = TheCU.getSkeleton();
+ DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;
+ auto *CUNode = cast<DICompileUnit>(P.first);
+ DIMacroNodeArray Macros = CUNode->getMacros();
+ if (Macros.empty())
+ continue;
+ Asm->OutStreamer->SwitchSection(
+ Asm->getObjFileLowering().getDwarfMacinfoDWOSection());
+ Asm->OutStreamer->EmitLabel(U.getMacroLabelBegin());
+ handleMacroNodes(Macros, U);
+ Asm->OutStreamer->AddComment("End Of Macro List Mark");
+ Asm->emitInt8(0);
+ }
+}
+
// DWARF5 Experimental Separate Dwarf emitters.
void DwarfDebug::initSkeletonUnit(const DwarfUnit &U, DIE &Die,
/// Emit macros into a debug macinfo section.
void emitDebugMacinfo();
+ /// Emit macros into a debug macinfo.dwo section.
+ void emitDebugMacinfoDWO();
void emitMacro(DIMacro &M);
void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
if (Explicit || !getDebugMacro()->empty()) {
OS << "\n.debug_macinfo contents:\n";
getDebugMacro()->dump(OS);
+ } else if (ExplicitDWO || !getDebugMacroDWO()->empty()) {
+ OS << "\n.debug_macinfo.dwo contents:\n";
+ getDebugMacroDWO()->dump(OS);
}
}
return DebugFrame.get();
}
+const DWARFDebugMacro *DWARFContext::getDebugMacroDWO() {
+ if (MacroDWO)
+ return MacroDWO.get();
+
+ DataExtractor MacinfoDWOData(DObj->getMacinfoDWOSection(), isLittleEndian(),
+ 0);
+ MacroDWO.reset(new DWARFDebugMacro());
+ MacroDWO->parse(MacinfoDWOData);
+ return MacroDWO.get();
+}
+
const DWARFDebugMacro *DWARFContext::getDebugMacro() {
if (Macro)
return Macro.get();
StringRef ArangesSection;
StringRef StrSection;
StringRef MacinfoSection;
+ StringRef MacinfoDWOSection;
StringRef AbbrevDWOSection;
StringRef StrDWOSection;
StringRef CUIndexSection;
.Case("debug_aranges", &ArangesSection)
.Case("debug_str", &StrSection)
.Case("debug_macinfo", &MacinfoSection)
+ .Case("debug_macinfo.dwo", &MacinfoDWOSection)
.Case("debug_abbrev.dwo", &AbbrevDWOSection)
.Case("debug_str.dwo", &StrDWOSection)
.Case("debug_cu_index", &CUIndexSection)
return RnglistsSection;
}
StringRef getMacinfoSection() const override { return MacinfoSection; }
+ StringRef getMacinfoDWOSection() const override { return MacinfoDWOSection; }
const DWARFSection &getPubnamesSection() const override { return PubnamesSection; }
const DWARFSection &getPubtypesSection() const override { return PubtypesSection; }
const DWARFSection &getGnuPubnamesSection() const override {
DebugSecType, ELF::SHF_EXCLUDE);
DwarfRnglistsDWOSection =
Ctx->getELFSection(".debug_rnglists.dwo", DebugSecType, ELF::SHF_EXCLUDE);
+ DwarfMacinfoDWOSection =
+ Ctx->getELFSection(".debug_macinfo.dwo", DebugSecType, ELF::SHF_EXCLUDE);
DwarfLoclistsDWOSection =
Ctx->getELFSection(".debug_loclists.dwo", DebugSecType, ELF::SHF_EXCLUDE);
--- /dev/null
+RUN: llvm-dwarfdump -debug-macro %p/Inputs/dwarfdump-macro.dwo \
+RUN: | FileCheck %s -check-prefix TEST_MACINFODWO
+
+; This test verifies that llvm-dwarfdump tools know how to read .debug_macinfo.dwo
+; section.
+; dwarfdump-macro.dwo has been generated from Inputs/dwarfdump-macro.cc
+; clang++ -c -O0 -DM3=Value3 -include dwarfdump-macro-cmd.h dwarfdump-macro.cc -fdebug-macro -gsplit-dwarf
+
+TEST_MACINFODWO: .debug_macinfo.dwo contents:
+TEST_MACINFODWO: DW_MACINFO_start_file - lineno: 0 filenum: 1
+TEST_MACINFODWO: DW_MACINFO_start_file - lineno: 0 filenum: 2
+TEST_MACINFODWO: DW_MACINFO_define - lineno: 1 macro: M4 Value4
+TEST_MACINFODWO: DW_MACINFO_end_file
+TEST_MACINFODWO: DW_MACINFO_define - lineno: 1 macro: M1 Value1
+TEST_MACINFODWO: DW_MACINFO_start_file - lineno: 2 filenum: 3
+TEST_MACINFODWO: DW_MACINFO_undef - lineno: 4 macro: M1
+TEST_MACINFODWO: DW_MACINFO_define - lineno: 5 macro: M1 NewValue1
+TEST_MACINFODWO: DW_MACINFO_end_file
+TEST_MACINFODWO: DW_MACINFO_define - lineno: 3 macro: M2(x,y) ((x)+(y)* Value2)
+TEST_MACINFODWO: DW_MACINFO_end_file