1 # Copyright 2014-2022 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/>.
17 set executable ${testfile}
19 # The plain remote target can't do multiple inferiors.
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
28 # Inferior 1 stops at f1.
34 gdb_test "add-inferior -exec ${binfile}" \
35 "Added inferior 2.*" \
36 "add inferior 2 with -exec ${executable}"
37 gdb_test "inferior 2" "witching to inferior 2 .*" "switch to inferior 2"
41 # Inferior 2 stops at f2.
47 gdb_breakpoint commonfun
49 # Check the stack bactrace in inferior INF. PREFIX is the test
52 proc check_bt { inf prefix } {
53 with_test_prefix "$prefix" {
54 gdb_test "bt 1" "#0 f$inf .*" "bt in inferior $inf"
58 # Do inferior call commonfun () in inferior 2 and inferior 1, but
59 # finish it in inferior INF1 first and then inferior INF2. Check
60 # the stack backtrace in each inferior is still correct after
63 proc test { inf1 inf2 } {
65 with_test_prefix "inf $inf1 first" {
66 gdb_test "inferior 2" "witching to inferior 2 .*" \
67 "switch to inferior 2 (1)"
68 check_bt 2 "before infcall"
69 gdb_test "p commonfun()" "Breakpoint .*The program being debugged stopped while in a function called from GDB.*" "infcall in inferior 2"
71 gdb_test "inferior 1" "witching to inferior 1 .*" \
72 "switch to inferior 1 (1)"
73 check_bt 1 "before infcall"
74 gdb_test "p commonfun()" "Breakpoint .*The program being debugged stopped while in a function called from GDB.*" "infcall in inferior 1"
76 gdb_test "maintenance print dummy-frames" ": id={stack=.*}.*: id=.*" \
79 gdb_test "inferior $inf1" "witching to inferior $inf1 .*" \
80 "switch to inferior $inf1 (2)"
81 gdb_test "finish" "Run till exit from #0 commonfun .*" \
82 "finish in inferior $inf1"
83 check_bt $inf1 "after infcall"
85 gdb_test "inferior $inf2" "witching to inferior $inf2 .*" \
86 "switch to inferior $inf2 (2)"
87 gdb_test "finish" "Run till exit from #0 commonfun .*" \
88 "finish in inferior $inf2"
89 check_bt $inf2 "after infcall"
93 # Do the test in different orders.