2004-07-17 00:21:52 +02:00
|
|
|
# This testcase is part of GDB, the GNU debugger.
|
|
|
|
|
2011-01-01 16:34:07 +01:00
|
|
|
# Copyright 1998, 1999, 2000, 2001, 2002, 2004, 2007, 2008, 2009, 2010, 2011
|
2007-01-09 18:59:20 +01:00
|
|
|
# Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-08-23 20:14:19 +02:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-04-16 03:35:26 +02:00
|
|
|
# (at your option) any later version.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2007-08-23 20:14:19 +02:00
|
|
|
#
|
1999-04-16 03:35:26 +02:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 20:14:19 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Test GDB's ability to restore saved registers from stack frames
|
|
|
|
# when using the `return' command.
|
|
|
|
#
|
|
|
|
# This file was written by Jim Blandy <jimb@cygnus.com>, with
|
|
|
|
# fragments borrowed from return.exp.
|
|
|
|
|
|
|
|
if $tracelevel then {
|
2004-07-17 00:21:52 +02:00
|
|
|
strace $tracelevel
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set testfile "restore"
|
|
|
|
set srcfile ${testfile}.c
|
|
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
2006-08-10 07:27:22 +02:00
|
|
|
untested restore.exp
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
proc restore_tests { } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
2004-07-17 00:21:52 +02:00
|
|
|
if { ! [ runto driver ] } {
|
|
|
|
return 0
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
set limit 5
|
|
|
|
|
|
|
|
# For each caller function,
|
|
|
|
# call each of the callee functions,
|
|
|
|
# force a return from the callee, and
|
|
|
|
# make sure that the local variables still have the right values.
|
2004-07-17 00:21:52 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
for {set c 1} {$c <= $limit} {incr c} {
|
|
|
|
|
2001-09-17 21:42:28 +02:00
|
|
|
# Set a breakpoint at the next caller function.
|
2008-04-15 16:33:55 +02:00
|
|
|
gdb_test "tbreak caller$c" "Temporary breakpoint.*\[0-9\]*\\." \
|
2004-07-17 00:21:52 +02:00
|
|
|
"tbreak caller$c"
|
2001-09-17 21:42:28 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
# Continue to the next caller function.
|
2004-07-17 00:21:52 +02:00
|
|
|
gdb_test "continue" " caller$c prologue .*" "run to caller$c"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Do each callee function.
|
|
|
|
for {set e 1} {$e <= $limit} {incr e} {
|
2001-09-17 21:42:28 +02:00
|
|
|
|
2008-04-15 16:33:55 +02:00
|
|
|
gdb_test "tbreak callee$e" "Temporary breakpoint.*\[0-9\]*\\." \
|
2004-07-17 00:21:52 +02:00
|
|
|
"caller$c calls callee$e; tbreak callee"
|
2001-09-17 21:42:28 +02:00
|
|
|
|
2004-07-17 00:21:52 +02:00
|
|
|
gdb_test "continue" " callee$e prologue .*/" \
|
|
|
|
"caller$c calls callee$e; continue to callee"
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
# Do a forced return from the callee.
|
2004-07-17 00:21:52 +02:00
|
|
|
set test "caller$c calls callee$e; return callee now"
|
2010-05-28 01:44:51 +02:00
|
|
|
|
|
|
|
gdb_test "return 0" \
|
|
|
|
" caller$c .*" \
|
|
|
|
"$test" \
|
|
|
|
"Make .* return now.*y or n. $" \
|
|
|
|
"y"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
# Check that the values of the local variables are what
|
|
|
|
# they should be.
|
|
|
|
for {set var 1} {$var <= $c} {incr var} {
|
1999-09-09 02:02:17 +02:00
|
|
|
set expected [expr 0x7eeb + $var]
|
1999-04-16 03:35:26 +02:00
|
|
|
gdb_test "print l$var" " = $expected" \
|
2004-07-17 00:21:52 +02:00
|
|
|
"caller$c calls callee$e; return restored l$var to $expected"
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-14 23:12:26 +01:00
|
|
|
if ![gdb_skip_stdio_test "run to completion"] {
|
|
|
|
send_gdb "continue\n"
|
|
|
|
|
|
|
|
gdb_expect {
|
|
|
|
-re "exiting" {
|
|
|
|
pass "run to completion"
|
|
|
|
}
|
|
|
|
timeout {
|
|
|
|
fail "(timeout) run to completion"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2010-06-09 00:58:03 +02:00
|
|
|
gdb_test "continue" ".*" ""
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 23:12:26 +01:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
# Start with a fresh gdb.
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
gdb_load ${binfile}
|
|
|
|
|
* gdb.base/call-strs.exp, gdb.base/default.exp,
gdb.base/ending-run.exp, gdb.base/finish.exp, gdb.base/funcargs.exp,
gdb.base/huge.exp, gdb.base/nodebug.exp, gdb.base/ptype.exp,
gdb.base/restore.exp, gdb.base/return.exp, gdb.base/setvar.exp,
gdb.base/watchpoints.exp, gdb.threads/gcore-thread.exp,
gdb.base/watchpoint-solib.exp: Save and restore timeout.
* gdb.base/ending-run.exp: Correct restore of timeout.
* gdb.base/page.exp: Remove unnecessary timeout setting.
2010-01-29 16:38:38 +01:00
|
|
|
set prev_timeout $timeout
|
1999-04-16 03:35:26 +02:00
|
|
|
set timeout 30
|
|
|
|
restore_tests
|
* gdb.base/call-strs.exp, gdb.base/default.exp,
gdb.base/ending-run.exp, gdb.base/finish.exp, gdb.base/funcargs.exp,
gdb.base/huge.exp, gdb.base/nodebug.exp, gdb.base/ptype.exp,
gdb.base/restore.exp, gdb.base/return.exp, gdb.base/setvar.exp,
gdb.base/watchpoints.exp, gdb.threads/gcore-thread.exp,
gdb.base/watchpoint-solib.exp: Save and restore timeout.
* gdb.base/ending-run.exp: Correct restore of timeout.
* gdb.base/page.exp: Remove unnecessary timeout setting.
2010-01-29 16:38:38 +01:00
|
|
|
set timeout $prev_timeout
|