1 # Copyright
2014-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
/>.
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.
31 fail "can't run to f1
"
35 gdb_test
"add-inferior -exec ${binfile}" \
36 "Added inferior 2.*" \
37 "add inferior 2 with -exec ${executable}"
38 gdb_test
"inferior 2" "witching to inferior 2 .*" "switch to inferior 2"
42 # Inferior
2 stops at f2.
45 fail
"can't run to f2"
49 gdb_breakpoint commonfun
51 # Check the stack bactrace in inferior INF. PREFIX is the test
54 proc check_bt
{ inf prefix
} {
55 with_test_prefix
"$prefix" {
56 gdb_test
"bt 1" "#0 f$inf .*" "bt in inferior $inf"
60 #
Do inferior
call commonfun
() in inferior
2 and inferior
1, but
61 # finish it in inferior INF1 first and
then inferior INF2. Check
62 # the stack backtrace in each inferior is still correct after
65 proc test
{ inf1 inf2
} {
67 with_test_prefix
"inf $inf1 first" {
68 gdb_test
"inferior 2" "witching to inferior 2 .*" \
69 "switch to inferior 2 (1)"
70 check_bt
2 "before infcall"
71 gdb_test
"p commonfun()" "Breakpoint .*The program being debugged stopped while in a function called from GDB.*" "infcall in inferior 2"
73 gdb_test
"inferior 1" "witching to inferior 1 .*" \
74 "switch to inferior 1 (1)"
75 check_bt
1 "before infcall"
76 gdb_test
"p commonfun()" "Breakpoint .*The program being debugged stopped while in a function called from GDB.*" "infcall in inferior 1"
78 gdb_test
"maintenance print dummy-frames" ": id={stack=.*}.*: id=.*" \
81 gdb_test
"inferior $inf1" "witching to inferior $inf1 .*" \
82 "switch to inferior $inf1 (2)"
83 gdb_test
"finish" "Run till exit from #0 commonfun .*" \
84 "finish in inferior $inf1"
85 check_bt $inf1
"after infcall"
87 gdb_test
"inferior $inf2" "witching to inferior $inf2 .*" \
88 "switch to inferior $inf2 (2)"
89 gdb_test
"finish" "Run till exit from #0 commonfun .*" \
90 "finish in inferior $inf2"
91 check_bt $inf2
"after infcall"
95 #
Do the test in different orders.