dwarf.exp: In 64-bit units, emit also abbrev offset as a 64-bit field

Message ID m2egt6h8xo.fsf@redhat.com
State New, archived
Headers

Commit Message

Petr Machata Nov. 14, 2014, 1:23 a.m. UTC
  Hi there,

playing with dwarf.exp I noticed a problem in generating Dwarf
compilation and type units with 64-bit offsets.  This patch fixes the
problem.  "make check" reports no regressions.

I don't have commit priviliges, so if this patch is acceptable, I'll
need someone else to commit this for me.

Thanks,
Petr

----8<----------------------------------------------------------------
Dwarf::tu and Dwarf::cu allow selection of units with 64-bit offsets
through an option.  When selected, unit size is encoded properly, but
offset to abbreviation unit is still encoded in a 4-byte field.

Reproducer:

Dwarf::assemble "blah.s" {
    tu {is_64 1 version 4 addr_size 8} 0x1122334455667788 the_type {
	type_unit {} { the_type: }
    }

    cu {is_64 1 version 4 addr_size 8} {
	compile_unit {{language @DW_LANG_C}} {}
    }
}

Signed-off-by: Petr Machata <pmachata@redhat.com>
---
 gdb/testsuite/ChangeLog     | 5 +++++
 gdb/testsuite/lib/dwarf.exp | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
  

Comments

Yao Qi Nov. 15, 2014, 9:02 a.m. UTC | #1
Petr Machata <pmachata@redhat.com> writes:

> I don't have commit priviliges, so if this patch is acceptable, I'll
> need someone else to commit this for me.

The patch looks good to me.

> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 1edfc93..7f714a9 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2014-11-14  Petr Machata  <pmachata@redhat.com>
> +
> +	* lib/dwarf.exp (Dwarf::cu, Dwarf::tu): In units with 64-bit
> +	offsets, emit also abbrev offset as a 64-bit field.

Your changelog entry doesn't describe what the change is.  How about this?

	* lib/dwarf.exp (Dwarf::cu, Dwarf::tu): Emit
        ${_cu_offset_size} bytes abbrev offset.

I'll commit the patch for you if you are happy with the updated changelog.
  
Petr Machata Nov. 15, 2014, 7:22 p.m. UTC | #2
Yao Qi <yao@codesourcery.com> writes:

>> +2014-11-14  Petr Machata  <pmachata@redhat.com>
>> +
>> +	* lib/dwarf.exp (Dwarf::cu, Dwarf::tu): In units with 64-bit
>> +	offsets, emit also abbrev offset as a 64-bit field.
>
> Your changelog entry doesn't describe what the change is.  How about this?
>
> 	* lib/dwarf.exp (Dwarf::cu, Dwarf::tu): Emit
>         ${_cu_offset_size} bytes abbrev offset.
>
> I'll commit the patch for you if you are happy with the updated changelog.

I am.

Thanks,
Petr
  

Patch

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1edfc93..7f714a9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2014-11-14  Petr Machata  <pmachata@redhat.com>
+
+	* lib/dwarf.exp (Dwarf::cu, Dwarf::tu): In units with 64-bit
+	offsets, emit also abbrev offset as a 64-bit field.
+
 2013-10-21  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
 	PR gdb/15986
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index c28b986..ba734ab 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -820,7 +820,7 @@  namespace eval Dwarf {
 	}
 	define_label $start_label
 	_op .2byte $_cu_version Version
-	_op .4byte $my_abbrevs Abbrevs
+	_op .${_cu_offset_size}byte $my_abbrevs Abbrevs
 	_op .byte $_cu_addr_size "Pointer size"
 
 	_defer_output $_abbrev_section {
@@ -913,7 +913,7 @@  namespace eval Dwarf {
 	}
 	define_label $start_label
 	_op .2byte $_cu_version Version
-	_op .4byte $my_abbrevs Abbrevs
+	_op .${_cu_offset_size}byte $my_abbrevs Abbrevs
 	_op .byte $_cu_addr_size "Pointer size"
 	_op .8byte $signature Signature
 	if { $type_label != "" } {