[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

llvm-svn: 319044
This commit is contained in:
Jonas Devlieghere 2017-11-27 16:40:46 +00:00
parent 4ca9968155
commit 6a9c5929d4
5 changed files with 30 additions and 17 deletions
llvm
lib/DebugInfo/DWARF
test/tools

View File

@ -234,9 +234,17 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die,
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);

View File

@ -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 3.7.0 ")
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

View File

@ -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_

View File

@ -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)

View File

@ -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