Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / restore.exp
blob1ee71d631d29033157f56c8f12f88ab4479dfd23
1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 1998, 1999, 2000, 2001, 2002, 2004 Free Software
4 # Foundation, Inc.
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
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Test GDB's ability to restore saved registers from stack frames
21 # when using the `return' command.
23 # This file was written by Jim Blandy <jimb@cygnus.com>, with
24 # fragments borrowed from return.exp.
26 if $tracelevel then {
27 strace $tracelevel
30 set prms_id 0
31 set bug_id 0
33 set testfile "restore"
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
36 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40 proc restore_tests { } {
41 global gdb_prompt
43 if { ! [ runto driver ] } {
44 return 0
47 set limit 5
49 # For each caller function,
50 # call each of the callee functions,
51 # force a return from the callee, and
52 # make sure that the local variables still have the right values.
54 for {set c 1} {$c <= $limit} {incr c} {
56 # Set a breakpoint at the next caller function.
57 gdb_test "tbreak caller$c" "Breakpoint.*\[0-9\]*\\." \
58 "tbreak caller$c"
60 # Continue to the next caller function.
61 gdb_test "continue" " caller$c prologue .*" "run to caller$c"
63 # Do each callee function.
64 for {set e 1} {$e <= $limit} {incr e} {
66 gdb_test "tbreak callee$e" "Breakpoint.*\[0-9\]*\\." \
67 "caller$c calls callee$e; tbreak callee"
69 gdb_test "continue" " callee$e prologue .*/" \
70 "caller$c calls callee$e; continue to callee"
72 # Do a forced return from the callee.
73 set test "caller$c calls callee$e; return callee now"
74 gdb_test_multiple "return 0" "$test" {
75 -re "Make .* return now.*y or n. $" {
76 send_gdb "y\n"
77 exp_continue
79 -re " caller$c .*$gdb_prompt $" {
80 pass "$test"
84 # Check that the values of the local variables are what
85 # they should be.
86 for {set var 1} {$var <= $c} {incr var} {
87 set expected [expr 0x7eeb + $var]
88 gdb_test "print l$var" " = $expected" \
89 "caller$c calls callee$e; return restored l$var to $expected"
94 if ![gdb_skip_stdio_test "run to completion"] {
95 send_gdb "continue\n"
97 gdb_expect {
98 -re "exiting" {
99 pass "run to completion"
101 timeout {
102 fail "(timeout) run to completion"
105 } else {
106 gdb_test "continue" "" ""
112 # Start with a fresh gdb.
114 gdb_exit
115 gdb_start
116 gdb_reinitialize_dir $srcdir/$subdir
117 gdb_load ${binfile}
119 set timeout 30
120 restore_tests