1 # Copyright (C) 1992, 1997, 2001, 2007, 2008, 2009
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Jeff Law. (law@cs.utah.edu)
19 if { [prepare_for_testing return.exp "return"] } {
23 proc return_tests { } {
27 if { ! [ runto func1 ] } then { return 0 }
30 -re "Make .* return now.*y or n. $" {
34 -re "func1 ..;.*$gdb_prompt $" {
38 -re ".*in main after func1.*$gdb_prompt $" { pass "simple return" }
39 -re "$gdb_prompt $" { fail "simple return" }
40 timeout { fail "(timeout) simple return" }
43 # Set breakpoints in other interesting functions.
44 gdb_test "break func2" "" "break func2"
45 gdb_test "break func3" "" "break func3"
47 gdb_test "continue" "return -5;" "continue to return of -5"
50 -re "Make .* return now.*y or n. $" {
54 -re ".*tmp2 = func2.*$gdb_prompt $" { }
55 -re "$gdb_prompt $" { fail "did not return (integer test)" }
56 timeout { fail "(timeout) did not return (integer test)" }
58 gdb_test "next" "tmp3 = func3.*" "next over call to func2"
60 gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
62 gdb_test "continue" "return -5.0;" "continue to return of -5.0"
64 # Return of a double does not work for 68hc11 (need struct return
66 setup_xfail "m6811-*-*"
67 send_gdb "return 5.0\n"
69 -re "Make .* return now.*y or n. $" {
73 -re ".*tmp3 = func3.*$gdb_prompt $" { }
74 -re "$gdb_prompt $" { fail "did not return (double test)" }
75 timeout { fail "(timeout) did not return (double test)" }
78 setup_xfail "m6811-*-*"
79 gdb_test "next" "printf.*" "next over call to func3"
81 # This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
82 # At the time the `next' is issued, the floating point unit for the
83 # process is not yet initialized, and the storing of the floating
84 # point value to the floating point return register is ignored.
85 # Xfail it for current versions that are known to fail. Presumably
86 # if some future version does initialize the floating point unit at
87 # process start, making this test pass, it will be for a version that
90 setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
91 gdb_test "p tmp3" ".* = 5.*" "correct value returned double test (known problem with sparc solaris)"