gdb.dwarf2: Don't hardcode certain constants in Dwarf::assemble constructs

Two tests in gdb.dwarf2, data-loc.exp and dynarr-ptr.exp assume that
sizeof(int) is 4.  This patch looks up the integer size and uses this
constant for DW_AT_byte_size, DW_AT_lower_bound, and DW_AT_upper_bound.

I discovered this problem while looking at test results for this
msp430 multilib:

msp430-sim/-msim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either

It fixes the following set of failures:

FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr_tdef.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.three_ptr_tdef'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr_tdef.all'first
FAIL: gdb.dwarf2/dynarr-ptr.exp: print foo.five_ptr_tdef'first
FAIL: gdb.dwarf2/data-loc.exp: print foo.three
FAIL: gdb.dwarf2/data-loc.exp: print foo.three(1)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(1)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.three_tdef(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(4)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(5)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five(6)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(2)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(3)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(4)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(5)
FAIL: gdb.dwarf2/data-loc.exp: print foo.five_tdef(6)
FAIL: gdb.dwarf2/data-loc.exp: print foo__three
FAIL: gdb.dwarf2/data-loc.exp: print foo__three_tdef
FAIL: gdb.dwarf2/data-loc.exp: print foo__five
FAIL: gdb.dwarf2/data-loc.exp: print foo__five_tdef

As I recall, there are still (other) problems with msp430 multilibs
which don't use -mlarge.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Don't hardcode
	value associated with DW_AT_byte_size.
	* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Don't hardcode
	constants for DW_AT_byte_size, DW_AT_lower_bound, and
	DW_AT_upper_bound.
This commit is contained in:
Kevin Buettner 2015-10-29 21:53:51 -07:00
parent f01dcfd9a7
commit c6f0b406f5
3 changed files with 16 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2015-11-07 Kevin Buettner <kevinb@redhat.com>
* gdb.dwarf2/data-loc.exp (Dwarf::assemble): Don't hardcode
value associated with DW_AT_byte_size.
* gdb.dwarf2/dynarr-ptr.exp (Dwarf::assemble): Don't hardcode
constants for DW_AT_byte_size, DW_AT_lower_bound, and
DW_AT_upper_bound.
2015-11-07 Kevin Buettner <kevinb@redhat.com> 2015-11-07 Kevin Buettner <kevinb@redhat.com>
* lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc. * lib/gdb (gdb_target_symbol_prefix_flags_asm): New proc.

View File

@ -43,9 +43,10 @@ Dwarf::assemble $asm_file {
{DW_AT_comp_dir /tmp} {DW_AT_comp_dir /tmp}
} { } {
declare_labels integer_label array_label array_ptr_label declare_labels integer_label array_label array_ptr_label
set int_size [get_sizeof "int" 4]
integer_label: DW_TAG_base_type { integer_label: DW_TAG_base_type {
{DW_AT_byte_size 4 DW_FORM_sdata} {DW_AT_byte_size $int_size DW_FORM_sdata}
{DW_AT_encoding @DW_ATE_signed} {DW_AT_encoding @DW_ATE_signed}
{DW_AT_name integer} {DW_AT_name integer}
} }

View File

@ -45,9 +45,10 @@ Dwarf::assemble $asm_file {
declare_labels integer_label array_label array_ptr_label \ declare_labels integer_label array_label array_ptr_label \
array_typedef_label array_typedef_label
set ptr_size [get_sizeof "void *" 96] set ptr_size [get_sizeof "void *" 96]
set int_size [get_sizeof "int" 4]
integer_label: DW_TAG_base_type { integer_label: DW_TAG_base_type {
{DW_AT_byte_size 4 DW_FORM_sdata} {DW_AT_byte_size $int_size DW_FORM_sdata}
{DW_AT_encoding @DW_ATE_signed} {DW_AT_encoding @DW_ATE_signed}
{DW_AT_name integer} {DW_AT_name integer}
} }
@ -61,15 +62,15 @@ Dwarf::assemble $asm_file {
{DW_AT_type :$integer_label} {DW_AT_type :$integer_label}
{DW_AT_lower_bound { {DW_AT_lower_bound {
DW_OP_push_object_address DW_OP_push_object_address
DW_OP_lit8 DW_OP_const1u [expr {2 * $int_size}]
DW_OP_minus DW_OP_minus
DW_OP_deref_size 4 DW_OP_deref_size $int_size
} SPECIAL_expr} } SPECIAL_expr}
{DW_AT_upper_bound { {DW_AT_upper_bound {
DW_OP_push_object_address DW_OP_push_object_address
DW_OP_lit4 DW_OP_const1u $int_size
DW_OP_minus DW_OP_minus
DW_OP_deref_size 4 DW_OP_deref_size $int_size
} SPECIAL_expr} } SPECIAL_expr}
} }
} }