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

Tom de Vries tdevries@suse.de
Tue May 12 07:47:53 GMT 2020


Hi,

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.

Committed to trunk.

Thanks,
- Tom

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

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.

---
 gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp         | 10 ++++++++--
 gdb/testsuite/gdb.dwarf2/data-loc.exp               | 14 ++++++--------
 gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp |  9 ++++++---
 gdb/testsuite/gdb.dwarf2/implref-struct.exp         | 10 ++++++----
 gdb/testsuite/gdb.dwarf2/varval.exp                 |  9 ++++-----
 5 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp b/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
index a27678b3a4..8ff6b733cc 100644
--- a/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
+++ b/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
@@ -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\\+\\+"
diff --git a/gdb/testsuite/gdb.dwarf2/data-loc.exp b/gdb/testsuite/gdb.dwarf2/data-loc.exp
index 5fde07472a..de21dffa1e 100644
--- a/gdb/testsuite/gdb.dwarf2/data-loc.exp
+++ b/gdb/testsuite/gdb.dwarf2/data-loc.exp
@@ -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"
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp
index 8ff08afb06..8b51de0d39 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp
@@ -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"
diff --git a/gdb/testsuite/gdb.dwarf2/implref-struct.exp b/gdb/testsuite/gdb.dwarf2/implref-struct.exp
index b7f1f16fec..b00408b408 100644
--- a/gdb/testsuite/gdb.dwarf2/implref-struct.exp
+++ b/gdb/testsuite/gdb.dwarf2/implref-struct.exp
@@ -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"
+    }
 }
diff --git a/gdb/testsuite/gdb.dwarf2/varval.exp b/gdb/testsuite/gdb.dwarf2/varval.exp
index 8a05a4e046..876725be62 100644
--- a/gdb/testsuite/gdb.dwarf2/varval.exp
+++ b/gdb/testsuite/gdb.dwarf2/varval.exp
@@ -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}


More information about the Gdb-patches mailing list