1 # Copyright 2017-2021 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test "next" bouncing between two breakpoints in two threads running
17 # in different targets.
19 source $srcdir/$subdir/multi-target.exp.tcl
21 if {![multi_target_prepare]} {
25 proc test_ping_pong_next {} {
29 untested "setup failed"
33 # Block/unblock inferiors 1 and 2 according to INF1 and INF2.
34 proc block {inf1 inf2} {
35 gdb_test "thread apply 1.1 p wait_for_gdb = $inf1" " = $inf1"
36 gdb_test "thread apply 2.1 p wait_for_gdb = $inf2" " = $inf2"
39 # We'll use inferiors 1 and 2. Make sure they're really connected
40 # to different targets.
41 gdb_test "thread apply 1.1 maint print target-stack" \
43 gdb_test "thread apply 2.1 maint print target-stack" \
46 # Set two breakpoints, one for each of inferior 1 and 2. Inferior
47 # 1 is running on the native target, and inferior 2 is running on
48 # extended-gdbserver. Run to breakpoint 1 to gets things started.
49 set line1 [gdb_get_line_number "set break 1 here"]
50 set line2 [gdb_get_line_number "set break 2 here"]
52 gdb_test "thread 1.1" "Switching to thread 1.1 .*"
54 gdb_test "break $srcfile:$line1 thread 1.1" \
55 "Breakpoint .*$srcfile:$line1\\..*"
57 gdb_test "continue" "hit Breakpoint .*"
59 gdb_test "break $srcfile:$line2 thread 2.1" \
60 "Breakpoint .*$srcfile:$line2\\..*"
62 # Now block inferior 1 and issue "next". We should stop at the
63 # breakpoint for inferior 2, given schedlock off.
64 with_test_prefix "next inf 1" {
66 gdb_test "next" "Thread 2.1 .*hit Breakpoint .*$srcfile:$line2.*"
69 # Now unblock inferior 2 and block inferior 1. "next" should run
70 # into the breakpoint in inferior 1.
71 with_test_prefix "next inf 2" {
73 gdb_test "next" "Thread 1.1 .*hit Breakpoint .*$srcfile:$line1.*"
76 # Try nexting inferior 1 again.
77 with_test_prefix "next inf 1 again" {
79 gdb_test "next" "Thread 2.1 .*hit Breakpoint .*$srcfile:$line2.*"