]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.multi/dummy-frame-restore.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.multi / dummy-frame-restore.exp
1 # Copyright 2014-2022 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 standard_testfile .c
17 set executable ${testfile}
18
19 # The plain remote target can't do multiple inferiors.
20 if [use_gdb_stub] {
21 return
22 }
23
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
25 return -1
26 }
27
28 # Inferior 1 stops at f1.
29
30 if ![runto f1] then {
31 return 0
32 }
33
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"
38
39 delete_breakpoints
40
41 # Inferior 2 stops at f2.
42
43 if ![runto f2] then {
44 return 0
45 }
46
47 gdb_breakpoint commonfun
48
49 # Check the stack bactrace in inferior INF. PREFIX is the test
50 # message prefix.
51
52 proc check_bt { inf prefix } {
53 with_test_prefix "$prefix" {
54 gdb_test "bt 1" "#0 f$inf .*" "bt in inferior $inf"
55 }
56 }
57
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
61 # inferior call.
62
63 proc test { inf1 inf2 } {
64
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"
70
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"
75
76 gdb_test "maintenance print dummy-frames" ": id={stack=.*}.*: id=.*" \
77 "two dummy frames"
78
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"
84
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"
90 }
91 }
92
93 # Do the test in different orders.
94 test 1 2
95 test 2 1