[gdb/testsuite] Fix duplicate test-names in gdb.dwarf2
authorTom de Vries <tdevries@suse.de>
Tue, 12 May 2020 07:47:15 +0000 (09:47 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 12 May 2020 07:47:15 +0000 (09:47 +0200)
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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
gdb/testsuite/gdb.dwarf2/data-loc.exp
gdb/testsuite/gdb.dwarf2/dw2-bad-parameter-type.exp
gdb/testsuite/gdb.dwarf2/implref-struct.exp
gdb/testsuite/gdb.dwarf2/varval.exp

index 2817ebd2bf439a7ce7af7686986c59e118618230..53181b685a601c78326a14b4a87ff682905c36cd 100644 (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.
index a27678b3a446e5fc0bdd5425805ccbeb6ea10357..8ff6b733cc97e8282e3f27b19785bf1b9082748a 100644 (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\\+\\+"
index 5fde07472a0100e842ea34a08958283e21915ad4..de21dffa1e4ec9222f107cf5adfdfc9708d57f58 100644 (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"
 
index 8ff08afb0656c88cc4c5da227e51b05d9d82f053..8b51de0d398d7b79273c37272d6ad3716244c84d 100644 (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"
index b7f1f16feca20fdbec7a1528c945a79f587ef6ed..b00408b4089b400c7ffcc8908730dde6bb22b21f 100644 (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"
+    }
 }
index 8a05a4e046ecc0491a1881dd1ec7541cc7fa3b0d..876725be62f4d60cc4168c424ee223dab5babb7d 100644 (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}