[llvm] r350046 - llvm-dwarfdump: Skip address index info (and dump only the address, if found) when non-verbose dumping addrx forms

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 23 22:52:31 PST 2018


Author: dblaikie
Date: Sun Dec 23 22:52:31 2018
New Revision: 350046

URL: http://llvm.org/viewvc/llvm-project?rev=350046&view=rev
Log:
llvm-dwarfdump: Skip address index info (and dump only the address, if found) when non-verbose dumping addrx forms

There's a few bugs here still - demonstrated with FIXITs in the test.

Added:
    llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp?rev=350046&r1=350045&r2=350046&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFFormValue.cpp Sun Dec 23 22:52:31 2018
@@ -370,13 +370,14 @@ void DWARFFormValue::dump(raw_ostream &O
   case DW_FORM_addrx3:
   case DW_FORM_addrx4:
   case DW_FORM_GNU_addr_index: {
-    AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);
+    Optional<SectionedAddress> A = U->getAddrOffsetSectionItem(UValue);
+    if (!A || DumpOpts.Verbose)
+      AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue);
     if (U == nullptr)
       OS << "<invalid dwarf unit>";
-    else if (Optional<SectionedAddress> A =
-                 U->getAddrOffsetSectionItem(UValue)) {
+    else if (A)
       dumpSectionedAddress(AddrOS, DumpOpts, *A);
-    } else
+    else
       OS << "<no .debug_addr section>";
     break;
   }

Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s?rev=350046&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s (added)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s Sun Dec 23 22:52:31 2018
@@ -0,0 +1,77 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
+# RUN: llvm-dwarfdump -debug-info %t.o | FileCheck %s
+# RUN: llvm-dwarfdump -debug-info %t.o -v | FileCheck --check-prefix=VERBOSE %s
+
+# CHECK: DW_TAG_compile_unit
+# CHECK:   DW_AT_low_pc                                              (0x0000000000000000)
+# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x0000000000000000 ".text")
+# FIXME: There is a debug_addr section, it's just that the index is outside its 
+#        bounds (both of the section, and the range defined by the header for the
+#        debug_addr contribution for this CU)
+# CHECK:   DW_AT_low_pc                 (indexed (00000001) address = <no .debug_addr section>)
+# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = <no .debug_addr section>)
+
+# CHECK: DW_TAG_compile_unit
+# FIXME: Should error "no debug_addr contribution" - rather than parsing debug_addr
+#        from the start, incorrectly interpreting the header bytes as an address.
+# CHECK:   DW_AT_low_pc                                              (0x000800050000000c)
+# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x000800050000000c)
+
+	.globl	foo                     # -- Begin function foo
+foo:                                    # @foo
+.Lfunc_begin0:
+	retq
+.Lfunc_end0:
+	.section	.debug_abbrev,"", at progbits
+	.byte	1                       # Abbreviation Code
+	.byte	17                      # DW_TAG_compile_unit
+	.byte	0                       # DW_CHILDREN_no
+	.byte	115                     # DW_AT_addr_base
+	.byte	23                      # DW_FORM_sec_offset
+	.byte	17                      # DW_AT_low_pc
+	.byte	27                      # DW_FORM_addrx
+	.byte	17                      # DW_AT_low_pc
+	.byte	27                      # DW_FORM_addrx
+	.byte	0                       # EOM(1)
+	.byte	0                       # EOM(2)
+	.byte	2                       # Abbreviation Code
+	.byte	17                      # DW_TAG_compile_unit
+	.byte	0                       # DW_CHILDREN_no
+	.byte	17                      # DW_AT_low_pc
+	.byte	27                      # DW_FORM_addrx
+	.byte	0                       # EOM(1)
+	.byte	0                       # EOM(2)
+	.byte	0                       # EOM(3)
+	.section	.debug_info,"", at progbits
+.Lcu_begin0:
+	.long	.Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+	.short	5                       # DWARF version number
+	.byte	1                       # DWARF Unit Type
+	.byte	8                       # Address Size (in bytes)
+	.long	.debug_abbrev           # Offset Into Abbrev. Section
+	.byte	1                       # Abbrev [1] 0xc:0x23 DW_TAG_compile_unit
+	.long	.Laddr_table_base0      # DW_AT_addr_base
+	.byte	0                       # DW_AT_low_pc
+	.byte	1                       # DW_AT_low_pc
+.Ldebug_info_end0:
+.Lcu_begin1:
+	.long	.Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit
+.Ldebug_info_start1:
+	.short	5                       # DWARF version number
+	.byte	1                       # DWARF Unit Type
+	.byte	8                       # Address Size (in bytes)
+	.long	.debug_abbrev           # Offset Into Abbrev. Section
+	.byte	2                       # Abbrev [2] 0xc:0x23 DW_TAG_compile_unit
+	.long	.Laddr_table_base0      # DW_AT_addr_base
+	.byte	0                       # DW_AT_low_pc
+.Ldebug_info_end1:
+	.section	.debug_macinfo,"", at progbits
+	.byte	0                       # End Of Macro List Mark
+	.section	.debug_addr,"", at progbits
+	.long	12                      # Length of Pool
+	.short	5                       # DWARF version number
+	.byte	8                       # Address Size (in bytes)
+	.byte	0                       # Segment selector size
+.Laddr_table_base0:
+	.quad	.Lfunc_begin0




More information about the llvm-commits mailing list