From: David Blaikie Date: Thu, 19 Sep 2013 23:01:29 +0000 (+0000) Subject: DebugInfo: llvm-dwarfdump support for gnu_pubnames section X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=994c37fcb001bc5a53bf2c676009b327b882d765;p=oota-llvm.git DebugInfo: llvm-dwarfdump support for gnu_pubnames section git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191050 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index 4bb7c774389..ab0fca58ecd 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 30f268c6519..7b87c6a90d0 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((Value & KIND_MASK) >> KIND_OFFSET)), - Static(static_cast((Value & LINKAGE_MASK) >> - LINKAGE_OFFSET)) {} - uint8_t toBits() { - return Kind << KIND_OFFSET | Static << LINKAGE_OFFSET; - } + Linkage(static_cast((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 a5b5905f3b1..a8ebf45e6e9 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 baf2bb5b577..c87855e530b 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 c491b4ca492..e4b640e4c90 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 19dd5b57126..9d4e6b609ae 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 }