Fix gdb.mi/mi-fullname-deleted.exp with Clang
authorGary Benson <gbenson@redhat.com>
Wed, 21 Oct 2020 08:54:31 +0000 (09:54 +0100)
committerGary Benson <gbenson@redhat.com>
Wed, 21 Oct 2020 08:54:31 +0000 (09:54 +0100)
gdb.mi/mi-fullname-deleted.exp attempts to generate an executable
with a doubled slash in the source filename recorded in its debug
info.  This attempt fails when compiling using Clang, causing the
substituted filename test to fail.  This commit fixes this issue.
It also expands the comments in the file, to clarify what the test
is attempting to do, and to document where it doesn't succeed.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-fullname-deleted.exp: Fix substituted
fullname test with Clang.  Also expand comments generally.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/mi-fullname-deleted.exp

index 277848c25322ad1f36b798a7fc699767a2ec6655..4061d1789ccdd99d28bf539ae41d773e4c97e79a 100644 (file)
@@ -1,3 +1,8 @@
+2020-10-21  Gary Benson <gbenson@redhat.com>
+
+       * gdb.mi/mi-fullname-deleted.exp: Fix substituted
+       fullname test with Clang.  Also expand comments generally.
+
 2020-10-20  Tom de Vries  <tdevries@suse.de>
 
        * gdb.dwarf2/pr13961.S: Remove superfluous end-of-siblings marker.
index f68bcc55bc3626aa93a79a69f663ed40b729cf64..e175041b46c6b88c0ed03f4a7cfb6e9750970b5f 100644 (file)
@@ -24,7 +24,17 @@ if [mi_gdb_start] {
 standard_testfile
 set srcfileabs [standard_output_file $srcfile]
 
-# "//$srcfile" It is used for the test of compare_filenames_for_search.
+# Double the final slash separator in $srcfileabs, such that
+# "/path/to/$srcfile" becomes "/path/to//$srcfile".  This is
+# passed as the "source" argument of gdb_compile, which, when
+# using GCC (as of 10.2) will result in the doubled slash
+# being incorporated into the built executable's debug info.
+# This is then used to check compare_filenames_for_search does
+# not falsely use an absolute filename as a relative one.
+# Note that Clang (as of 12.0.0) normalizes the path before
+# storing it in the executable's debug info, removing the double
+# slash.  This nullifies the "compare_filenames_for_search does
+# not match" test when using Clang (it can never fail).
 if { [regsub {/[^/]+$} $srcfileabs {/\0} srcfileabs] != 1 } {
     xfail "cannot double the last slash separator"
     return -1
@@ -36,6 +46,12 @@ if { [regsub {^(/[^/]+)/} $srcfileabs {\1subst/} srcfileabssubst] != 1
     return -1
 }
 
+# Generate a regular expression which to match $srcfileabs with
+# or without the doubled slash.  This is used by the substituted
+# fullname test.
+set srcfileabssubst_regexp [string_to_regexp $srcfileabssubst]
+regsub {//} $srcfileabssubst_regexp {\0?} srcfileabssubst_regexp
+
 set f [open $srcfileabs "w"]
 puts $f "int main (void) { return 0; }"
 close $f
@@ -54,10 +70,12 @@ mi_gdb_test "-interpreter-exec console \"set substitute-path ${initdir} ${initdi
 
 mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\".*\".*" "fullname present"
 
-mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"[string_to_regexp $srcfileabssubst]\".*" "substituted fullname"
+mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"$srcfileabssubst_regexp\".*" "substituted fullname"
 
-# Test compare_filenames_for_search does not falsely use absolute filename as
-# a relative one.
+# Test compare_filenames_for_search does not falsely use absolute
+# filename as a relative one.  Note that this test can falsely pass
+# with Clang, and possibly other compilers too; see the comment
+# above for more.
 mi_gdb_test "-break-insert -t /$srcfile:main" \
            "\\^error,msg=\"No source file named /[string_to_regexp $srcfile]\\.\"" \
            "compare_filenames_for_search does not match"
This page took 0.035282 seconds and 4 git commands to generate.