From b9339f62977b4b55db70e9c739eadd1d48be244d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 24 Dec 2018 06:52:31 +0000 Subject: 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. --- llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp | 9 +-- .../tools/llvm-dwarfdump/X86/debug_info_addrx.s | 77 ++++++++++++++++++++++ 2 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp index b7b359878f9..7719fea6312 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -370,13 +370,14 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { case DW_FORM_addrx3: case DW_FORM_addrx4: case DW_FORM_GNU_addr_index: { - AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue); + Optional A = U->getAddrOffsetSectionItem(UValue); + if (!A || DumpOpts.Verbose) + AddrOS << format("indexed (%8.8x) address = ", (uint32_t)UValue); if (U == nullptr) OS << ""; - else if (Optional A = - U->getAddrOffsetSectionItem(UValue)) { + else if (A) dumpSectionedAddress(AddrOS, DumpOpts, *A); - } else + else OS << ""; break; } diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s new file mode 100644 index 00000000000..e0e468c9153 --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_addrx.s @@ -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 = ) +# VERBOSE: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address = ) + +# 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,"",@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,"",@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,"",@progbits + .byte 0 # End Of Macro List Mark + .section .debug_addr,"",@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 -- cgit v1.2.3