]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.dwarf2/dwp-symlink.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / dwp-symlink.exp
1 # Copyright 2013-2021 Free Software Foundation, Inc.
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 standard_testfile
17
18 remote_file host delete [standard_output_file ${testfile}.dwp]
19 if [remote_file host exists [standard_output_file ${testfile}.dwp]] {
20 unsupported "dwp file cannot be deleted"
21 return 0
22 }
23 if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } {
24 return -1
25 }
26 if ![remote_file host exists [standard_output_file ${testfile}.dwp]] {
27 unsupported "testsuite run does not produce dwp files"
28 return 0
29 }
30
31 set thelink "${testfile}-thelink"
32
33 remote_file host delete [standard_output_file ${thelink}]
34 remote_file host delete [standard_output_file ${thelink}.dwp]
35 # file link is only Tcl 8.4+.
36 remote_exec host "ln -sf ${testfile} [standard_output_file $thelink]"
37 if ![remote_file host exists [standard_output_file $thelink]] {
38 unsupported "host does not support symbolic links (binary symlink is missing)"
39 return 0
40 }
41 if [remote_file host exists [standard_output_file $thelink.dwp]] {
42 unsupported "host does not support symbolic links (we tried to delete a file and it is still there)"
43 return 0
44 }
45
46 clean_restart "$testfile"
47
48 gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary default, dwp default"
49
50 clean_restart "$thelink"
51
52 gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp default"
53
54 gdb_exit
55 remote_exec host "mv -f [standard_output_file ${testfile}.dwp] [standard_output_file ${thelink}.dwp]"
56 if [remote_file host exists [standard_output_file ${testfile}.dwp]] {
57 unsupported "host does not support symbolic links (binary symlink exists)"
58 return 0
59 }
60 if ![remote_file host exists [standard_output_file ${thelink}.dwp]] {
61 unsupported "host does not support symbolic links (dwp symlink is missing)"
62 return 0
63 }
64
65 clean_restart "$testfile"
66
67 # This case cannot work.
68 gdb_test "ptype main" {type = int \(\)} "binary default, dwp at symlink"
69
70 clean_restart "$thelink"
71
72 gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp at symlink"
73
74 # Verify we can still find the dwp if we change directories and we specified
75 # a relative path for the program.
76
77 # This is clean_restart, but specifying a relative path to the binary.
78 gdb_exit
79 gdb_start
80 gdb_reinitialize_dir $srcdir/$subdir
81 gdb_test "cd [file dirname [standard_output_file ${thelink}]]" \
82 "Working directory .*"
83 gdb_load "./${thelink}"
84
85 gdb_test "cd .." "Working directory .*"
86
87 gdb_test "ptype main" {type = int \(int, char \*\*\)} \
88 "relative path, binary symlink, dwp at symlink"
89
90 # Rename the dwp file back to its original name.
91 remote_exec host "mv -f [standard_output_file ${thelink}.dwp] [standard_output_file ${testfile}.dwp]"
92
93 # N.B. At this point the active gdb is in, essentially, some random directory.
94 # Restart a new copy if you add more tests here.
95
96 # Now verify that the following scenario works:
97 # dir1/real-binary-with-random-name
98 # dir2/real-dwp-with-random-name
99 # dir3/symlink-to-real-binary
100 # dir3/symlink-to-real-binary.dwp
101
102 set dwp_bin_dir [standard_output_file dwp-dir1]
103 set dwp_dwp_dir [standard_output_file dwp-dir2]
104 set dwp_symlink_dir [standard_output_file dwp-dir3]
105 set dwp_real_binary "dwp-abc"
106 set dwp_real_dwp "dwp-def"
107 set dwp_symlink_binary "dwp-symlink-binary"
108 set dwp_symlink_dwp "${dwp_symlink_binary}.dwp"
109
110 remote_exec host "rm -rf ${dwp_bin_dir}"
111 remote_exec host "rm -rf ${dwp_dwp_dir}"
112 remote_exec host "rm -rf ${dwp_symlink_dir}"
113 remote_exec host "mkdir ${dwp_bin_dir}"
114 remote_exec host "mkdir ${dwp_dwp_dir}"
115 remote_exec host "mkdir ${dwp_symlink_dir}"
116 remote_exec host "cp [standard_output_file $testfile] ${dwp_bin_dir}/${dwp_real_binary}"
117 remote_exec host "cp [standard_output_file ${testfile}.dwp] ${dwp_dwp_dir}/${dwp_real_dwp}"
118 # We don't test for failure to create the symlink here.
119 # We assume that if the above symlinks are created ok, these will be too.
120 remote_exec host "ln -sf ${dwp_bin_dir}/${dwp_real_binary} ${dwp_symlink_dir}/${dwp_symlink_binary}"
121 remote_exec host "ln -sf ${dwp_dwp_dir}/${dwp_real_dwp} ${dwp_symlink_dir}/${dwp_symlink_dwp}"
122
123 clean_restart "${dwp_symlink_dir}/${dwp_symlink_binary}"
124
125 if ![runto_main] {
126 return -1
127 }
128
129 gdb_test {print argv[0]} "/${dwp_symlink_binary}\"" \
130 "separate executable/dwp symlinks"