]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/return.exp
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / return.exp
1 # Copyright (C) 1992, 1997 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Jeff Law. (law@cs.utah.edu)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 set testfile "return"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
34 }
35
36 proc 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"
76 send_gdb "return 5.0\n"
77 gdb_expect {
78 -re "Make .* return now.*y or n. $" {
79 send_gdb "y\n"
80 exp_continue
81 }
82 -re ".*tmp3 = func3.*$gdb_prompt $" { }
83 -re "$gdb_prompt $" { fail "did not return (double test)" }
84 timeout { fail "(timeout) did not return (double test)" }
85 }
86
87 gdb_test "next" "printf.*" "next over call to func3"
88
89 # This test is going to fail on all i*86 systems using an i*87.
90 # When returning a floating point value from a function, all known
91 # compilers do this via a `fldl' instruction, which pushes the floating
92 # value on the i387 stack. This causes two problems:
93 # a) Most i*86 targets do not store (or cannot store, see comment in
94 # in i386v-nat.c:i386_register_u_addr) the floating point registers
95 # to the target.
96 # b) gdb would have to figure out if the `fldl' instruction (or variants
97 # of it) has already been executed. If not, it would have to simulate
98 # a push instruction, as it is not enough to write the register,
99 # the floating point `stack pointer' has to be updated too.
100 # Do not expect this to get fixed anytime soon.
101
102 # This test also fails for sparc Solaris 2.3 & 2.4, but passes under 2.5
103 # At the time the `next' is issued, the floating point unit for the
104 # process is not yet initialized, and the storing of the floating
105 # point value to the floating point return register is ignored.
106 # Xfail it for current versions that are known to fail. Presumably
107 # if some future version does initialize the floating point unit at
108 # process start, making this test pass, it will be for a version that
109 # is not xfailed.
110
111 setup_xfail "i*86-*-*" "sparc-*-solaris2.3*" "sparc-*-solaris2.4*"
112 gdb_test "p tmp3" ".* = 5.*" "correct value returned double test (known problem with i*86 and sparc solaris"
113 }
114
115
116 # Start with a fresh gdb.
117
118 gdb_exit
119 gdb_start
120 gdb_reinitialize_dir $srcdir/$subdir
121 gdb_load ${binfile}
122
123 set timeout 30
124 return_tests