1 1.11 christos # Copyright 2013-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos standard_testfile 17 1.1 christos 18 1.3 christos remote_file host delete [standard_output_file ${testfile}.dwp] 19 1.3 christos if [remote_file host exists [standard_output_file ${testfile}.dwp]] { 20 1.1 christos unsupported "dwp file cannot be deleted" 21 1.1 christos return 0 22 1.1 christos } 23 1.1 christos if { [build_executable ${testfile}.exp ${testfile} ${srcfile}] == -1 } { 24 1.1 christos return -1 25 1.1 christos } 26 1.3 christos if ![remote_file host exists [standard_output_file ${testfile}.dwp]] { 27 1.1 christos unsupported "testsuite run does not produce dwp files" 28 1.1 christos return 0 29 1.1 christos } 30 1.1 christos 31 1.1 christos set thelink "${testfile}-thelink" 32 1.1 christos 33 1.3 christos remote_file host delete [standard_output_file ${thelink}] 34 1.3 christos remote_file host delete [standard_output_file ${thelink}.dwp] 35 1.1 christos # file link is only Tcl 8.4+. 36 1.3 christos remote_exec host "ln -sf ${testfile} [standard_output_file $thelink]" 37 1.3 christos if ![remote_file host exists [standard_output_file $thelink]] { 38 1.1 christos unsupported "host does not support symbolic links (binary symlink is missing)" 39 1.1 christos return 0 40 1.1 christos } 41 1.3 christos if [remote_file host exists [standard_output_file $thelink.dwp]] { 42 1.1 christos unsupported "host does not support symbolic links (we tried to delete a file and it is still there)" 43 1.1 christos return 0 44 1.1 christos } 45 1.1 christos 46 1.1 christos clean_restart "$testfile" 47 1.1 christos 48 1.12 christos set main_type_re [string_to_regexp "type = int (int, char **)"] 49 1.12 christos 50 1.12 christos gdb_test "ptype main" $main_type_re "binary default, dwp default" 51 1.1 christos 52 1.1 christos clean_restart "$thelink" 53 1.1 christos 54 1.12 christos gdb_test "ptype main" $main_type_re "binary symlink, dwp default" 55 1.1 christos 56 1.1 christos gdb_exit 57 1.3 christos remote_exec host "mv -f [standard_output_file ${testfile}.dwp] [standard_output_file ${thelink}.dwp]" 58 1.3 christos if [remote_file host exists [standard_output_file ${testfile}.dwp]] { 59 1.1 christos unsupported "host does not support symbolic links (binary symlink exists)" 60 1.1 christos return 0 61 1.1 christos } 62 1.3 christos if ![remote_file host exists [standard_output_file ${thelink}.dwp]] { 63 1.1 christos unsupported "host does not support symbolic links (dwp symlink is missing)" 64 1.1 christos return 0 65 1.1 christos } 66 1.1 christos 67 1.1 christos clean_restart "$testfile" 68 1.1 christos 69 1.12 christos gdb_test "ptype main" \ 70 1.12 christos "Could not find DWO CU .*" \ 71 1.12 christos "binary default, dwp at symlink" 72 1.1 christos 73 1.1 christos clean_restart "$thelink" 74 1.1 christos 75 1.12 christos gdb_test "ptype main" $main_type_re "binary symlink, dwp at symlink" 76 1.1 christos 77 1.1 christos # Verify we can still find the dwp if we change directories and we specified 78 1.1 christos # a relative path for the program. 79 1.1 christos 80 1.1 christos # This is clean_restart, but specifying a relative path to the binary. 81 1.11 christos clean_restart 82 1.1 christos gdb_test "cd [file dirname [standard_output_file ${thelink}]]" \ 83 1.12 christos "Working directory .*" \ 84 1.12 christos "cd to dir containing binary" 85 1.12 christos 86 1.1 christos gdb_load "./${thelink}" 87 1.1 christos 88 1.1 christos gdb_test "cd .." "Working directory .*" 89 1.1 christos 90 1.1 christos gdb_test "ptype main" {type = int \(int, char \*\*\)} \ 91 1.1 christos "relative path, binary symlink, dwp at symlink" 92 1.1 christos 93 1.3 christos # Rename the dwp file back to its original name. 94 1.3 christos remote_exec host "mv -f [standard_output_file ${thelink}.dwp] [standard_output_file ${testfile}.dwp]" 95 1.3 christos 96 1.3 christos # N.B. At this point the active gdb is in, essentially, some random directory. 97 1.3 christos # Restart a new copy if you add more tests here. 98 1.3 christos 99 1.3 christos # Now verify that the following scenario works: 100 1.3 christos # dir1/real-binary-with-random-name 101 1.3 christos # dir2/real-dwp-with-random-name 102 1.3 christos # dir3/symlink-to-real-binary 103 1.3 christos # dir3/symlink-to-real-binary.dwp 104 1.3 christos 105 1.3 christos set dwp_bin_dir [standard_output_file dwp-dir1] 106 1.3 christos set dwp_dwp_dir [standard_output_file dwp-dir2] 107 1.3 christos set dwp_symlink_dir [standard_output_file dwp-dir3] 108 1.3 christos set dwp_real_binary "dwp-abc" 109 1.3 christos set dwp_real_dwp "dwp-def" 110 1.3 christos set dwp_symlink_binary "dwp-symlink-binary" 111 1.3 christos set dwp_symlink_dwp "${dwp_symlink_binary}.dwp" 112 1.3 christos 113 1.3 christos remote_exec host "rm -rf ${dwp_bin_dir}" 114 1.3 christos remote_exec host "rm -rf ${dwp_dwp_dir}" 115 1.3 christos remote_exec host "rm -rf ${dwp_symlink_dir}" 116 1.3 christos remote_exec host "mkdir ${dwp_bin_dir}" 117 1.3 christos remote_exec host "mkdir ${dwp_dwp_dir}" 118 1.3 christos remote_exec host "mkdir ${dwp_symlink_dir}" 119 1.3 christos remote_exec host "cp [standard_output_file $testfile] ${dwp_bin_dir}/${dwp_real_binary}" 120 1.3 christos remote_exec host "cp [standard_output_file ${testfile}.dwp] ${dwp_dwp_dir}/${dwp_real_dwp}" 121 1.3 christos # We don't test for failure to create the symlink here. 122 1.3 christos # We assume that if the above symlinks are created ok, these will be too. 123 1.3 christos remote_exec host "ln -sf ${dwp_bin_dir}/${dwp_real_binary} ${dwp_symlink_dir}/${dwp_symlink_binary}" 124 1.3 christos remote_exec host "ln -sf ${dwp_dwp_dir}/${dwp_real_dwp} ${dwp_symlink_dir}/${dwp_symlink_dwp}" 125 1.3 christos 126 1.3 christos clean_restart "${dwp_symlink_dir}/${dwp_symlink_binary}" 127 1.3 christos 128 1.3 christos if ![runto_main] { 129 1.3 christos return -1 130 1.3 christos } 131 1.3 christos 132 1.3 christos gdb_test {print argv[0]} "/${dwp_symlink_binary}\"" \ 133 1.3 christos "separate executable/dwp symlinks" 134