[PATCH] D101255: [DebugInfo][llvm-dwarfdump] Fix dumping of unit header with DW_UT_partial type

Alok Kumar Sharma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 25 07:51:03 PDT 2021


alok created this revision.
alok added reviewers: jmorse, aprantl, jini.susan, SouraVX, bhuvanendrakumarn.
alok added a project: debug-info.
Herald added subscribers: pengfei, hiraditya.
alok requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

  Currently llvm-dwarfdump crashes for Unit header with DW_UT_partial type.
  -------------
  llvm-dwarfdump: /tmp/llvm/include/llvm/ADT/Optional.h:197: T& llvm::optional_detail::OptionalStorage<T, true>::getValue() &
  [with T = long unsigned int]: Assertion `hasVal' failed.
  PLEASE submit a bug report to the technical support section of https://developer.amd.com/amd-aocc and include the crash backtrace.
  Stack dump:
  0.      Program arguments: llvm-dwarfdump -v /tmp/test/DebugInfo/X86/Output/dwarfdump-he
  ader.s.tmp.o
   #0 0x00007f37d5ad8838 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /tmp/llvm/lib/Support/Unix/Signals.inc:565:0
   #1 0x00007f37d5ad88ef PrintStackTraceSignalHandler(void*) /tmp/llvm/lib/Support/Unix/Signals.inc:632:0
   #2 0x00007f37d5ad65bd llvm::sys::RunSignalHandlers() /tmp/llvm/lib/Support/Signals.cpp:71:0
   #3 0x00007f37d5ad81b9 SignalHandler(int) /tmp/llvm/lib/Support/Unix/Signals.inc:407:0
   #4 0x00007f37d4c26040 (/lib/x86_64-linux-gnu/libc.so.6+0x3f040)
   #5 0x00007f37d4c25fb7 raise /build/glibc-S9d2JN/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
   #6 0x00007f37d4c27921 abort /build/glibc-S9d2JN/glibc-2.27/stdlib/abort.c:81:0
   #7 0x00007f37d4c1748a __assert_fail_base /build/glibc-S9d2JN/glibc-2.27/assert/assert.c:89:0
   #8 0x00007f37d4c17502 (/lib/x86_64-linux-gnu/libc.so.6+0x30502)
   #9 0x00007f37d7576b81 llvm::optional_detail::OptionalStorage<unsigned long, true>::getValue() & /tmp/llvm/include/llvm/ADT/Optional.h:198:0
   #10 0x00007f37d75726ac llvm::Optional<unsigned long>::operator*() && /tmp/llvm/include/llvm/ADT/Optional.h:309:0
   #11 0x00007f37d7582968 llvm::DWARFCompileUnit::dump(llvm::raw_ostream&, llvm::DIDumpOptions) /tmp/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp:30:0
  --------------

This was due to tool expecting DW_AT_dwo_id for DW_UT_partial type which should be expected only for DW_UT_skeleton and DW_UT_split_compile. This is fixed now.

Thanks to @jini.susan.george for providing the fix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101255

Files:
  llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
  llvm/test/DebugInfo/X86/dwarfdump-header.s


Index: llvm/test/DebugInfo/X86/dwarfdump-header.s
===================================================================
--- llvm/test/DebugInfo/X86/dwarfdump-header.s
+++ llvm/test/DebugInfo/X86/dwarfdump-header.s
@@ -59,6 +59,13 @@
         .byte 0x0e  # DW_FORM_strp
         .byte 0x00  # EOM(1)
         .byte 0x00  # EOM(2)
+        .byte 0x04  # Abbrev code
+        .byte 0x3c  # DW_TAG_compile_unit
+        .byte 0x00  # DW_CHILDREN_no
+        .byte 0x03  # DW_AT_name
+        .byte 0x0e  # DW_FORM_strp
+        .byte 0x00  # EOM(1)
+        .byte 0x00  # EOM(2)
         .byte 0x00  # EOM(3)
 
 # And a .dwo copy for the .dwo sections.
@@ -128,6 +135,22 @@
 # CHECK: 0x00000019: Compile Unit: length = 0x00000016, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000033)
 # CHECK: 0x00000025: DW_TAG_compile_unit
 
+# DWARF v5 CU header (Unit Type = DW_UT_partial).
+        .long  CU_5_partial_end-CU_5_partial_version  # Length of Unit
+CU_5_partial_version:
+        .short 5               # DWARF version number
+        .byte 3                # DWARF Unit Type
+        .byte 8                # Address Size (in bytes)
+        .long .debug_abbrev    # Offset Into Abbrev. Section
+# The partial-unit DIE, with DW_AT_name
+        .byte 4
+        .long str_CU_5
+        .byte 0 # NULL
+CU_5_partial_end:
+
+# CHECK: 0x00000033: Compile Unit: length = 0x0000000e, format = DWARF32, version = 0x0005, unit_type = DW_UT_partial, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000045)
+# CHECK: 0x0000003f: DW_TAG_partial_unit
+
         .section .debug_info.dwo,"e", at progbits
 # CHECK-LABEL: .debug_info.dwo
 
Index: llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
@@ -26,7 +26,8 @@
   if (!getAbbreviations())
     OS << " (invalid)";
   OS << ", addr_size = " << format("0x%02x", getAddressByteSize());
-  if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile)
+  if (getVersion() >= 5 && (getUnitType() == dwarf::DW_UT_skeleton ||
+                            getUnitType() == dwarf::DW_UT_split_compile))
     OS << ", DWO_id = " << format("0x%016" PRIx64, *getDWOId());
   OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset())
      << ")\n";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101255.340357.patch
Type: text/x-patch
Size: 2436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210425/8a15aab1/attachment.bin>


More information about the llvm-commits mailing list