diff options
-rw-r--r-- | include/llvm/DebugInfo/DIContext.h | 1 | ||||
-rw-r--r-- | include/llvm/Support/Dwarf.h | 17 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 4 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFContext.cpp | 22 | ||||
-rw-r--r-- | lib/DebugInfo/DWARFContext.h | 3 | ||||
-rw-r--r-- | test/DebugInfo/X86/gnu-public-names.ll | 29 |
6 files changed, 52 insertions, 24 deletions
diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index 4bb7c77..ab0fca5 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -109,6 +109,7 @@ enum DIDumpType { DIDT_Loc, DIDT_Ranges, DIDT_Pubnames, + DIDT_GnuPubnames, DIDT_Str, DIDT_StrDwo, DIDT_StrOffsetsDwo diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 30f268c..7b87c6a 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -821,19 +821,18 @@ StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); /// offset of the cu within the debug_info section stored in those 24 bits. struct PubIndexEntryDescriptor { GDBIndexEntryKind Kind; - GDBIndexEntryLinkage Static; - PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Static) - : Kind(Kind), Static(Static) {} + GDBIndexEntryLinkage Linkage; + PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage) + : Kind(Kind), Linkage(Linkage) {} /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind) - : Kind(Kind), Static(GIEL_EXTERNAL) {} + : Kind(Kind), Linkage(GIEL_EXTERNAL) {} explicit PubIndexEntryDescriptor(uint8_t Value) : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> KIND_OFFSET)), - Static(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >> - LINKAGE_OFFSET)) {} - uint8_t toBits() { - return Kind << KIND_OFFSET | Static << LINKAGE_OFFSET; - } + Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >> + LINKAGE_OFFSET)) {} + uint8_t toBits() { return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET; } + private: enum { KIND_OFFSET = 4, diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index a5b5905..a8ebf45 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2404,7 +2404,7 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) { dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity); Asm->OutStreamer.AddComment( "Kind: " + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " + - dwarf::GDBIndexEntryLinkageString(Desc.Static)); + dwarf::GDBIndexEntryLinkageString(Desc.Linkage)); Asm->EmitInt8(Desc.toBits()); } @@ -2466,7 +2466,7 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) { dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheCU, Entity); Asm->OutStreamer.AddComment( "Kind: " + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " + - dwarf::GDBIndexEntryLinkageString(Desc.Static)); + dwarf::GDBIndexEntryLinkageString(Desc.Linkage)); Asm->EmitInt8(Desc.toBits()); } diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index baf2bb5..c87855e 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -120,6 +120,27 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType) { } } + if (DumpType == DIDT_All || DumpType == DIDT_GnuPubnames) { + OS << "\n.debug_gnu_pubnames contents:\n"; + DataExtractor pubNames(getGnuPubNamesSection(), isLittleEndian(), 0); + offset = 0; + OS << "Length: " << pubNames.getU32(&offset) << "\n"; + OS << "Version: " << pubNames.getU16(&offset) << "\n"; + OS << "Offset in .debug_info: " << pubNames.getU32(&offset) << "\n"; + OS << "Size: " << pubNames.getU32(&offset) << "\n"; + OS << "Offset Linkage Kind Name\n"; + while (offset < getGnuPubNamesSection().size()) { + uint32_t dieRef = pubNames.getU32(&offset); + if (dieRef == 0) + break; + PubIndexEntryDescriptor desc(pubNames.getU8(&offset)); + OS << format("0x%8.8x ", dieRef) + << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage)) + << ' ' << dwarf::GDBIndexEntryKindString(desc.Kind) << ' ' + << pubNames.getCStr(&offset) << "\n"; + } + } + if (DumpType == DIDT_All || DumpType == DIDT_AbbrevDwo) { const DWARFDebugAbbrev *D = getDebugAbbrevDWO(); if (D) { @@ -566,6 +587,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) : .Case("debug_str", &StringSection) .Case("debug_ranges", &RangeSection) .Case("debug_pubnames", &PubNamesSection) + .Case("debug_gnu_pubnames", &GnuPubNamesSection) .Case("debug_info.dwo", &InfoDWOSection) .Case("debug_abbrev.dwo", &AbbrevDWOSection) .Case("debug_str.dwo", &StringDWOSection) diff --git a/lib/DebugInfo/DWARFContext.h b/lib/DebugInfo/DWARFContext.h index c491b4c..e4b640e4c 100644 --- a/lib/DebugInfo/DWARFContext.h +++ b/lib/DebugInfo/DWARFContext.h @@ -125,6 +125,7 @@ public: virtual StringRef getStringSection() = 0; virtual StringRef getRangeSection() = 0; virtual StringRef getPubNamesSection() = 0; + virtual StringRef getGnuPubNamesSection() = 0; // Sections for DWARF5 split dwarf proposal. virtual StringRef getInfoDWOSection() = 0; @@ -166,6 +167,7 @@ class DWARFContextInMemory : public DWARFContext { StringRef StringSection; StringRef RangeSection; StringRef PubNamesSection; + StringRef GnuPubNamesSection; // Sections for DWARF5 split dwarf proposal. RelocAddrMap InfoDWORelocMap; @@ -195,6 +197,7 @@ public: virtual StringRef getStringSection() { return StringSection; } virtual StringRef getRangeSection() { return RangeSection; } virtual StringRef getPubNamesSection() { return PubNamesSection; } + virtual StringRef getGnuPubNamesSection() { return GnuPubNamesSection; } // Sections for DWARF5 split dwarf proposal. virtual StringRef getInfoDWOSection() { return InfoDWOSection; } diff --git a/test/DebugInfo/X86/gnu-public-names.ll b/test/DebugInfo/X86/gnu-public-names.ll index 19dd5b5..9d4e6b6 100644 --- a/test/DebugInfo/X86/gnu-public-names.ll +++ b/test/DebugInfo/X86/gnu-public-names.ll @@ -1,4 +1,5 @@ -; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -o - %s | FileCheck %s +; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s +; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s ; ModuleID = 'dwarf-public-names.cpp' ; ; Generated from: @@ -33,18 +34,20 @@ ; } -; CHECK: .byte 32 # Kind: VARIABLE, EXTERNAL -; CHECK-NEXT: .asciz "global_namespace_variable" # External Name -; CHECK: .byte 48 # Kind: FUNCTION, EXTERNAL -; CHECK-NEXT: .asciz "global_namespace_function" # External Name -; CHECK: .byte 176 # Kind: FUNCTION, STATIC -; CHECK-NEXT: .asciz "static_member_function" # External Name -; CHECK: .byte 32 # Kind: VARIABLE, EXTERNAL -; CHECK-NEXT: .asciz "global_variable" # External Name -; CHECK: .byte 48 # Kind: FUNCTION, EXTERNAL -; CHECK-NEXT: .asciz "global_function" # External Name -; CHECK: .byte 176 # Kind: FUNCTION, STATIC -; CHECK-NEXT: .asciz "member_function" # External Name +; ASM: .byte 32 # Kind: VARIABLE, EXTERNAL + +; CHECK: .debug_gnu_pubnames contents: +; CHECK-NEXT: Length: 167 +; CHECK-NEXT: Version: 2 +; CHECK-NEXT: Offset in .debug_info: 0 +; CHECK-NEXT: Size: 317 +; CHECK-NEXT: Offset Linkage Kind Name +; CHECK-DAG: 0x00000094 EXTERNAL VARIABLE global_namespace_variable +; CHECK-DAG: 0x000000a3 EXTERNAL FUNCTION global_namespace_function +; CHECK-DAG: 0x000000e8 STATIC FUNCTION static_member_function +; CHECK-DAG: 0x0000007c EXTERNAL VARIABLE global_variable +; CHECK-DAG: 0x000000ff EXTERNAL FUNCTION global_function +; CHECK-DAG: 0x000000be STATIC FUNCTION member_function %struct.C = type { i8 } |