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.
This commit is contained in:
Gary Benson
2020-10-21 09:54:31 +01:00
parent a1bd8917ab
commit 98cec4f6a2
2 changed files with 27 additions and 4 deletions

View 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.

View 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"