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