2004-07-16 22:21:52 +00:00
|
|
|
# This testcase is part of GDB, the GNU debugger.
|
|
|
|
|
2014-01-01 03:54:24 +00:00
|
|
|
# Copyright 1998-2014 Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00: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 18:14:19 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-04-16 01:35:26 +00:00
|
|
|
# (at your option) any later version.
|
2007-08-23 18:14:19 +00:00
|
|
|
#
|
1999-04-16 01:35:26 +00: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 18:14:19 +00:00
|
|
|
#
|
1999-04-16 01:35:26 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-08-23 18:14:19 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1999-04-16 01:35:26 +00: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.
|
|
|
|
|
2013-01-26 18:43:43 +00:00
|
|
|
standard_testfile
|
|
|
|
set executable $testfile
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2013-01-26 18:43:43 +00:00
|
|
|
if { [prepare_for_testing $testfile.exp $executable $srcfile] } {
|
2006-08-10 05:27:22 +00:00
|
|
|
return -1
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proc restore_tests { } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
2004-07-16 22:21:52 +00:00
|
|
|
if { ! [ runto driver ] } {
|
|
|
|
return 0
|
|
|
|
}
|
1999-04-16 01:35:26 +00: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-16 22:21:52 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
for {set c 1} {$c <= $limit} {incr c} {
|
|
|
|
|
2001-09-17 19:42:28 +00:00
|
|
|
# Set a breakpoint at the next caller function.
|
2008-04-15 14:33:55 +00:00
|
|
|
gdb_test "tbreak caller$c" "Temporary breakpoint.*\[0-9\]*\\." \
|
2004-07-16 22:21:52 +00:00
|
|
|
"tbreak caller$c"
|
2001-09-17 19:42:28 +00:00
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
# Continue to the next caller function.
|
2004-07-16 22:21:52 +00:00
|
|
|
gdb_test "continue" " caller$c prologue .*" "run to caller$c"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
# Do each callee function.
|
|
|
|
for {set e 1} {$e <= $limit} {incr e} {
|
2001-09-17 19:42:28 +00:00
|
|
|
|
2008-04-15 14:33:55 +00:00
|
|
|
gdb_test "tbreak callee$e" "Temporary breakpoint.*\[0-9\]*\\." \
|
2004-07-16 22:21:52 +00:00
|
|
|
"caller$c calls callee$e; tbreak callee"
|
2001-09-17 19:42:28 +00:00
|
|
|
|
2004-07-16 22:21:52 +00:00
|
|
|
gdb_test "continue" " callee$e prologue .*/" \
|
|
|
|
"caller$c calls callee$e; continue to callee"
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
# Do a forced return from the callee.
|
2004-07-16 22:21:52 +00:00
|
|
|
set test "caller$c calls callee$e; return callee now"
|
2010-05-27 23:44:51 +00:00
|
|
|
|
|
|
|
gdb_test "return 0" \
|
|
|
|
" caller$c .*" \
|
|
|
|
"$test" \
|
|
|
|
"Make .* return now.*y or n. $" \
|
|
|
|
"y"
|
1999-04-16 01:35:26 +00: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 00:02:17 +00:00
|
|
|
set expected [expr 0x7eeb + $var]
|
1999-04-16 01:35:26 +00:00
|
|
|
gdb_test "print l$var" " = $expected" \
|
2004-07-16 22:21:52 +00:00
|
|
|
"caller$c calls callee$e; return restored l$var to $expected"
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-14 22:12:26 +00: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-08 22:58:03 +00:00
|
|
|
gdb_test "continue" ".*" ""
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* 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 15:38:38 +00:00
|
|
|
set prev_timeout $timeout
|
1999-04-16 01:35:26 +00: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 15:38:38 +00:00
|
|
|
set timeout $prev_timeout
|