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

Petr Machata pmachata@redhat.com
Fri Nov 14 01:23:00 GMT 2014


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

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 != "" } {
-- 
2.1.0



More information about the Gdb-patches mailing list