[dwarfdump] Only print CU relative offset in verbose mode

Instead of only printing the CU-relative offset in non-verbose mode, it
makes more sense to only printed the resolved address. In verbose mode
we still print both.

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

rdar://33525475

llvm-svn: 326903
This commit is contained in:
Jonas Devlieghere 2018-03-07 16:28:53 +00:00
parent e12a48bcc0
commit bf8596f9cf
8 changed files with 77 additions and 70 deletions

View File

@ -538,22 +538,27 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
break;
case DW_FORM_ref1:
CURelativeOffset = true;
if (DumpOpts.Verbose)
AddrOS << format("cu + 0x%2.2x", (uint8_t)UValue);
break;
case DW_FORM_ref2:
CURelativeOffset = true;
if (DumpOpts.Verbose)
AddrOS << format("cu + 0x%4.4x", (uint16_t)UValue);
break;
case DW_FORM_ref4:
CURelativeOffset = true;
if (DumpOpts.Verbose)
AddrOS << format("cu + 0x%4.4x", (uint32_t)UValue);
break;
case DW_FORM_ref8:
CURelativeOffset = true;
if (DumpOpts.Verbose)
AddrOS << format("cu + 0x%8.8" PRIx64, UValue);
break;
case DW_FORM_ref_udata:
CURelativeOffset = true;
if (DumpOpts.Verbose)
AddrOS << format("cu + 0x%" PRIx64, UValue);
break;
case DW_FORM_GNU_ref_alt:
@ -576,10 +581,12 @@ void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
break;
}
if (CURelativeOffset && DumpOpts.Verbose) {
if (CURelativeOffset) {
if (DumpOpts.Verbose)
OS << " => {";
WithColor(OS, syntax::Address).get()
<< format("0x%8.8" PRIx64, UValue + (U ? U->getOffset() : 0));
if (DumpOpts.Verbose)
OS << "}";
}
}

View File

