Switch the inferior too in switch_to_program_space_and_thread
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.server / bkpt-other-inferior.exp
1 # Copyright 2019-2020 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 if { [skip_gdbserver_tests] } {
25 return 0
26 }
27
28 if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
29 {debug pthreads}] } {
30 return
31 }
32
33 # Make sure we're disconnected, in case we're testing with an
34 # extended-remote board, therefore already connected.
35 gdb_test "disconnect" ".*"
36
37 # Leave inferior 1 with the exec target, not connected. Add another
38 # inferior, and connect it to gdbserver.
39
40 gdb_test "add-inferior" "Added inferior 2" \
41 "add inferior 2"
42 gdb_test "inferior 2" "Switching to inferior 2.*" \
43 "switch to inferior 2"
44 gdb_test "file ${binfile}" ".*" "load file in inferior 2"
45
46 set target_exec [gdbserver_download_current_prog]
47
48 # Start GDBserver.
49 set res [gdbserver_start "" $target_exec]
50
51 # Connect to GDBserver.
52 set gdbserver_protocol [lindex $res 0]
53 set gdbserver_gdbport [lindex $res 1]
54 gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
55
56 # Discard any symbol files that we have opened.
57 set test "discard symbol table"
58 gdb_test_multiple "file" $test {
59 -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $" {
60 gdb_test "y" ".*" $test \
61 {Discard symbol table from `.*'\? \(y or n\) } "y"
62 }
63 }
64
65 # At this point:
66 #
67 # - inferior 1 has symbols, and is not connected to any target.
68 # - inferior 2 has no symbols, and is connected to gdbserver.
69
70 # Setting a breakpoint at some function by name should set a
71 # breakpoint on inferior 1, since it has symbols, and should not
72 # result in any access to inferior 2's remote target.
73
74 gdb_test_no_output "set debug remote 1"
75
76 foreach inf_sel {1 2} {
77 with_test_prefix "inf $inf_sel" {
78 gdb_test "inferior $inf_sel" "Switching to inferior $inf_sel.*" \
79 "switch to inferior"
80
81 set test "set breakpoint"
82 gdb_test_multiple "break main" $test {
83 -re "Sending packet.*$gdb_prompt $" {
84 fail $test
85 }
86 -re "^break main\r\nBreakpoint .* at .*$gdb_prompt $" {
87 pass $test
88 }
89 }
90
91 delete_breakpoints
92 }
93 }
This page took 0.031297 seconds and 4 git commands to generate.