This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / restore.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1998 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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# Test GDB's ability to restore saved registers from stack frames
21# when using the `return' command.
22#
23# This file was written by Jim Blandy <jimb@cygnus.com>, with
24# fragments borrowed from return.exp.
25
26if $tracelevel then {
27 strace $tracelevel
28}
29
30set prms_id 0
31set bug_id 0
32
33set testfile "restore"
34set srcfile ${testfile}.c
35set binfile ${objdir}/${subdir}/${testfile}
36if { [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."
38}
39
40proc restore_tests { } {
41 global gdb_prompt
42
43 if { ! [ runto driver ] } then { return 0 }
44
45 set limit 5
46
47 # Set breakpoints at each of the `caller' functions.
48 for {set c 1} {$c <= $limit} {incr c} {
49 gdb_test "break caller$c" "Breakpoint.*\[0-9\]*\\." "break caller$c"
50 }
51
52 # Set breakpoints at each of the `callee' functions.
53 for {set c 1} {$c <= $limit} {incr c} {
54 gdb_test "break callee$c" "Breakpoint.*\[0-9\]*\\." "break caller$c"
55 }
56
57 # For each caller function,
58 # call each of the callee functions,
59 # force a return from the callee, and
60 # make sure that the local variables still have the right values.
61 for {set c 1} {$c <= $limit} {incr c} {
62
63 # Continue to the next caller function.
64 gdb_test "continue" ".*/\\* caller$c \\*/" "run to caller$c"
65
66 # Do each callee function.
67 for {set e 1} {$e <= $limit} {incr e} {
68 gdb_test " continue" ".*/\\* callee$e \\*/" "run to callee$e"
69
70 # Do a forced return from the callee.
71 send_gdb "return 0\n"
72 gdb_expect {
73 -re "Make .* return now.*y or n. $" {
74 send_gdb "y\n"
75 exp_continue
76 }
77 -re "$gdb_prompt $" { }
78 }
79
80 # Check that the values of the local variables are what
81 # they should be.
82 for {set var 1} {$var <= $c} {incr var} {
83 set expected [expr 0xfeeb + $var]
84 gdb_test "print l$var" " = $expected" \
85 "caller$c called callee$e; variable l$var restored"
86 }
87 }
88 }
89
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}
101
102
103# Start with a fresh gdb.
104
105gdb_exit
106gdb_start
107gdb_reinitialize_dir $srcdir/$subdir
108gdb_load ${binfile}
109
110set timeout 30
111restore_tests
This page took 0.027158 seconds and 4 git commands to generate.