Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2012-2022 Free Software Foundation, Inc. |
f35a17b5 JK |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | load_lib mi-support.exp | |
17 | set MIFLAGS "-i=mi" | |
18 | ||
19 | gdb_exit | |
20 | if [mi_gdb_start] { | |
21 | continue | |
22 | } | |
23 | ||
24 | standard_testfile | |
25 | set srcfileabs [standard_output_file $srcfile] | |
26 | ||
98cec4f6 GB |
27 | # Double the final slash separator in $srcfileabs, such that |
28 | # "/path/to/$srcfile" becomes "/path/to//$srcfile". This is | |
29 | # passed as the "source" argument of gdb_compile, which, when | |
30 | # using GCC (as of 10.2) will result in the doubled slash | |
31 | # being incorporated into the built executable's debug info. | |
32 | # This is then used to check compare_filenames_for_search does | |
33 | # not falsely use an absolute filename as a relative one. | |
34 | # Note that Clang (as of 12.0.0) normalizes the path before | |
35 | # storing it in the executable's debug info, removing the double | |
36 | # slash. This nullifies the "compare_filenames_for_search does | |
37 | # not match" test when using Clang (it can never fail). | |
af529f8f | 38 | if { [regsub {/[^/]+$} $srcfileabs {/\0} srcfileabs] != 1 } { |
bc6c7af4 | 39 | xfail "cannot double the last slash separator" |
af529f8f JK |
40 | return -1 |
41 | } | |
42 | ||
f0a4b570 JK |
43 | if { [regsub {^(/[^/]+)/} $srcfileabs {\1subst/} srcfileabssubst] != 1 |
44 | || [regsub {^(/[^/]+)/.*$} $srcfileabs {\1} initdir] != 1 } { | |
bc6c7af4 | 45 | xfail "missing root subdirectory" |
f0a4b570 JK |
46 | return -1 |
47 | } | |
48 | ||
98cec4f6 GB |
49 | # Generate a regular expression which to match $srcfileabs with |
50 | # or without the doubled slash. This is used by the substituted | |
51 | # fullname test. | |
52 | set srcfileabssubst_regexp [string_to_regexp $srcfileabssubst] | |
53 | regsub {//} $srcfileabssubst_regexp {\0?} srcfileabssubst_regexp | |
54 | ||
f35a17b5 JK |
55 | set f [open $srcfileabs "w"] |
56 | puts $f "int main (void) { return 0; }" | |
57 | close $f | |
58 | ||
59 | if { [gdb_compile "$srcfileabs" "${binfile}" executable {debug}] != "" } { | |
60 | untested $testname | |
61 | return -1 | |
62 | } | |
63 | ||
64 | file delete -- $srcfileabs | |
65 | ||
66 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
67 | mi_gdb_load ${binfile} | |
68 | ||
f0a4b570 JK |
69 | mi_gdb_test "-interpreter-exec console \"set substitute-path ${initdir} ${initdir}subst\"" {\^done} "set substitute-path" |
70 | ||
71 | mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\".*\".*" "fullname present" | |
72 | ||
98cec4f6 | 73 | mi_gdb_test "-file-list-exec-source-file" ".*\",fullname=\"$srcfileabssubst_regexp\".*" "substituted fullname" |
af529f8f | 74 | |
98cec4f6 GB |
75 | # Test compare_filenames_for_search does not falsely use absolute |
76 | # filename as a relative one. Note that this test can falsely pass | |
77 | # with Clang, and possibly other compilers too; see the comment | |
78 | # above for more. | |
af529f8f JK |
79 | mi_gdb_test "-break-insert -t /$srcfile:main" \ |
80 | "\\^error,msg=\"No source file named /[string_to_regexp $srcfile]\\.\"" \ | |
81 | "compare_filenames_for_search does not match" | |
82 | mi_gdb_test "-break-insert -t $srcfile:main" \ | |
83 | {\^done,bkpt=.*} \ | |
84 | "compare_filenames_for_search does match" |