@ -8,7 +8,7 @@
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type {{.*}}"sizetype"
; CHECK-NEXT: DW_AT_count (cu + 0x0[[VLAEXPR]])
; CHECK-NEXT: DW_AT_count (0x00000[[VLAEXPR]]
;
;
; Generated from (and then modified):

View File

@ -2,11 +2,11 @@
; CHECK: 0x00000[[G:.*]]: DW_TAG_variable
; CHECK-NEXT: DW_AT_name ("g")
; CHECK: DW_TAG_array_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "int")
; CHECK-NEXT: DW_AT_type ({{.*}} "int")
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + 0x0[[G]])
; CHECK-NEXT: DW_AT_type ({{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x00000[[G]])
; Test that a VLA referring to a global variable is handled correctly.
; Clang doesn't generate this, but the verifier allows it.
source_filename = "/tmp/test.c"

View File

@ -8,41 +8,41 @@
;}
;
; CHECK: DW_TAG_array_type
; CHECK-NEXT: DW_AT_type (cu + 0x00f8 "int")
; CHECK-NEXT: DW_AT_type (0x000000f8 "int")
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}}"sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}}"sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK: DW_TAG_array_type
; CHECK-NEXT: DW_AT_type (cu + 0x00f8 "int")
; CHECK-NEXT: DW_AT_type (0x000000f8 "int")
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}}"sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}}"sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
; CHECK-NOT: TAG
; CHECK: DW_TAG_subrange_type
; CHECK-NEXT: DW_AT_type (cu + {{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (cu + {{.*}})
; CHECK-NEXT: DW_AT_type (0x{{.*}} "sizetype")
; CHECK-NEXT: DW_AT_count (0x{{.*}})
source_filename = "/tmp/test.c"

View File

@ -26,7 +26,7 @@ CHECK: DW_AT_name ("main")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_prototyped (0x01)
CHECK: DW_AT_type (cu + 0x0063
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_external (0x01)
CHECK: DW_AT_accessibility (DW_ACCESS_public)
CHECK: DW_AT_low_pc (0x0000000100000ea0)
@ -36,13 +36,13 @@ CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argc")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_type (cu + 0x0063
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_location (DW_OP_fbreg -8)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argv")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_type (cu + 0x006a
CHECK: DW_AT_type (0x0000006a
CHECK: DW_AT_location (DW_OP_fbreg -16)
CHECK: NULL
CHECK: DW_TAG_base_type
@ -50,11 +50,11 @@ CHECK: DW_AT_name ("int")
CHECK: DW_AT_encoding (DW_ATE_signed)
CHECK: DW_AT_byte_size (0x04)
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (cu + 0x006f
CHECK: DW_AT_type (0x0000006f
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (cu + 0x0074
CHECK: DW_AT_type (0x00000074
CHECK: DW_TAG_const_type
CHECK: DW_AT_type (cu + 0x0079
CHECK: DW_AT_type (0x00000079
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("char")
CHECK: DW_AT_encoding (DW_ATE_signed_char)
@ -73,30 +73,30 @@ CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("private_int")
CHECK: DW_AT_type (cu + 0x0026
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
BASIC: DW_AT_location (DW_OP_addr 0x100001008)
ARCHIVE: DW_AT_location (DW_OP_addr 0x100001004)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("baz")
CHECK: DW_AT_type (cu + 0x0026
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001000)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("foo")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_type (cu + 0x0026
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_low_pc (0x0000000100000ed0)
CHECK: DW_AT_high_pc (0x0000000100000f19)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (cu + 0x0026
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_location (DW_OP_fbreg -4)
CHECK: NULL
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (cu + 0x0026
CHECK: DW_AT_type (0x000000a7
CHECK: DW_AT_low_pc (0x0000000100000f20)
CHECK: DW_AT_high_pc (0x0000000100000f37)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
@ -112,28 +112,28 @@ CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("val")
CHECK: DW_AT_type (cu + 0x003c
CHECK: DW_AT_type (0x00000162
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c")
BASIC: DW_AT_location (DW_OP_addr 0x100001004)
ARCHIVE: DW_AT_location (DW_OP_addr 0x100001008)
CHECK: DW_TAG_volatile_type
CHECK: DW_AT_type (cu + 0x0041
CHECK: DW_AT_type (0x00000167
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("int")
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("bar")
CHECK: DW_AT_type (cu + 0x0041
CHECK: DW_AT_type (0x00000167
CHECK: DW_AT_low_pc (0x0000000100000f40)
CHECK: DW_AT_high_pc (0x0000000100000f84)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (cu + 0x0041
CHECK: DW_AT_type (0x00000167
CHECK: DW_AT_location (DW_OP_fbreg -8)
CHECK: NULL
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (cu + 0x0041
CHECK: DW_AT_type (0x00000167
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_AT_high_pc (0x0000000100000fa9)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)

View File

@ -30,10 +30,10 @@ CHECK: DW_AT_type (0x00000000000000a1
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_location (DW_OP_reg4 RSI)
CHECK: DW_AT_name ("argv")
CHECK: DW_AT_type (cu + 0x0060
CHECK: DW_AT_type (0x00000060
CHECK: NULL
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (cu + 0x0065
CHECK: DW_AT_type (0x00000065
CHECK: DW_TAG_pointer_type
CHECK: DW_TAG_const_type
CHECK: DW_TAG_base_type
@ -62,7 +62,7 @@ CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001008)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_name ("inc")
CHECK: DW_AT_type (cu + 0x002a
CHECK: DW_AT_type (0x000000a1
CHECK: DW_AT_inline (DW_INL_inlined)
CHECK: DW_TAG_subprogram
CHECK: DW_AT_low_pc (0x0000000100000f50)
@ -71,14 +71,14 @@ CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_AT_name ("foo")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c")
CHECK: DW_AT_prototyped (true)
CHECK: DW_AT_type (cu + 0x002a
CHECK: DW_AT_type (0x000000a1
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_location (0x00000000
CHECK: [0x0000000000000000, 0x000000000000000c): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name ("arg")
CHECK: DW_AT_type (cu + 0x002a
CHECK: DW_AT_type (0x000000a1
CHECK: DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (cu + 0x005b "inc")
CHECK: DW_AT_abstract_origin (0x000000d2 "inc")
CHECK: DW_AT_low_pc (0x0000000100000f61)
CHECK: DW_AT_high_pc (0x0000000100000f70)
CHECK: NULL
@ -111,7 +111,7 @@ CHECK: [0x0000000000000000, 0x000000000000000f): DW_OP_reg5 RDI, DW_OP_
CHECK: [0x0000000000000019, 0x000000000000001d): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_AT_name ("arg")
CHECK: DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (cu + 0x0044 "inc")
CHECK: DW_AT_abstract_origin (0x0000015f "inc")
CHECK: DW_AT_ranges (0x00000000
CHECK: [0x0000000100000f94, 0x0000000100000f9a)
CHECK: [0x0000000100000f9f, 0x0000000100000fa7))

View File

@ -19,7 +19,7 @@ CHECK: DW_AT_name ("main")
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c")
CHECK: DW_AT_decl_line (23)
CHECK: DW_AT_prototyped (0x01)
CHECK: DW_AT_type (cu + 0x0063
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_external (0x01)
CHECK: DW_AT_accessibility (DW_ACCESS_public)
CHECK: DW_AT_low_pc (0x0000000100000f40)
@ -27,11 +27,11 @@ CHECK: DW_AT_high_pc (0x0000000100000f4b)
CHECK: DW_AT_frame_base (DW_OP_reg6 RBP)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argc")
CHECK: DW_AT_type (cu + 0x0063
CHECK: DW_AT_type (0x00000063
CHECK: DW_AT_location (DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK: DW_TAG_formal_parameter
CHECK: DW_AT_name ("argv")
CHECK: DW_AT_type (cu + 0x006a
CHECK: DW_AT_type (0x0000006a
CHECK: DW_AT_location (DW_OP_reg4 RSI)
CHECK: NULL
CHECK: DW_TAG_base_type
@ -39,11 +39,11 @@ CHECK: DW_AT_name ("int")
CHECK: DW_AT_encoding (DW_ATE_signed)
CHECK: DW_AT_byte_size (0x04)
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (cu + 0x006f
CHECK: DW_AT_type (0x0000006f
CHECK: DW_TAG_pointer_type
CHECK: DW_AT_type (cu + 0x0074
CHECK: DW_AT_type (0x00000074
CHECK: DW_TAG_const_type
CHECK: DW_AT_type (cu + 0x0079
CHECK: DW_AT_type (0x00000079
CHECK: DW_TAG_base_type
CHECK: DW_AT_name ("char")
CHECK: DW_AT_encoding (DW_ATE_signed_char)
@ -79,7 +79,7 @@ CHECK: DW_AT_type (0x0000000000000063
CHECK: DW_AT_location (0x00000000
CHECK: [0x0000000000000000, 0x000000000000000e): DW_OP_reg5 RDI, DW_OP_piece 0x4)
CHECK:[[INC1:0x[0-9a-f]*]]{{.*}}DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (cu + 0x00a7 "inc")
CHECK: DW_AT_abstract_origin (0x00000128 "inc")
CHECK: DW_AT_low_pc (0x0000000100000f63)
CHECK: DW_AT_high_pc (0x0000000100000f72)
CHECK: DW_AT_call_line (20)
@ -100,7 +100,7 @@ CHECK: DW_AT_comp_dir ("/Inputs")
CHECK: DW_AT_low_pc (0x0000000100000f90)
CHECK: DW_TAG_variable
CHECK: DW_AT_name ("val")
CHECK: DW_AT_type (cu + 0x003c
CHECK: DW_AT_type (0x00000176
CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c")
CHECK: DW_AT_location (DW_OP_addr 0x100001004)
CHECK: DW_TAG_volatile_type
@ -121,7 +121,7 @@ CHECK: DW_TAG_lexical_block
CHECK: DW_AT_low_pc (0x0000000100000f94)
CHECK: DW_AT_high_pc (0x0000000100000fa7)
CHECK:[[INC2:0x[0-9a-f]*]]{{.*}}DW_TAG_inlined_subroutine
CHECK: DW_AT_abstract_origin (cu + 0x009a "inc")
CHECK: DW_AT_abstract_origin (0x000001d4 "inc")
CHECK: DW_AT_ranges (0x00000000
CHECK: [0x0000000100000f94, 0x0000000100000f9a)
CHECK: [0x0000000100000f9f, 0x0000000100000fa7))

View File

@ -12,7 +12,7 @@
# CHECK: DW_TAG_GNU_call_site
# CHECK-NEXT: DW_AT_low_pc (0x0000000000000000)
# CHECK-NEXT: DW_AT_abstract_origin (cu + 0x0021 "test")
# CHECK-NEXT: DW_AT_abstract_origin (0x00000021 "test")
# CHECK: DW_TAG_GNU_call_site_parameter
# CHECK-NEXT: DW_AT_location (DW_OP_reg0 EAX)