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