1 # This testcase is part of GDB
, the GNU debugger.
3 # Copyright
2016-2022 Free Software Foundation
, Inc.
5 # This
program is free software
; you can redistribute it and
/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
; either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # This
program is distributed in the hope that it will be useful
,
11 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
18 # Test GDB
's ability to properly connect to GDBserver with no pre-opened
19 # symbol file. If GDB is buggy, it will drop the connection when
20 # it attempts to open the symbol file indicated by GDBserver and fails.
22 # This test is only meaningful for standard remote connections.
24 load_lib gdbserver-support.exp
28 if { [skip_gdbserver_tests] } {
32 if { [build_executable "failed to prepare" $testfile $srcfile debug] } {
36 # Test connecting GDB to GDBserver without loading a symbol file.
38 # SYSROOT is the desired sysroot string
40 # ACTION is the action to perform to the symbol file on the target.
41 # It can be either "permission" to deny access to the file or "delete"
44 proc connect_no_symbol_file { sysroot action } {
47 with_test_prefix "setup" {
48 # Copy the symbol file to the target.
49 set target_exec [gdb_remote_download target $binfile.bak $binfile]
51 # Make sure we're disconnected
, in case we
're testing with an
52 # extended-remote board, therefore already connected.
53 gdb_test "disconnect" ".*"
55 # Set sysroot to something non-target and possibly also invalid so that
56 # GDB is unable to open the symbol file.
57 gdb_test_no_output "set sysroot $sysroot" "adjust sysroot"
60 set res [gdbserver_start "" $target_exec]
62 set gdbserver_protocol [lindex $res 0]
63 set gdbserver_gdbport [lindex $res 1]
65 # Perform test actions to the symbol file on the target.
66 if { $action == "delete" } then {
67 remote_file target delete $target_exec
68 } elseif { $action == "permission" } {
69 remote_spawn target "chmod 000 $target_exec"
72 # Connect to GDBserver.
73 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
76 # Check if GDB succeeded connecting to GDBserver by attempting to detach
79 ".*Detaching from program: , process.*Ending remote debugging.*" \
80 "connection to GDBserver succeeded"
83 # Make sure we have the original symbol file in a safe place to copy from.
84 gdb_remote_download host $binfile $binfile.bak
86 # Start with no executable loaded.
89 # Run the test with different permutations.
90 foreach_with_prefix sysroot {"" "target:"} {
91 foreach_with_prefix action {"permission" "delete"} {
92 connect_no_symbol_file $sysroot $action