Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / return.exp
CommitLineData
b811d2c2 1# Copyright (C) 1992-2020 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 15
c906108c
SS
16# This file was written by Jeff Law. (law@cs.utah.edu)
17
5b362f04 18if { [prepare_for_testing "failed to prepare" "return"] } {
dbc52822 19 return -1
c906108c
SS
20}
21
27aba047
YQ
22set skip_float_test [gdb_skip_float_test]
23
c906108c 24proc return_tests { } {
27aba047 25 global gdb_prompt skip_float_test
c906108c
SS
26
27
28 if { ! [ runto func1 ] } then { return 0 }
02746bbc
MS
29
30 gdb_test_multiple "return" "simple return" {
c906108c
SS
31 -re "Make .* return now.*y or n. $" {
32 send_gdb "y\n"
33 exp_continue
34 }
35 -re "func1 ..;.*$gdb_prompt $" {
36 send_gdb "step\n"
37 exp_continue
38 }
02746bbc
MS
39 -re ".*in main after func1.*$gdb_prompt $" {
40 pass "simple return"
41 }
c906108c
SS
42 }
43
44 # Set breakpoints in other interesting functions.
11af934b
TV
45 gdb_test "break func2" ".*"
46 gdb_test "break func3" ".*"
c906108c
SS
47
48 gdb_test "continue" "return -5;" "continue to return of -5"
02746bbc
MS
49
50 gdb_test_multiple "return 5" "return value 5" {
c906108c
SS
51 -re "Make .* return now.*y or n. $" {
52 send_gdb "y\n"
53 exp_continue
54 }
02746bbc
MS
55 -re ".*tmp2 = func2.*$gdb_prompt $" {
56 # pass without comment
57 }
c906108c 58 }
02746bbc 59
c906108c
SS
60 gdb_test "next" "tmp3 = func3.*" "next over call to func2"
61
62 gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
63
64 gdb_test "continue" "return -5.0;" "continue to return of -5.0"
d6f5fea1
SC
65
66 # Return of a double does not work for 68hc11 (need struct return
67 # in memory).
68 setup_xfail "m6811-*-*"
02746bbc
MS
69
70 gdb_test_multiple "return 5.0" "return value 5.0" {
c906108c
SS
71 -re "Make .* return now.*y or n. $" {
72 send_gdb "y\n"
73 exp_continue
74 }
02746bbc
MS
75 -re ".*tmp3 = func3.*$gdb_prompt $" {
76 # pass without comment
77 }
c906108c
SS
78 }
79
d6f5fea1 80 setup_xfail "m6811-*-*"
c906108c
SS
81 gdb_test "next" "printf.*" "next over call to func3"
82
c906108c
SS
83 # This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
84 # At the time the `next' is issued, the floating point unit for the
85 # process is not yet initialized, and the storing of the floating
86 # point value to the floating point return register is ignored.
87 # Xfail it for current versions that are known to fail. Presumably
88 # if some future version does initialize the floating point unit at
89 # process start, making this test pass, it will be for a version that
90 # is not xfailed.
91
1f36144c 92 setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
27aba047 93 if {!$skip_float_test} {
d426f7b4
MS
94 gdb_test "p tmp3" ".* = 5.*" \
95 "correct value returned double test (known problem with sparc solaris)"
96 }
c906108c
SS
97}
98
97f2ed50 99set prev_timeout $timeout
c906108c
SS
100set timeout 30
101return_tests
97f2ed50 102set timeout $prev_timeout
This page took 2.028866 seconds and 4 git commands to generate.