Commit | Line | Data |
---|---|---|
029d2200 AC |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
28e7fd62 | 3 | # Copyright 1998-2013 Free Software Foundation, Inc. |
c906108c SS |
4 | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 7 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 8 | # (at your option) any later version. |
e22f8b7c | 9 | # |
c906108c SS |
10 | # This program is distributed in the hope that it will be useful, |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
e22f8b7c | 14 | # |
c906108c | 15 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 17 | |
c906108c SS |
18 | # Test GDB's ability to restore saved registers from stack frames |
19 | # when using the `return' command. | |
20 | # | |
21 | # This file was written by Jim Blandy <jimb@cygnus.com>, with | |
22 | # fragments borrowed from return.exp. | |
23 | ||
e229648e JK |
24 | standard_testfile |
25 | set executable $testfile | |
c906108c | 26 | |
e229648e | 27 | if { [prepare_for_testing $testfile.exp $executable $srcfile] } { |
b60f0898 | 28 | return -1 |
c906108c SS |
29 | } |
30 | ||
31 | proc restore_tests { } { | |
32 | global gdb_prompt | |
33 | ||
029d2200 AC |
34 | if { ! [ runto driver ] } { |
35 | return 0 | |
36 | } | |
c906108c SS |
37 | |
38 | set limit 5 | |
39 | ||
c906108c SS |
40 | # For each caller function, |
41 | # call each of the callee functions, | |
42 | # force a return from the callee, and | |
43 | # make sure that the local variables still have the right values. | |
029d2200 | 44 | |
c906108c SS |
45 | for {set c 1} {$c <= $limit} {incr c} { |
46 | ||
1b8947f0 | 47 | # Set a breakpoint at the next caller function. |
18ac113b | 48 | gdb_test "tbreak caller$c" "Temporary breakpoint.*\[0-9\]*\\." \ |
029d2200 | 49 | "tbreak caller$c" |
1b8947f0 | 50 | |
c906108c | 51 | # Continue to the next caller function. |
029d2200 | 52 | gdb_test "continue" " caller$c prologue .*" "run to caller$c" |
c906108c SS |
53 | |
54 | # Do each callee function. | |
55 | for {set e 1} {$e <= $limit} {incr e} { | |
1b8947f0 | 56 | |
18ac113b | 57 | gdb_test "tbreak callee$e" "Temporary breakpoint.*\[0-9\]*\\." \ |
029d2200 | 58 | "caller$c calls callee$e; tbreak callee" |
1b8947f0 | 59 | |
029d2200 AC |
60 | gdb_test "continue" " callee$e prologue .*/" \ |
61 | "caller$c calls callee$e; continue to callee" | |
62 | ||
c906108c | 63 | # Do a forced return from the callee. |
029d2200 | 64 | set test "caller$c calls callee$e; return callee now" |
02746bbc MS |
65 | |
66 | gdb_test "return 0" \ | |
67 | " caller$c .*" \ | |
68 | "$test" \ | |
69 | "Make .* return now.*y or n. $" \ | |
70 | "y" | |
c906108c SS |
71 | |
72 | # Check that the values of the local variables are what | |
73 | # they should be. | |
74 | for {set var 1} {$var <= $c} {incr var} { | |
d4f3574e | 75 | set expected [expr 0x7eeb + $var] |
c906108c | 76 | gdb_test "print l$var" " = $expected" \ |
029d2200 | 77 | "caller$c calls callee$e; return restored l$var to $expected" |
c906108c SS |
78 | } |
79 | } | |
80 | } | |
81 | ||
958a4e4c MS |
82 | if ![gdb_skip_stdio_test "run to completion"] { |
83 | send_gdb "continue\n" | |
84 | ||
85 | gdb_expect { | |
86 | -re "exiting" { | |
87 | pass "run to completion" | |
88 | } | |
89 | timeout { | |
90 | fail "(timeout) run to completion" | |
91 | } | |
92 | } | |
93 | } else { | |
de7ff789 | 94 | gdb_test "continue" ".*" "" |
c906108c SS |
95 | } |
96 | } | |
97 | ||
97f2ed50 | 98 | set prev_timeout $timeout |
c906108c SS |
99 | set timeout 30 |
100 | restore_tests | |
97f2ed50 | 101 | set timeout $prev_timeout |