]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/return.exp
2010-06-08 Michael Snyder <msnyder@vmware.com>
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / return.exp
CommitLineData
4c38e0a4 1# Copyright (C) 1992, 1997, 2001, 2007, 2008, 2009, 2010
0fb0cc75 2# Free Software Foundation, Inc.
c906108c
SS
3
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
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
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.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17# This file was written by Jeff Law. (law@cs.utah.edu)
18
dbc52822
VP
19if { [prepare_for_testing return.exp "return"] } {
20 return -1
c906108c
SS
21}
22
23proc return_tests { } {
24 global gdb_prompt
25
26
27 if { ! [ runto func1 ] } then { return 0 }
02746bbc
MS
28
29 gdb_test_multiple "return" "simple return" {
c906108c
SS
30 -re "Make .* return now.*y or n. $" {
31 send_gdb "y\n"
32 exp_continue
33 }
34 -re "func1 ..;.*$gdb_prompt $" {
35 send_gdb "step\n"
36 exp_continue
37 }
02746bbc
MS
38 -re ".*in main after func1.*$gdb_prompt $" {
39 pass "simple return"
40 }
c906108c
SS
41 }
42
43 # Set breakpoints in other interesting functions.
f6978de9
MS
44 gdb_test "break func2" ".*" "break func2"
45 gdb_test "break func3" ".*" "break func3"
c906108c
SS
46
47 gdb_test "continue" "return -5;" "continue to return of -5"
02746bbc
MS
48
49 gdb_test_multiple "return 5" "return value 5" {
c906108c
SS
50 -re "Make .* return now.*y or n. $" {
51 send_gdb "y\n"
52 exp_continue
53 }
02746bbc
MS
54 -re ".*tmp2 = func2.*$gdb_prompt $" {
55 # pass without comment
56 }
c906108c 57 }
02746bbc 58
c906108c
SS
59 gdb_test "next" "tmp3 = func3.*" "next over call to func2"
60
61 gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
62
63 gdb_test "continue" "return -5.0;" "continue to return of -5.0"
d6f5fea1
SC
64
65 # Return of a double does not work for 68hc11 (need struct return
66 # in memory).
67 setup_xfail "m6811-*-*"
02746bbc
MS
68
69 gdb_test_multiple "return 5.0" "return value 5.0" {
c906108c
SS
70 -re "Make .* return now.*y or n. $" {
71 send_gdb "y\n"
72 exp_continue
73 }
02746bbc
MS
74 -re ".*tmp3 = func3.*$gdb_prompt $" {
75 # pass without comment
76 }
c906108c
SS
77 }
78
d6f5fea1 79 setup_xfail "m6811-*-*"
c906108c
SS
80 gdb_test "next" "printf.*" "next over call to func3"
81
c906108c
SS
82 # This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
83 # At the time the `next' is issued, the floating point unit for the
84 # process is not yet initialized, and the storing of the floating
85 # point value to the floating point return register is ignored.
86 # Xfail it for current versions that are known to fail. Presumably
87 # if some future version does initialize the floating point unit at
88 # process start, making this test pass, it will be for a version that
89 # is not xfailed.
90
1f36144c
MK
91 setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
92 gdb_test "p tmp3" ".* = 5.*" "correct value returned double test (known problem with sparc solaris)"
c906108c
SS
93}
94
97f2ed50 95set prev_timeout $timeout
c906108c
SS
96set timeout 30
97return_tests
97f2ed50 98set timeout $prev_timeout