[committed][gdb/testsuite] Use $srcfile in DW_AT_name for CU

Tom de Vries tdevries@suse.de
Fri Oct 23 12:56:02 GMT 2020


Hi,

In dwarf assembly test-case ada-linkage-name.exp, we have:
...
standard_testfile .c -debug.S
  ...
  cu {} {
    DW_TAG_compile_unit {
      {DW_AT_name     ada-linkage-name.c}
...
Use $srcfile instead of ada-linkage-name.c.

In dwarf assembly test-case atomic-type.exp, we have:
...
standard_testfile .c -dw.S
  ...
  cu {} {
    DW_TAG_compile_unit {
      {DW_AT_name     atomic-type-dw.c}
...
The dwarf generated into atomic-type-dw.S is meant to represent the code in
atomic-type.c, not atomic-type-dw.c, so use $srcfile instead of
atomic-type-dw.c.

Fix these and similar.

Tested on x86_64-linux.

Committed to trunk.

Thanks,
- Tom

[gdb/testsuite] Use $srcfile in DW_AT_name for CU

gdb/testsuite/ChangeLog:

2020-10-23  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/ada-linkage-name.exp: Use $srcfile for DW_AT_name of CU.
	* gdb.dwarf2/atomic-type.exp: Same.
	* gdb.dwarf2/bad-regnum.exp: Same.
	* gdb.dwarf2/cpp-linkage-name.exp: Same.
	* gdb.dwarf2/dw2-align.exp: Same.
	* gdb.dwarf2/dw2-bad-elf.exp: Same.
	* gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Same.
	* gdb.dwarf2/dw2-bad-unresolved.exp: Same.
	* gdb.dwarf2/dw2-namespaceless-anonymous.exp: Same.
	* gdb.dwarf2/dw2-opt-structptr.exp: Same.
	* gdb.dwarf2/dw2-unusual-field-names.exp: Same.
	* gdb.dwarf2/enum-type.exp: Same.
	* gdb.dwarf2/frame-inlined-in-outer-frame.exp: Same.
	* gdb.dwarf2/info-locals-optimized-out.exp: Same.
	* gdb.dwarf2/main-subprogram.exp: Same.
	* gdb.dwarf2/missing-type-name.exp: Same.
	* gdb.dwarf2/nonvar-access.exp: Same.
	* gdb.dwarf2/typedef-void-finish.exp: Same.
	* gdb.dwarf2/var-access.exp: Same.
	* gdb.dwarf2/void-type.exp: Same.

---
 gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp             | 2 +-
 gdb/testsuite/gdb.dwarf2/atomic-type.exp                  | 4 +++-
 gdb/testsuite/gdb.dwarf2/bad-regnum.exp                   | 4 +++-
 gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp             | 4 +++-
 gdb/testsuite/gdb.dwarf2/dw2-align.exp                    | 2 +-
 gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp                  | 6 +++---
 gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp    | 4 +++-
 gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp           | 4 +++-
 gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp  | 2 +-
 gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp            | 3 ++-
 gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp      | 2 +-
 gdb/testsuite/gdb.dwarf2/enum-type.exp                    | 4 +++-
 gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp | 4 +++-
 gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp    | 4 ++--
 gdb/testsuite/gdb.dwarf2/main-subprogram.exp              | 4 +++-
 gdb/testsuite/gdb.dwarf2/missing-type-name.exp            | 4 +++-
 gdb/testsuite/gdb.dwarf2/nonvar-access.exp                | 4 +++-
 gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp          | 4 +++-
 gdb/testsuite/gdb.dwarf2/var-access.exp                   | 4 ++--
 gdb/testsuite/gdb.dwarf2/void-type.exp                    | 4 +++-
 20 files changed, 49 insertions(+), 24 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp b/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp
index 0b440c8e6d..870a7550f0 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp
@@ -34,7 +34,7 @@ Dwarf::assemble $asm_file {
     cu {} {
 	DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_Ada95}
-                {DW_AT_name     ada-linkage-name.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
 
         } {
diff --git a/gdb/testsuite/gdb.dwarf2/atomic-type.exp b/gdb/testsuite/gdb.dwarf2/atomic-type.exp
index d28af05d26..1058d2db9c 100644
--- a/gdb/testsuite/gdb.dwarf2/atomic-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/atomic-type.exp
@@ -25,10 +25,12 @@ standard_testfile .c -dw.S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C11}
-                {DW_AT_name     atomic-type-dw.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels i_l c_l c_c_l ac_c_l pac_c_l vpac_c_l avpac_c_l
diff --git a/gdb/testsuite/gdb.dwarf2/bad-regnum.exp b/gdb/testsuite/gdb.dwarf2/bad-regnum.exp
index acd739f7a5..600ec56a72 100644
--- a/gdb/testsuite/gdb.dwarf2/bad-regnum.exp
+++ b/gdb/testsuite/gdb.dwarf2/bad-regnum.exp
@@ -25,10 +25,12 @@ standard_testfile main.c -dw.S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
 	    {DW_AT_language @DW_LANG_C}
-	    {DW_AT_name     bad-regnum-dw.c}
+	    {DW_AT_name     $srcfile}
 	    {DW_AT_comp_dir /tmp}
 	} {
 	    declare_labels integer_label
diff --git a/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp b/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp
index f2c88b9b55..a1077b5a82 100644
--- a/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp
@@ -30,10 +30,12 @@ standard_testfile .c -debug.S
 # Set up the DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
 	    {DW_AT_language @DW_LANG_C_plus_plus}
-	    {DW_AT_name     ada-linkage-name.c}
+	    {DW_AT_name     $srcfile}
 	    {DW_AT_comp_dir /tmp}
 
 	} {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-align.exp b/gdb/testsuite/gdb.dwarf2/dw2-align.exp
index 640216ae19..4ad4fe811c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-align.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-align.exp
@@ -30,7 +30,7 @@ Dwarf::assemble $asm_file {
     cu {} {
 	DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C_plus_plus}
-                {DW_AT_name     dw2-align.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels itype ptype
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
index a85d3430a7..e939046e96 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
@@ -39,7 +39,7 @@ standard_testfile main.c -other.S -dwarf.S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile3]
 Dwarf::assemble $asm_file {
-    global srcdir subdir srcfile
+    global srcdir subdir srcfile srcfile2
 
     declare_labels ranges_label_1 ranges_label_2 L1 L2
 
@@ -52,7 +52,7 @@ Dwarf::assemble $asm_file {
     cu {} {
 	DW_TAG_compile_unit {
 	    {DW_AT_language @DW_LANG_C}
-	    {DW_AT_name     dw2-bad-elf.c}
+	    {DW_AT_name     $srcfile}
 	    {DW_AT_comp_dir ${srcdir}/${subdir}}
 	    {stmt_list $L1 DW_FORM_sec_offset}
 	    {ranges ${ranges_label_1} DW_FORM_sec_offset}
@@ -80,7 +80,7 @@ Dwarf::assemble $asm_file {
     cu {} {
 	DW_TAG_compile_unit {
 	    {DW_AT_language @DW_LANG_C}
-	    {DW_AT_name     dw2-bad-elf-other.c}
+	    {DW_AT_name     $srcfile2}
 	    {DW_AT_comp_dir ${srcdir}/${subdir}}
 	    {stmt_list $L2 DW_FORM_sec_offset}
 	    {ranges ${ranges_label_2} DW_FORM_sec_offset}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
index 238297c76a..bfb95215eb 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
@@ -26,10 +26,12 @@ standard_testfile .c .S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C_plus_plus}
-                {DW_AT_name     dw2-bad-mips-linkage-name.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
 
         } {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp
index 44d5faa97b..e93f2ce938 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp
@@ -28,10 +28,12 @@ standard_testfile .c -2.S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
 	    {DW_AT_language @DW_LANG_C}
-	    {DW_AT_name     dw2-bad-unresolved-2.c}
+	    {DW_AT_name     $srcfile}
 	    {DW_AT_comp_dir /tmp}
 	} {
 	    declare_labels b_l
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp b/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp
index a6d9a50028..bba05e4d5c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp
@@ -30,7 +30,7 @@ Dwarf::assemble $asm_file {
     cu {} {
 	DW_TAG_compile_unit {
 	    {DW_AT_language @DW_LANG_C_plus_plus}
-	    {DW_AT_name     dw2-namespaceless-anonymous.c}
+	    {DW_AT_name     $srcfile}
 	    {DW_AT_comp_dir /tmp}
 	} {
 	    declare_labels myint
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
index 496eddcc86..332e8439eb 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
@@ -41,6 +41,7 @@ proc build_test_program {} {
     # Make some DWARF for the test.
     set asm_file [standard_output_file $srcfile2]
     Dwarf::assemble $asm_file {
+	global srcfile
 
 	# Creating a CU with 4-byte addresses lets this test link on
 	# both 32- and 64-bit machines.
@@ -48,7 +49,7 @@ proc build_test_program {} {
     
 	    DW_TAG_compile_unit {
 		{DW_AT_language @DW_LANG_C99}
-		{DW_AT_name     dw2-opt-structptr.c}
+		{DW_AT_name     $srcfile}
 		{DW_AT_comp_dir /tmp}
 	    } {
 		declare_labels int_label struct_label pointer_label \
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp b/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp
index 1ff7b66587..8b984c3150 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp
@@ -62,7 +62,7 @@ proc run_test { field_name } {
 	cu {} {
 	    DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C}
-                {DW_AT_name     dw2-unusual-field-names.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
 	    } {
 		declare_labels itype ptype stype
diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwarf2/enum-type.exp
index 0b12d19453..dbb7446717 100644
--- a/gdb/testsuite/gdb.dwarf2/enum-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp
@@ -24,10 +24,12 @@ standard_testfile main.c -dw.S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C}
-                {DW_AT_name     enum-type-dw.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels integer_label uinteger_label
diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
index 0ded2c0e76..82d508a7d8 100644
--- a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
+++ b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
@@ -35,6 +35,8 @@ standard_testfile .S
 
 set dwarf_asm [standard_output_file dwarf-asm.S]
 Dwarf::assemble $dwarf_asm {
+    global srcfile
+
     declare_labels foo_subprogram bar_subprogram
     declare_labels stmt_list
 
@@ -43,7 +45,7 @@ Dwarf::assemble $dwarf_asm {
 
     cu { addr_size 4 } {
 	DW_TAG_compile_unit {
-	    {DW_AT_name file1.txt}
+	    {DW_AT_name $srcfile}
 	    {DW_AT_stmt_list $stmt_list DW_FORM_sec_offset}
 	    {DW_AT_language @DW_LANG_C99}
 	    {DW_AT_low_pc __cu_low_pc DW_FORM_addr}
diff --git a/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp
index 210acc1864..56fe9d6a67 100644
--- a/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp
@@ -28,13 +28,13 @@ standard_testfile main.c -dw.S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    global dwarf_regnum regname
+    global dwarf_regnum regname srcfile
 
     set buf_var [gdb_target_symbol buf]
 
     cu {} {
 	DW_TAG_compile_unit {
-		{DW_AT_name info-locals-optimized-out.c}
+		{DW_AT_name $srcfile}
 		{DW_AT_comp_dir /tmp}
 	} {
 	    declare_labels int_type_label
diff --git a/gdb/testsuite/gdb.dwarf2/main-subprogram.exp b/gdb/testsuite/gdb.dwarf2/main-subprogram.exp
index e5470ab7cb..ff08c0af5a 100644
--- a/gdb/testsuite/gdb.dwarf2/main-subprogram.exp
+++ b/gdb/testsuite/gdb.dwarf2/main-subprogram.exp
@@ -24,10 +24,12 @@ standard_testfile .c -dw.S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
                 {DW_AT_language @DW_LANG_C}
-                {DW_AT_name     main-subprogram.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels type
diff --git a/gdb/testsuite/gdb.dwarf2/missing-type-name.exp b/gdb/testsuite/gdb.dwarf2/missing-type-name.exp
index 920b67a7cb..06cabc9be7 100644
--- a/gdb/testsuite/gdb.dwarf2/missing-type-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/missing-type-name.exp
@@ -42,11 +42,13 @@ standard_testfile void-type.c void-type.S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
 	        {DW_AT_producer "GNU C 8.1"}
                 {DW_AT_language @DW_LANG_C}
-                {DW_AT_name     void-type.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels main_type int_type ptr_type
diff --git a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
index 71b726f8f6..20c2daf883 100644
--- a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
@@ -27,9 +27,11 @@ standard_testfile main.c -dw.S
 set asm_file [standard_output_file $srcfile2]
 
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	compile_unit {
-	    {DW_AT_name main.c}
+	    {DW_AT_name $srcfile}
 	} {
 	    declare_labels int_type_label char_type_label \
 		struct_s_label struct_t_label array_a9_label \
diff --git a/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp b/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
index b8a1d64d19..dc91c2f7f3 100644
--- a/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
+++ b/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
@@ -29,11 +29,13 @@ standard_testfile void-type.c .S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
 	        {DW_AT_producer "GNU C 8.1"}
                 {DW_AT_language @DW_LANG_C}
-                {DW_AT_name     void-type.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels main_type void_typedef
diff --git a/gdb/testsuite/gdb.dwarf2/var-access.exp b/gdb/testsuite/gdb.dwarf2/var-access.exp
index c0d21ba96b..82fd5fd4a6 100644
--- a/gdb/testsuite/gdb.dwarf2/var-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/var-access.exp
@@ -50,13 +50,13 @@ standard_testfile .c -dw.S
 
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
-    global dwarf_regnum regname
+    global dwarf_regnum regname srcfile
 
     set buf_var [gdb_target_symbol buf]
 
     cu {} {
 	DW_TAG_compile_unit {
-		{DW_AT_name var-pieces-dw.c}
+		{DW_AT_name $srcfile}
 		{DW_AT_comp_dir /tmp}
 	} {
 	    declare_labels char_type_label
diff --git a/gdb/testsuite/gdb.dwarf2/void-type.exp b/gdb/testsuite/gdb.dwarf2/void-type.exp
index 0ffba34a18..eb8db2c921 100644
--- a/gdb/testsuite/gdb.dwarf2/void-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/void-type.exp
@@ -36,11 +36,13 @@ standard_testfile .c .S
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
+    global srcfile
+
     cu {} {
 	DW_TAG_compile_unit {
 	        {DW_AT_producer "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.5.212 Build 20150212"}
                 {DW_AT_language @DW_LANG_C}
-                {DW_AT_name     void-type.c}
+                {DW_AT_name     $srcfile}
                 {DW_AT_comp_dir /tmp}
         } {
 	    declare_labels int_type void_type ptr_type


More information about the Gdb-patches mailing list