diff mbox

gdb.arch/amd64-entry-value-paramref.S: Fix DIE offsets

Message ID 047d7b675d880387a4051d23f744@google.com
State New
Headers show

Commit Message

Doug Evans Aug. 12, 2015, 9:33 p.m. UTC
Hi.

This patch has been failing for me (gdb internal error) for a very long  
time.
I just never did anything about it because it wasn't important enough,
but now's a good time to do a bit of test cleanup.

The problem here is that DIE offsets are relative to the start of the CU,
and if this test's .o is not the first .o linked then the current DIE  
offsets
will be wrong.  GDB will then crash on an internal error (*1) because
it can't find a partial DIE at an expected offset.

This patch restores a lot of the hardwired offsets,
which the test tried to change because some DWARF was manually
inserted into the generated output.
And for those DIEs that need to change just adds "+2" to
the designated offsets.

This patch also restores some sibling attributes to further minimize
differences from the generated output.
[I know the original compiler emitted these sibling attributes
because the original offsets (0x29, 0x39, etc.) aren't correct
without them.]

If you want to fix this by replacing all the label references with
DIEfoo - .Ldebug_info0 go for it, but this patch differs from
the generated file less.
Until then, I plan to check this in.

---

(*1): gdb obviously shouldn't internal-error on bad dwarf,
but that's a separate bug.

2015-08-12  Doug Evans  <dje@google.com>

	* gdb.arch/amd64-entry-value-paramref.S: Re-fixup DIE offsets, they're
	relative to the start of the CU.

  	.section	.debug_abbrev,"",@progbits
@@ -255,6 +258,8 @@ DIEfe:	.uleb128 0x10	# (DIE (0xfe) DW_TAG_pointer_type)
  	.uleb128 0x13	# (DW_FORM_ref4)
  	.uleb128 0x20	# (DW_AT_inline)
  	.uleb128 0xb	# (DW_FORM_data1)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
  	.byte	0
  	.byte	0
  	.uleb128 0x3	# (abbrev code)
@@ -310,6 +315,8 @@ DIEfe:	.uleb128 0x10	# (DIE (0xfe) DW_TAG_pointer_type)
  	.uleb128 0x18	# (DW_FORM_exprloc)
  	.uleb128 0x2117	# (DW_AT_GNU_all_call_sites)
  	.uleb128 0x19	# (DW_FORM_flag_present)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
  	.byte	0
  	.byte	0
  	.uleb128 0x8	# (abbrev code)
@@ -342,6 +349,8 @@ DIEfe:	.uleb128 0x10	# (DIE (0xfe) DW_TAG_pointer_type)
  	.uleb128 0x18	# (DW_FORM_exprloc)
  	.uleb128 0x2117	# (DW_AT_GNU_all_call_sites)
  	.uleb128 0x19	# (DW_FORM_flag_present)
+	.uleb128 0x1	# (DW_AT_sibling)
+	.uleb128 0x13	# (DW_FORM_ref4)
  	.byte	0
  	.byte	0
  	.uleb128 0xa	# (abbrev code)

Comments

Yao Qi Aug. 18, 2015, 9:44 a.m. UTC | #1
Doug Evans <dje@google.com> writes:

> 2015-08-12  Doug Evans  <dje@google.com>
>
> 	* gdb.arch/amd64-entry-value-paramref.S: Re-fixup DIE offsets, they're
> 	relative to the start of the CU.

This patch looks good to me.
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S  
b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S
index 7b1725d..bdf7ed1 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S
@@ -117,65 +117,68 @@  vv:
  	.long	.Ldebug_ranges0+0	# DW_AT_ranges
  	.quad	0	# DW_AT_low_pc
  	.long	.Ldebug_line0	# DW_AT_stmt_list
