]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/return.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / return.exp
CommitLineData
618f726f 1# Copyright (C) 1992-2016 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
dbc52822
VP
18if { [prepare_for_testing return.exp "return"] } {
19 return -1
c906108c
SS
20}
21
22proc return_tests { } {
23 global gdb_prompt
24
25
26 if { ! [ runto func1 ] } then { return 0 }
02746bbc
MS
27
28 gdb_test_multiple "return" "simple return" {
c906108c
SS
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 }
02746bbc
MS
37 -re ".*in main after func1.*$gdb_prompt $" {
38 pass "simple return"
39 }
c906108c
SS
40 }
41
42 # Set breakpoints in other interesting functions.
f6978de9
MS
43 gdb_test "break func2" ".*" "break func2"
44 gdb_test "break func3" ".*" "break func3"
c906108c
SS
45
46 gdb_test "continue" "return -5;" "continue to return of -5"
02746bbc
MS
47
48 gdb_test_multiple "return 5" "return value 5" {
c906108c
SS
49 -re "Make .* return now.*y or n. $" {
50 send_gdb "y\n"
51 exp_continue
52 }
02746bbc
MS
53 -re ".*tmp2 = func2.*$gdb_prompt $" {
54 # pass without comment
55 }
c906108c 56 }
02746bbc 57
c906108c
SS
58 gdb_test "next" "tmp3 = func3.*" "next over call to func2"
59
60 gdb_test "p tmp2" ".* = 5" "correct value returned (integer test)"
61
62 gdb_test "continue" "return -5.0;" "continue to return of -5.0"
d6f5fea1
SC
63
64 # Return of a double does not work for 68hc11 (need struct return
65 # in memory).
66 setup_xfail "m6811-*-*"
02746bbc
MS
67
68 gdb_test_multiple "return 5.0" "return value 5.0" {
c906108c
SS
69 -re "Make .* return now.*y or n. $" {
70 send_gdb "y\n"
71 exp_continue
72 }
02746bbc
MS
73 -re ".*tmp3 = func3.*$gdb_prompt $" {
74 # pass without comment
75 }
c906108c
SS
76 }
77
d6f5fea1 78 setup_xfail "m6811-*-*"
c906108c
SS
79 gdb_test "next" "printf.*" "next over call to func3"
80
c906108c
SS
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
88 # is not xfailed.
89
1f36144c 90 setup_xfail "sparc-*-solaris2.3*" "sparc-*-solaris2.4*" "m6811-*-*"
d426f7b4
MS
91 if ![target_info exists gdb,skip_float_tests] {
92 gdb_test "p tmp3" ".* = 5.*" \
93 "correct value returned double test (known problem with sparc solaris)"
94 }
c906108c
SS
95}
96
97f2ed50 97set prev_timeout $timeout
c906108c
SS
98set timeout 30
99return_tests
97f2ed50 100set timeout $prev_timeout