diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 6 | ||||
| -rw-r--r-- | llvm/test/DebugInfo/X86/no-public-sections.ll | 31 |
4 files changed, 46 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 713a9763a7f..0ff1b5004d9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -851,7 +851,8 @@ bool DwarfCompileUnit::hasDwarfPubSections() const { if (CUNode->getGnuPubnames()) return true; - return DD->tuneForGDB() && !includeMinimalInlineScopes(); + return DD->tuneForGDB() && DD->usePubSections() && + !includeMinimalInlineScopes(); } /// addGlobalName - Add a new global name to the compile unit. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index a1e9a01e72b..b9a17d5018c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -123,6 +123,11 @@ DwarfInlinedStrings("dwarf-inlined-strings", cl::Hidden, clEnumVal(Disable, "Disabled")), cl::init(Default)); +static cl::opt<bool> + NoDwarfPubSections("no-dwarf-pub-sections", cl::Hidden, + cl::desc("Disable emission of DWARF pub sections."), + cl::init(false)); + enum LinkageNameOption { DefaultLinkageNames, AllLinkageNames, @@ -310,6 +315,8 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) // Use dwarf 4 by default if nothing is requested. DwarfVersion = DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION; + UsePubSections = !NoDwarfPubSections; + // Work around a GDB bug. GDB doesn't support the standard opcode; // SCE doesn't support GNU's; LLDB prefers the standard opcode, which // is defined as of DWARF 3. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index c8a36baffe3..56a1d633729 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -258,6 +258,9 @@ class DwarfDebug : public DebugHandlerBase { /// Use inlined strings. bool UseInlineStrings = false; + /// Whether to emit DWARF pub sections or not. + bool UsePubSections = true; + /// DWARF5 Experimental Options /// @{ bool HasDwarfAccelTables; @@ -501,6 +504,9 @@ public: /// Returns whether to use inline strings. bool useInlineStrings() const { return UseInlineStrings; } + /// Returns whether GNU oub sections should be emitted. + bool usePubSections() const { return UsePubSections; } + // Experimental DWARF5 features. /// Returns whether or not to emit tables that dwarf consumers can diff --git a/llvm/test/DebugInfo/X86/no-public-sections.ll b/llvm/test/DebugInfo/X86/no-public-sections.ll new file mode 100644 index 00000000000..75fbd398acd --- /dev/null +++ b/llvm/test/DebugInfo/X86/no-public-sections.ll @@ -0,0 +1,31 @@ +; RUN: llc -mtriple=x86_64-pc-linux-gnu -debugger-tune=gdb -filetype=asm < %s -no-dwarf-pub-sections | FileCheck %s --check-prefix=DISABLED +; RUN: llc -mtriple=x86_64-pc-linux-gnu -debugger-tune=gdb -filetype=asm < %s | FileCheck %s + +; DISABLED-NOT: {{.debug_pubnames|.debug_pubtypes}} +; CHECK-DAG: .section .debug_pubnames +; CHECK-DAG: .section .debug_pubtypes + +%struct.bar = type { %"struct.ns::foo" } +%"struct.ns::foo" = type { i8 } + +@b = global %struct.bar zeroinitializer, align 1, !dbg !0 + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!11, !12} +!llvm.ident = !{!13} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, gnuPubnames: false) +!3 = !DIFile(filename: "type.cpp", directory: "/tmp/dbginfo") +!4 = !{} +!5 = !{!0} +!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "bar", file: !3, line: 5, size: 8, elements: !7, identifier: "_ZTS3bar") +!7 = !{!8} +!8 = !DIDerivedType(tag: DW_TAG_member, name: "f", scope: !6, file: !3, line: 6, baseType: !9, size: 8) +!9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !10, file: !3, line: 2, size: 8, elements: !4, identifier: "_ZTSN2ns3fooE") +!10 = !DINamespace(name: "ns", scope: null) +!11 = !{i32 2, !"Dwarf Version", i32 4} +!12 = !{i32 2, !"Debug Info Version", i32 3} +!13 = !{!"clang"} + |

