diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -1083,6 +1083,9 @@ if (DumpOpts.Verbose) OS << format(" [%u] %c", abbrCode, AbbrevDecl->hasChildren() ? '*' : ' '); + if (Optional ParentIdx = Die->getParentIdx()) + OS << format(" (0x%8.8" PRIx64 ")", + U->getDIEAtIndex(*ParentIdx).getOffset()); OS << '\n'; // Dump all data in the DIE for the attributes. diff --git a/llvm/test/tools/llvm-dwarfdump/X86/parent_link.s b/llvm/test/tools/llvm-dwarfdump/X86/parent_link.s new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/X86/parent_link.s @@ -0,0 +1,40 @@ +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-dwarfdump -a %t.o | FileCheck %s + +# This test checks that llvm-dwarfdump prints link +# to the parent of the current die: + +# DW_TAG_base_type (0x0000000b) <<<<< + +# CHECK: .o: file format +# CHECK: 0x0000000b: DW_TAG_compile_unit +# CHECK: DW_TAG_base_type (0x0000000b) + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +DWARF: + debug_abbrev: + - Table: + - Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_producer + Form: DW_FORM_string + - Tag: DW_TAG_base_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_string + debug_info: + - Version: 4 + Entries: + - AbbrCode: 1 + Values: + - CStr: by_hand + - AbbrCode: 2 + Values: + - CStr: int diff --git a/llvm/test/tools/llvm-dwarfdump/X86/verbose.test b/llvm/test/tools/llvm-dwarfdump/X86/verbose.test --- a/llvm/test/tools/llvm-dwarfdump/X86/verbose.test +++ b/llvm/test/tools/llvm-dwarfdump/X86/verbose.test @@ -7,9 +7,9 @@ # CHECK:.debug_info contents: # CHECK:0x0000000b: DW_TAG_compile_unit [1] * # CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "brief.c") -# CHECK:0x0000002a: DW_TAG_subprogram [2] +# CHECK:0x0000002a: DW_TAG_subprogram [2] (0x0000000b) # CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "main") -# CHECK:0x00000043: DW_TAG_base_type [3] +# CHECK:0x00000043: DW_TAG_base_type [3] (0x0000000b) # CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "int") # CHECK:.debug_line contents: