diff options
author | Gary Benson <gbenson@redhat.com> | 2020-10-21 09:54:31 +0100 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2020-10-21 09:54:31 +0100 |
commit | 98cec4f6a27679709d7ae2ce7ee25af50866f604 (patch) | |
tree | 8f1b06c93e883f2ebd8f86b5b5d4a4800d534372 /gdb/testsuite/gdb.mi/mi-fullname-deleted.exp | |
parent | a1bd8917ab2bbb61071366ce8a6fd31d00d147ad (diff) | |
download | gdb-98cec4f6a27679709d7ae2ce7ee25af50866f604.zip gdb-98cec4f6a27679709d7ae2ce7ee25af50866f604.tar.gz gdb-98cec4f6a27679709d7ae2ce7ee25af50866f604.tar.bz2 |
Fix gdb.mi/mi-fullname-deleted.exp with Clang
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.
Diffstat (limited to 'gdb/testsuite/gdb.mi/mi-fullname-deleted.exp')
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-fullname-deleted.exp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp index f68bcc5..e175041 100644 --- a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp +++ b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp @@ -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" |