-DIE29:	.uleb128 0x2	# (DIE (0x29) DW_TAG_subprogram)
+	.uleb128 0x2	# (DIE (0x29) DW_TAG_subprogram)
  	.ascii "bar\0"	# DW_AT_name
  	.byte	0x1	# DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
  	.byte	0x15	# DW_AT_decl_line
-	.long	DIE45	# DW_AT_type
+	.long	0x45	# DW_AT_type
  	.byte	0x1	# DW_AT_inline
-DIE39:	.uleb128 0x3	# (DIE (0x39) DW_TAG_formal_parameter)
+	.long	0x45	# DW_AT_sibling
+	.uleb128 0x3	# (DIE (0x39) DW_TAG_formal_parameter)
  	.ascii "ref\0"	# DW_AT_name
  	.byte	0x1	# DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
  	.byte	0x15	# DW_AT_decl_line
-	.long	DIE4c	# DW_AT_type
+	.long	0x4c	# DW_AT_type
  	.byte	0	# end of children of DIE 0x29
-DIE45:	.uleb128 0x4	# (DIE (0x45) DW_TAG_base_type)
+	.uleb128 0x4	# (DIE (0x45) DW_TAG_base_type)
  	.byte	0x4	# DW_AT_byte_size
  	.byte	0x5	# DW_AT_encoding
  	.ascii "int\0"	# DW_AT_name
-DIE4c:	.uleb128 0x5	# (DIE (0x4c) DW_TAG_const_type)
-	.long	DIE51	# DW_AT_type
-DIE51:	.uleb128 0x6	# (DIE (0x51) DW_TAG_reference_type)
+	.uleb128 0x5	# (DIE (0x4c) DW_TAG_const_type)
+	.long	0x51	# DW_AT_type
+	.uleb128 0x6	# (DIE (0x51) DW_TAG_reference_type)
  	.byte	0x8	# DW_AT_byte_size
-	.long	DIE45	# DW_AT_type
-DIE57:	.uleb128 0x7	# (DIE (0x57) DW_TAG_subprogram)
-	.long	DIE29	# DW_AT_abstract_origin
+	.long	0x45	# DW_AT_type
+	.uleb128 0x7	# (DIE (0x57) DW_TAG_subprogram)
+	.long	0x29	# DW_AT_abstract_origin
  	.quad	.LFB2	# DW_AT_low_pc
  	.quad	.LFE2-.LFB2	# DW_AT_high_pc
  	.uleb128 0x1	# DW_AT_frame_base
  	.byte	0x9c	# DW_OP_call_frame_cfa
  			# DW_AT_GNU_all_call_sites
-DIE72:	.uleb128 0x8	# (DIE (0x72) DW_TAG_formal_parameter)
-	.long	DIE39	# DW_AT_abstract_origin
+	.long	0x7a	# DW_AT_sibling
+	.uleb128 0x8	# (DIE (0x72) DW_TAG_formal_parameter)
+	.long	0x39	# DW_AT_abstract_origin
  	.uleb128 0x1	# DW_AT_location
  	.byte	0x55	# DW_OP_reg5
  	.byte	0	# end of children of DIE 0x57
-DIE7a:	.uleb128 0x9	# (DIE (0x7a) DW_TAG_subprogram)
+	.uleb128 0x9	# (DIE (0x7a) DW_TAG_subprogram)
  			# DW_AT_external
  	.long	.LASF3	# DW_AT_name: "main"
  	.byte	0x1	# DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
  	.byte	0x1d	# DW_AT_decl_line
-	.long	DIE45	# DW_AT_type
+	.long	0x45	# DW_AT_type
  	.quad	.LFB1	# DW_AT_low_pc
  	.quad	.LFE1-.LFB1	# DW_AT_high_pc
  	.uleb128 0x1	# DW_AT_frame_base
  	.byte	0x9c	# DW_OP_call_frame_cfa
  			# DW_AT_GNU_all_call_sites
