[PATCH] D87017: [DebugInfo] Fix emitting DWARF64 .debug_str_offsets sections (10/19).

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 06:22:42 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: dblaikie, jhenderson, probinson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added subscribers: ormris, hiraditya.
ikudrin requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

The patch fixes calculating the size of the table and emitting the unit length field.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87017

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
  llvm/test/DebugInfo/X86/debug-str-offsets-dwarf64.ll


Index: llvm/test/DebugInfo/X86/debug-str-offsets-dwarf64.ll
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-str-offsets-dwarf64.ll
@@ -0,0 +1,46 @@
+; This checks that .debug_str_offsets can be generated in the DWARF64 format.
+
+; RUN: llc -mtriple=x86_64 -dwarf-version=5 -dwarf64 -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-info -debug-str -debug-str-offsets -v %t | \
+; RUN:   FileCheck %s
+
+; CHECK:      .debug_info contents:
+; CHECK-NEXT: Compile Unit: {{.*}}, format = DWARF64,
+; CHECK:      DW_TAG_compile_unit [1] *
+; CHECK:        DW_AT_producer [DW_FORM_strx1] (indexed (00000000) string = "Manual")
+; CHECK:        DW_AT_name [DW_FORM_strx1] (indexed (00000001) string = "foo.c")
+; CHECK:        DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x0000000000000010)
+; CHECK:        DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000002) string = "/tmp")
+; CHECK:      DW_TAG_variable [2]  
+; CHECK:        DW_AT_name [DW_FORM_strx1] (indexed (00000003) string = "foo")
+; CHECK:      DW_TAG_base_type [3]  
+; CHECK:        DW_AT_name [DW_FORM_strx1] (indexed (00000004) string = "int")
+
+; CHECK:      .debug_str contents:
+; CHECK-NEXT: 0x00000000: "Manual"
+; CHECK-NEXT: 0x00000007: "foo.c"
+; CHECK-NEXT: 0x0000000d: "/tmp"
+; CHECK-NEXT: 0x00000012: "foo"
+; CHECK-NEXT: 0x00000016: "int"
+
+; CHECK:      .debug_str_offsets contents:
+; CHECK-NEXT: 0x00000000: Contribution size = 44, Format = DWARF64, Version = 5
+; CHECK-NEXT: 0x00000010: 0000000000000000 "Manual"
+; CHECK-NEXT: 0x00000018: 0000000000000007 "foo.c"
+; CHECK-NEXT: 0x00000020: 000000000000000d "/tmp"
+; CHECK-NEXT: 0x00000028: 0000000000000012 "foo"
+; CHECK-NEXT: 0x00000030: 0000000000000016 "int"
+
+ at foo = common dso_local global i32 0, align 4, !dbg !5
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !DIFile(filename: "foo.c", directory: "/tmp")
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Manual", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !{}
+!4 = !{!5}
+!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+!6 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true)
+!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
@@ -58,13 +58,13 @@
   if (getNumIndexedStrings() == 0)
     return;
   Asm.OutStreamer->SwitchSection(Section);
-  unsigned EntrySize = 4;
-  // FIXME: DWARF64
+  unsigned EntrySize = Asm.getDwarfOffsetByteSize();
   // We are emitting the header for a contribution to the string offsets
   // table. The header consists of an entry with the contribution's
   // size (not including the size of the length field), the DWARF version and
   // 2 bytes of padding.
-  Asm.emitInt32(getNumIndexedStrings() * EntrySize + 4);
+  Asm.emitDwarfUnitLength(getNumIndexedStrings() * EntrySize + 4,
+                          "Length of String Offsets Set");
   Asm.emitInt16(Asm.getDwarfVersion());
   Asm.emitInt16(0);
   // Define the symbol that marks the start of the contribution. It is


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87017.289421.patch
Type: text/x-patch
Size: 3484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200902/629bf61f/attachment.bin>


More information about the llvm-commits mailing list