[gdb/testsuite] Fix duplicate test-names in gdb.dwarf2

We currently have these duplicate test-names in gdb.dwarf2:
...
$ grep ^DUPLICATE: gdb.sum
DUPLICATE: gdb.dwarf2/comp-unit-lang.exp: show language
DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (int)"
DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (void *)"
DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (int)"
DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (int)"
DUPLICATE: gdb.dwarf2/data-loc.exp: ptype foo.array_type
DUPLICATE: gdb.dwarf2/varval.exp: get integer valueof "sizeof (int)"
DUPLICATE: gdb.dwarf2/varval.exp: get integer valueof "sizeof (void *)"
DUPLICATE: gdb.dwarf2/implref-struct.exp: print-object=off: \
  set print object off
DUPLICATE: gdb.dwarf2/implref-struct.exp: print-object=on: \
  set print object on
DUPLICATE: gdb.dwarf2/dw2-bad-parameter-type.exp: ptype f
...

Fix as appropriate.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-05-12  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/comp-unit-lang.exp: Use with_test_prefix.
	* gdb.dwarf2/dw2-bad-parameter-type.exp: Same.
	* gdb.dwarf2/implref-struct.exp: Same.
	* gdb.dwarf2/varval.exp: Ensure get_sizeof is called once per type.
	* gdb.dwarf2/data-loc.exp: Same.  Remove duplicate test.
This commit is contained in:
Tom de Vries 2020-05-12 09:47:15 +02:00
parent ebf470809e
commit 111b33f0b8
6 changed files with 38 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2020-05-12 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/comp-unit-lang.exp: Use with_test_prefix.
* gdb.dwarf2/dw2-bad-parameter-type.exp: Same.
* gdb.dwarf2/implref-struct.exp: Same.
* gdb.dwarf2/varval.exp: Ensure get_sizeof is called once per type.
* gdb.dwarf2/data-loc.exp: Same. Remove duplicate test.
2020-05-11 Simon Marchi <simon.marchi@polymtl.ca>
* gdb.base/jit-so.exp (one_jit_test): Change test name.

View File

@ -73,8 +73,14 @@ proc do_test {cu_lang gdb_lang} {
gdb_test "show language" "\"auto; currently $gdb_lang\".*"
}
proc do_test_with_prefix {cu_lang gdb_lang} {
with_test_prefix $gdb_lang {
do_test $cu_lang $gdb_lang
}
}
# Some paths in the debugger fall back to C. Check C++ as well to
# make sure the test doesn't happen to work because of such a
# fallback.
do_test DW_LANG_C "c"
do_test DW_LANG_C_plus_plus "c\\+\\+"
do_test_with_prefix DW_LANG_C "c"
do_test_with_prefix DW_LANG_C_plus_plus "c\\+\\+"

View File

@ -43,6 +43,7 @@ Dwarf::assemble $asm_file {
} {
declare_labels integer_label array_label array_ptr_label
set int_size [get_sizeof "int" 4]
set voidp_size [get_sizeof "void *" 96]
integer_label: DW_TAG_base_type {
{DW_AT_byte_size $int_size DW_FORM_sdata}
@ -63,16 +64,16 @@ Dwarf::assemble $asm_file {
{DW_AT_type :$integer_label}
{DW_AT_lower_bound {
DW_OP_push_object_address
DW_OP_plus_uconst [get_sizeof "void *" 96]
DW_OP_plus_uconst $voidp_size
DW_OP_deref
DW_OP_deref_size [get_sizeof "int" 4]
DW_OP_deref_size $int_size
} SPECIAL_expr}
{DW_AT_upper_bound {
DW_OP_push_object_address
DW_OP_plus_uconst [get_sizeof "void *" 96]
DW_OP_plus_uconst $voidp_size
DW_OP_deref
DW_OP_plus_uconst [get_sizeof "int" 4]
DW_OP_deref_size [get_sizeof "int" 4]
DW_OP_plus_uconst $int_size
DW_OP_deref_size $int_size
} SPECIAL_expr}
}
}
@ -226,9 +227,6 @@ gdb_test "print foo.five_tdef" \
gdb_test "ptype foo.five_tdef" \
"type = array \\(2 .. 6\\) of integer"
gdb_test "ptype foo.array_type" \
"type = array \\(<>\\) of integer"
gdb_test "print foo.five_tdef(2)" \
" = 5"

View File

@ -31,7 +31,10 @@ clean_restart $executable
# The first access (as we do not use -readnow) prints some:
# Dwarf Error: Cannot find DIE at 0x0 referenced from DIE at 0x29 [in module ...]
gdb_test "ptype f"
gdb_test "ptype f"
with_test_prefix "first" {
gdb_test "ptype f"
}
with_test_prefix "second" {
gdb_test "ptype f"
}
gdb_test "p 5" " = 5" "is alive"

View File

@ -177,9 +177,11 @@ foreach_with_prefix print-object {"off" "on"} {
# Test assignment through the synthetic reference.
gdb_test_no_output "set (ref = s2)"
foreach_with_prefix print-object {"off" "on"} {
gdb_test_no_output "set print object ${print-object}"
with_test_prefix "after assignment" {
foreach_with_prefix print-object {"off" "on"} {
gdb_test_no_output "set print object ${print-object}"
gdb_test "print ref" " = \\(S &\\) @${address}: \\{${s2_members}\\}" "print ref after assignment"
gdb_test "print s1" " = \\{${s2_members}\\}" "print s1 after assignment"
gdb_test "print ref" " = \\(S &\\) @${address}: \\{${s2_members}\\}" "print ref"
gdb_test "print s1" " = \\{${s2_members}\\}" "print s1"
}
}

View File

@ -38,6 +38,9 @@ set asm_file [standard_output_file ${srcfile2}]
if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
return -1
}
set int_size [get_sizeof "int" -1]
# gdb always assumes references are implemented as pointers.
set addr_size [get_sizeof "void *" -1]
proc setup_exec { arg_bad } {
global asm_file executable srcfile bad
@ -45,7 +48,7 @@ proc setup_exec { arg_bad } {
# Create the DWARF.
Dwarf::assemble ${asm_file} {
global srcdir subdir srcfile bad
global srcdir subdir srcfile bad int_size addr_size
cu {} {
DW_TAG_compile_unit {
@ -58,10 +61,6 @@ proc setup_exec { arg_bad } {
varval2_label varval3_def_label varval3_decl_label \
int_array_label int_array_of_1_label
set int_size [get_sizeof "int" -1]
# gdb always assumes references are implemented as pointers.
set addr_size [get_sizeof "void *" -1]
int_label: DW_TAG_base_type {
{DW_AT_byte_size ${int_size} DW_FORM_udata}