Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / return.exp
CommitLineData
6aba47ca 1# Copyright (C) 1992, 1997, 2001, 2007 Free Software Foundation, Inc.
c906108c
SS
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
c906108c 6# (at your option) any later version.
e22f8b7c 7#
c906108c
SS
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.
e22f8b7c 12#
c906108c 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
15
16# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@prep.ai.mit.edu
18
19# This file was written by Jeff Law. (law@cs.utah.edu)
20
21if $tracelevel then {
22 strace $tracelevel
23}
24
25set prms_id 0
26set bug_id 0
27
28set testfile "return"
29set srcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}
31if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
32 untested return.exp
33 return -1
c906108c
SS
34}
35
36proc return_tests { } {
37 global gdb_prompt
38
39
40 if { ! [ runto func1 ] } then { return 0 }
41 send_gdb "return\n"
42 gdb_expect {
43 -re "Make .* return now.*y or n. $" {
44 send_gdb "y\n"
45 exp_continue
46 }
47 -re "func1 ..;.*$gdb_prompt $" {
48 send_gdb "step\n"
49 exp_continue
50 }
51 -re ".*in main after func1.*$gdb_prompt $" { pass "simple return" }
52 -re "$gdb_prompt $" { fail "simple return" }
53 timeout { fail "(timeout) simple return" }
54 }
55
56 # Set breakpoints in other interesting functions.
57 gdb_test "break func2" "" "break func2"
58 gdb_test "break func3" "" "break func3"
59
60 gdb_test "continue" "return -5;" "continue to return of -5"
61 send_gdb "return 5\n"
62 gdb_expect {
63 -re "Make .* return now.*y or n. $" {
64 send_gdb "y\n"
65 exp_continue
66 }
67 -re ".*tmp2 = func2.*$gdb_prompt $" { }
68 -re "$gdb_prompt $" { fail "did not return (integer test)" }
69 timeout { fail "(timeout) did not return (integer test)" }
70 }
71 gdb_test "next" "tmp3 = func3.*" "next over call to func2"
72
73 gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
74
75 gdb_test "continue" "return -5.0;" "continue to return of -5.0"
d6f5fea1
SC
76
77 # Return of a double does not work for 68hc11 (need struct return
78 # in memory).
79 setup_xfail "m6811-*-*"
c906108c
SS
80 send_gdb "return 5.0\n"
81 gdb_expect {
82 -re "Make .* return now.*y or n. $" {
83 send_gdb "y\n"
84 exp_continue
85 }
86 -re ".*tmp3 = func3.*$gdb_prompt $" { }
87 -re "$gdb_prompt $" { fail "did not return (double test)" }
88 timeout { fail "(timeout) did not return (double test)" }
89 }
90
d6f5fea1 91 setup_xfail "m6811-*-*"
c906108c
SS
92 gdb_test "next" "printf.*" "next over call to func3"
93
c906108c
SS
94 # This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
95 # At the time the `next' is issued, the floating point unit for the
96 # process is not yet initialized, and the storing of the floating
97 # point value to the floating point return register is ignored.
98 # Xfail it for current versions that are known to fail. Presumably
99 # if some future version does initialize the floating point unit at
100 # process start, making this test pass, it will be for a version that
101 # is not xfailed.
102
1f36144c
MK
103 setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
104 gdb_test "p tmp3" ".* = 5.*" "correct value returned double test (known problem with sparc solaris)"
c906108c
SS
105}
106
107
108# Start with a fresh gdb.
109
110gdb_exit
111gdb_start
112gdb_reinitialize_dir $srcdir/$subdir
113gdb_load ${binfile}
114
115set timeout 30
116return_tests
This page took 0.752529 seconds and 4 git commands to generate.