2012-01-04 09:17:56 +01:00
|
|
|
# Copyright (C) 1992, 1997, 2001, 2007-2012 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
|
|
|
|
|
|
|
# This file was written by Jeff Law. (law@cs.utah.edu)
|
|
|
|
|
2008-04-07 18:32:44 +02:00
|
|
|
if { [prepare_for_testing return.exp "return"] } {
|
|
|
|
return -1
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
proc return_tests { } {
|
|
|
|
global gdb_prompt
|
|
|
|
|
|
|
|
|
|
|
|
if { ! [ runto func1 ] } then { return 0 }
|
2010-05-28 01:44:51 +02:00
|
|
|
|
|
|
|
gdb_test_multiple "return" "simple return" {
|
1999-04-16 03:35:26 +02:00
|
|
|
-re "Make .* return now.*y or n. $" {
|
|
|
|
send_gdb "y\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
|
|
|
-re "func1 ..;.*$gdb_prompt $" {
|
|
|
|
send_gdb "step\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
2010-05-28 01:44:51 +02:00
|
|
|
-re ".*in main after func1.*$gdb_prompt $" {
|
|
|
|
pass "simple return"
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Set breakpoints in other interesting functions.
|
2010-06-10 21:48:20 +02:00
|
|
|
gdb_test "break func2" ".*" "break func2"
|
|
|
|
gdb_test "break func3" ".*" "break func3"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
gdb_test "continue" "return -5;" "continue to return of -5"
|
2010-05-28 01:44:51 +02:00
|
|
|
|
|
|
|
gdb_test_multiple "return 5" "return value 5" {
|
1999-04-16 03:35:26 +02:00
|
|
|
-re "Make .* return now.*y or n. $" {
|
|
|
|
send_gdb "y\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
2010-05-28 01:44:51 +02:00
|
|
|
-re ".*tmp2 = func2.*$gdb_prompt $" {
|
|
|
|
# pass without comment
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
2010-05-28 01:44:51 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
gdb_test "next" "tmp3 = func3.*" "next over call to func2"
|
|
|
|
|
|
|
|
gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
|
|
|
|
|
|
|
|
gdb_test "continue" "return -5.0;" "continue to return of -5.0"
|
2001-07-16 20:49:43 +02:00
|
|
|
|
|
|
|
# Return of a double does not work for 68hc11 (need struct return
|
|
|
|
# in memory).
|
|
|
|
setup_xfail "m6811-*-*"
|
2010-05-28 01:44:51 +02:00
|
|
|
|
|
|
|
gdb_test_multiple "return 5.0" "return value 5.0" {
|
1999-04-16 03:35:26 +02:00
|
|
|
-re "Make .* return now.*y or n. $" {
|
|
|
|
send_gdb "y\n"
|
|
|
|
exp_continue
|
|
|
|
}
|
2010-05-28 01:44:51 +02:00
|
|
|
-re ".*tmp3 = func3.*$gdb_prompt $" {
|
|
|
|
# pass without comment
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
}
|
|
|
|
|
2001-07-16 20:49:43 +02:00
|
|
|
setup_xfail "m6811-*-*"
|
1999-04-16 03:35:26 +02:00
|
|
|
gdb_test "next" "printf.*" "next over call to func3"
|
|
|
|
|
|
|
|
# This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
|
|
|
|
# At the time the `next' is issued, the floating point unit for the
|
|
|
|
# process is not yet initialized, and the storing of the floating
|
|
|
|
# point value to the floating point return register is ignored.
|
|
|
|
# Xfail it for current versions that are known to fail. Presumably
|
|
|
|
# if some future version does initialize the floating point unit at
|
|
|
|
# process start, making this test pass, it will be for a version that
|
|
|
|
# is not xfailed.
|
|
|
|
|
2002-08-17 12:22:01 +02:00
|
|
|
setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
|
2010-12-02 22:34:14 +01:00
|
|
|
if ![target_info exists gdb,skip_float_tests] {
|
|
|
|
gdb_test "p tmp3" ".* = 5.*" \
|
|
|
|
"correct value returned double test (known problem with sparc solaris)"
|
|
|
|
}
|
1999-04-16 03:35:26 +02: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 16:38:38 +01:00
|
|
|
set prev_timeout $timeout
|
1999-04-16 03:35:26 +02:00
|
|
|
set timeout 30
|
|
|
|
return_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
|