]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.server/bkpt-other-inferior.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.server / bkpt-other-inferior.exp
1 # Copyright 2019-2024 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 # Test that GDB does not access the remote target's memory when
17 # setting a breakpoint on a function that only exists in an inferior
18 # that is not bound to the remote target.
19
20 load_lib gdbserver-support.exp
21
22 standard_testfile server.c
23
24 require allow_gdbserver_tests
25
26 if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
27 {debug pthreads}] } {
28 return
29 }
30 set host_binfile [gdb_remote_download host $binfile]
31
32 # Make sure we're disconnected, in case we're testing with an
33 # extended-remote board, therefore already connected.
34 gdb_test "disconnect" ".*"
35
36 # Leave inferior 1 with the exec target, not connected. Add another
37 # inferior, and connect it to gdbserver.
38
39 gdb_test "add-inferior" "Added inferior 2" \
40 "add inferior 2"
41 gdb_test "inferior 2" "Switching to inferior 2.*" \
42 "switch to inferior 2"
43 gdb_test "file ${host_binfile}" ".*" "load file in inferior 2"
44
45 set target_exec [gdbserver_download_current_prog]
46
47 # Start GDBserver.
48 set res [gdbserver_start "" $target_exec]
49
50 # Connect to GDBserver.
51 set gdbserver_protocol [lindex $res 0]
52 set gdbserver_gdbport [lindex $res 1]
53 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
54
55 # Discard any symbol files that we have opened.
56 set test "discard symbol table"
57 gdb_test_multiple "file" $test {
58 -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $" {
59 gdb_test "y" ".*" $test \
60 {Discard symbol table from `.*'\? \(y or n\) } "y"
61 }
62 }
63
64 # At this point:
65 #
66 # - inferior 1 has symbols, and is not connected to any target.
67 # - inferior 2 has no symbols, and is connected to gdbserver.
68
69 # Setting a breakpoint at some function by name should set a
70 # breakpoint on inferior 1, since it has symbols, and should not
71 # result in any access to inferior 2's remote target.
72
73 foreach inf_sel {1 2} {
74 with_test_prefix "inf $inf_sel" {
75 gdb_test "inferior $inf_sel" "Switching to inferior $inf_sel.*" \
76 "switch to inferior"
77
78 gdb_test_no_output "set debug remote 1"
79
80 gdb_test_multiple "break -q main" "set breakpoint" {
81 -re "Sending packet: \\\$qXfer:auxv:read.*$gdb_prompt $" {
82 # Symbol lookup may access the target to read AUXV in
83 # order to determine the debug base for SVR4 linker
84 # namespaces.
85 xfail "$gdb_test_name"
86 }
87 -re "Sending packet.*$gdb_prompt $" {
88 fail "$gdb_test_name"
89 }
90 -re "^break -q main\r\nBreakpoint .* at .*$gdb_prompt $" {
91 pass "$gdb_test_name"
92 }
93 }
94
95 gdb_test_no_output "set debug remote 0"
96
97 delete_breakpoints
98 }
99 }