[llvm] r319044 - [llvm-dwarfdump] Display DW_AT_high_pc as absolute value

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 08:40:46 PST 2017


Author: jdevlieghere
Date: Mon Nov 27 08:40:46 2017
New Revision: 319044

URL: http://llvm.org/viewvc/llvm-project?rev=319044&view=rev
Log:
[llvm-dwarfdump] Display DW_AT_high_pc as absolute value

DWARF4 relative DW_AT_high_pc values are now displayed as absolute
addresses. The relative value is only shown when explicitly dumping the
forms, i.e. in show-form or verbose mode.

```
DW_AT_low_pc	(0x0000000000000049)
DW_AT_high_pc	(0x00000019)
```

becomes

```
DW_AT_low_pc	(0x0000000000000049)
DW_AT_high_pc	(0x0000000000000062)
```

Differential revision: https://reviews.llvm.org/D40317

rdar://35416943

Modified:
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
    llvm/trunk/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test
    llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test
    llvm/trunk/test/tools/llvm-dwarfdump/X86/gnu_call_site.s
    llvm/trunk/test/tools/llvm-dwarfdump/X86/lookup.s

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=319044&r1=319043&r2=319044&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Mon Nov 27 08:40:46 2017
@@ -234,9 +234,17 @@ static void dumpAttribute(raw_ostream &O
     WithColor(OS, Color) << Name;
   else if (Attr == DW_AT_decl_line || Attr == DW_AT_call_line)
     OS << *formValue.getAsUnsignedConstant();
-  else if (Attr == DW_AT_location || Attr == DW_AT_frame_base ||
-           Attr == DW_AT_data_member_location ||
-           Attr == DW_AT_GNU_call_site_value)
+  else if (Attr == DW_AT_high_pc && !DumpOpts.ShowForm && !DumpOpts.Verbose &&
+           formValue.getAsUnsignedConstant()) {
+    // Print the actual address rather than the offset.
+    uint64_t LowPC, HighPC, Index;
+    if (Die.getLowAndHighPC(LowPC, HighPC, Index))
+      OS << format("0x%016" PRIx64, HighPC);
+    else
+      formValue.dump(OS, DumpOpts);
+  } else if (Attr == DW_AT_location || Attr == DW_AT_frame_base ||
+             Attr == DW_AT_data_member_location ||
+             Attr == DW_AT_GNU_call_site_value)
     dumpLocation(OS, formValue, U, sizeof(BaseIndent) + Indent + 4, DumpOpts);
   else
     formValue.dump(OS, DumpOpts);

Modified: llvm/trunk/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test?rev=319044&r1=319043&r2=319044&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test (original)
+++ llvm/trunk/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test Mon Nov 27 08:40:46 2017
@@ -12,10 +12,10 @@ CHECK:    DW_AT_name ("basic1.c")
 CHECK:    DW_AT_stmt_list (0x00000000)
 CHECK:    DW_AT_comp_dir ("/Inputs")
 CHECK:    DW_AT_low_pc (0x0000000100000f40)
-CHECK:    DW_AT_high_pc (0x0000000b)
+CHECK:    DW_AT_high_pc (0x0000000100000f4b)
 CHECK:    DW_TAG_subprogram
 CHECK:      DW_AT_low_pc (0x0000000100000f40)
-CHECK:      DW_AT_high_pc (0x0000000b)
+CHECK:      DW_AT_high_pc (0x0000000100000f4b)
 CHECK:      DW_AT_frame_base (DW_OP_reg6 RBP)
 CHECK:      DW_AT_name ("main")
 CHECK:      DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
@@ -50,7 +50,7 @@ CHECK:    DW_AT_language (DW_LANG_C99)
 CHECK:    DW_AT_name ("basic2.c")
 CHECK:    DW_AT_stmt_list (0x00000044)
 CHECK:    DW_AT_low_pc (0x0000000100000f50)
-CHECK:    DW_AT_high_pc (0x00000037)
+CHECK:    DW_AT_high_pc (0x0000000100000f87)
 CHECK:    DW_TAG_base_type
 CHECK:      DW_AT_name ("int")
 CHECK:    DW_TAG_variable
@@ -66,7 +66,7 @@ CHECK:      DW_AT_type (cu + 0x002a
 CHECK:      DW_AT_inline (DW_INL_inlined)
 CHECK:    DW_TAG_subprogram
 CHECK:      DW_AT_low_pc (0x0000000100000f50)
-CHECK:      DW_AT_high_pc (0x00000037)
+CHECK:      DW_AT_high_pc (0x0000000100000f87)
 CHECK:      DW_AT_frame_base (DW_OP_reg6 RBP)
 CHECK:      DW_AT_name ("foo")
 CHECK:      DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
@@ -80,7 +80,7 @@ CHECK:        DW_AT_type (cu + 0x002a
 CHECK:      DW_TAG_inlined_subroutine
 CHECK:        DW_AT_abstract_origin (cu + 0x005b "inc")
 CHECK:        DW_AT_low_pc (0x0000000100000f61)
-CHECK:        DW_AT_high_pc (0x0000000f)
+CHECK:        DW_AT_high_pc (0x0000000100000f70)
 CHECK:      NULL
 CHECK:    NULL
 
@@ -91,7 +91,7 @@ CHECK:    DW_AT_producer ("clang version
 CHECK:    DW_AT_name ("basic3.c")
 CHECK:    DW_AT_stmt_list (0x0000009a)
 CHECK:    DW_AT_low_pc (0x0000000100000f90)
-CHECK:    DW_AT_high_pc (0x00000024)
+CHECK:    DW_AT_high_pc (0x0000000100000fb4)
 CHECK:    DW_TAG_variable
 CHECK:      DW_AT_name ("val")
 CHECK:      DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c")
@@ -102,7 +102,7 @@ CHECK:      DW_AT_name ("inc")
 CHECK:      DW_AT_inline (DW_INL_inlined)
 CHECK:    DW_TAG_subprogram
 CHECK:      DW_AT_low_pc (0x0000000100000f90)
-CHECK:      DW_AT_high_pc (0x00000024)
+CHECK:      DW_AT_high_pc (0x0000000100000fb4)
 CHECK:      DW_AT_frame_base (DW_OP_reg6 RBP)
 CHECK:      DW_AT_name ("bar")
 CHECK:      DW_TAG_formal_parameter

Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test?rev=319044&r1=319043&r2=319044&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/form.test Mon Nov 27 08:40:46 2017
@@ -1,5 +1,6 @@
 # This test verifies that DWARF form types are printed in verbose mode and when
-# passing -F but not in brief mode.
+# passing -F but not in brief mode. Additionally we check that the high pc is
+# not printed as an address in verbose or show-form mode.
 
 # RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
 # RUN: | llvm-dwarfdump -v --debug-info - \
@@ -20,11 +21,11 @@
 # CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]
 # CHECK: DW_AT_comp_dir [DW_FORM_strp]
 # CHECK: DW_AT_low_pc [DW_FORM_addr]
-# CHECK: DW_AT_high_pc [DW_FORM_data4]
+# CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000008)
 
 # CHECK: DW_TAG_subprogram
 # CHECK: DW_AT_low_pc [DW_FORM_addr]
-# CHECK: DW_AT_high_pc [DW_FORM_data4]
+# CHECK: DW_AT_high_pc [DW_FORM_data4] (0x00000008)
 # CHECK: DW_AT_frame_base [DW_FORM_exprloc]
 # CHECK: DW_AT_name [DW_FORM_strp]
 # CHECK: DW_AT_decl_file [DW_FORM_data1]
@@ -38,3 +39,7 @@
 # CHECK: DW_AT_byte_size [DW_FORM_data1]
 
 # NO-FORM-NOT: DW_FORM_
+# NO-FORM: DW_AT_high_pc (0x0000000000000008)
+# NO-FORM-NOT: DW_FORM_
+# NO-FORM: DW_AT_high_pc (0x0000000000000008)
+# NO-FORM-NOT: DW_FORM_

Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/gnu_call_site.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/gnu_call_site.s?rev=319044&r1=319043&r2=319044&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/gnu_call_site.s (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/gnu_call_site.s Mon Nov 27 08:40:46 2017
@@ -6,7 +6,7 @@
 # CHECK-NEXT:   DW_AT_name      ("fn4")
 # CHECK-NEXT:   DW_AT_linkage_name      ("test")
 # CHECK-NEXT:   DW_AT_low_pc    (0x0000000000000000)
-# CHECK-NEXT:   DW_AT_high_pc   (0x00000000)
+# CHECK-NEXT:   DW_AT_high_pc   (0x0000000000000000)
 # CHECK-NEXT:   DW_AT_frame_base        (DW_OP_call_frame_cfa)
 # CHECK-NEXT:   DW_AT_GNU_all_call_sites        (true)
 

Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/lookup.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/lookup.s?rev=319044&r1=319043&r2=319044&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/lookup.s (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/lookup.s Mon Nov 27 08:40:46 2017
@@ -21,16 +21,16 @@
 # CHECK:   DW_AT_name        ("foo.c")
 # CHECK:   DW_AT_stmt_list   (0x00000000)
 # CHECK:   DW_AT_low_pc      (0x0000000000000000)
-# CHECK:   DW_AT_high_pc     (0x00000016)
+# CHECK:   DW_AT_high_pc     (0x0000000000000016)
 
 # CHECK: DW_TAG_subprogram
 # CHECK:     DW_AT_low_pc    (0x0000000000000000)
-# CHECK:     DW_AT_high_pc   (0x00000016)
+# CHECK:     DW_AT_high_pc   (0x0000000000000016)
 # CHECK:     DW_AT_name      ("foo")
 
 # LEX: DW_TAG_lexical_block
 # LEX:       DW_AT_low_pc  (0x0000000000000004)
-# LEX:       DW_AT_high_pc (0x00000010)
+# LEX:       DW_AT_high_pc (0x0000000000000014)
 
 # A: Line info: file 'foo.c', line 3, column 9, start line 1
 # B: Line info: file 'foo.c', line 4, column 6, start line 1




More information about the llvm-commits mailing list