-DIE9b:	.uleb128 0xa	# (DIE (0x9b) DW_TAG_lexical_block)
+	.long	0xd2	# DW_AT_sibling
+	.uleb128 0xa	# (DIE (0x9b) DW_TAG_lexical_block)
  	.quad	.LBB2	# DW_AT_low_pc
  	.quad	.LBE2-.LBB2	# DW_AT_high_pc
-DIEac:	.uleb128 0xb	# (DIE (0xac) DW_TAG_variable)
+	.uleb128 0xb	# (DIE (0xac) DW_TAG_variable)
  	.ascii "var\0"	# DW_AT_name
  	.byte	0x1	# DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
  	.byte	0x1f	# DW_AT_decl_line
-	.long	DIE45	# DW_AT_type
+	.long	0x45	# DW_AT_type
  	.uleb128 0x2	# DW_AT_location
  	.byte	0x91	# DW_OP_fbreg
  	.sleb128 -12
-DIEba:	.uleb128 0xc	# (DIE (0xba) DW_TAG_GNU_call_site)
+	.uleb128 0xc	# (DIE (0xba) DW_TAG_GNU_call_site)
  	.quad	.LVL1	# DW_AT_low_pc
-	.long	DIE57	# DW_AT_abstract_origin
-DIEc7:	.uleb128 0xd	# (DIE (0xc7) DW_TAG_GNU_call_site_parameter)
+	.long	0x57	# DW_AT_abstract_origin
+	.uleb128 0xd	# (DIE (0xc7) DW_TAG_GNU_call_site_parameter)
  	.uleb128 0x1	# DW_AT_location
  	.byte	0x55	# DW_OP_reg5
  	.uleb128 0x2	# DW_AT_GNU_call_site_value
@@ -196,29 +199,29 @@  DIEc7:	.uleb128 0xd	# (DIE (0xc7)  
DW_TAG_GNU_call_site_parameter)
  	.byte	0	# end of children of DIE 0xba
  	.byte	0	# end of children of DIE 0x9b
  	.byte	0	# end of children of DIE 0x7a
-DIEd2:	.uleb128 0xe	# (DIE (0xd2) DW_TAG_variable)
+	.uleb128 0xe	# (DIE (0xd2+2) DW_TAG_variable)
  	.ascii "vv\0"	# DW_AT_name
  	.byte	0x1	# DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
  	.byte	0x12	# DW_AT_decl_line
-	.long	DIEe6	# DW_AT_type
+	.long	0xe6+2	# DW_AT_type
  			# DW_AT_external
  	.uleb128 0x9	# DW_AT_location
  	.byte	0x3	# DW_OP_addr
  	.quad	vv
-DIEe6:	.uleb128 0xf	# (DIE (0xe6) DW_TAG_volatile_type)
-	.long	DIE45	# DW_AT_type
-DIEeb:	.uleb128 0xe	# (DIE (0xeb) DW_TAG_variable)
+	.uleb128 0xf	# (DIE (0xe6+2) DW_TAG_volatile_type)
+	.long	0x45	# DW_AT_type
+	.uleb128 0xe	# (DIE (0xeb+2) DW_TAG_variable)
  	.ascii "p\0"	# DW_AT_name
  	.byte	0x1	# DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
  	.byte	0x12	# DW_AT_decl_line
-	.long	DIEfe	# DW_AT_type
+	.long	0xfe+2	# DW_AT_type
  			# DW_AT_external
  	.uleb128 0x9	# DW_AT_location
  	.byte	0x3	# DW_OP_addr
  	.quad	p
-DIEfe:	.uleb128 0x10	# (DIE (0xfe) DW_TAG_pointer_type)
+	.uleb128 0x10	# (DIE (0xfe+2) DW_TAG_pointer_type)
  	.byte	0x8	# DW_AT_byte_size
-	.long	DIEe6	# DW_AT_type
+	.long	0xe6+2	# DW_AT_type
  	.byte	0	# end of children of DIE 0xb
  .Linfo_end: