]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/return2.exp
Updated copyright notices for most files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / return2.exp
CommitLineData
9b254dd1 1# Copyright 2000, 2001, 2004, 2007, 2008 Free Software Foundation, Inc.
efb66345
MS
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
efb66345 6# (at your option) any later version.
e22f8b7c 7#
efb66345
MS
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#
efb66345 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/>.
efb66345
MS
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 Michael Snyder (msnyder@redhat.com)
20
21if $tracelevel then {
22 strace $tracelevel
23}
24
25set prms_id 0
26set bug_id 0
27
28set testfile "return2"
29set srcfile ${testfile}.c
30set binfile ${objdir}/${subdir}/${testfile}
31if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
32 untested return2.exp
33 return -1
efb66345
MS
34}
35
36proc return_1 { type } {
37 global gdb_prompt
38
39 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
40 "set break on ${type}_func"
41 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
42 "continue to ${type}_func"
43 send_gdb "return testval.${type}_testval\n"
44 gdb_expect {
45 -re "Make ${type}_func return now.*y or n. $" {
46 send_gdb "y\n"
47 exp_continue
48 }
49 -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
50 send_gdb "step\n"
51 exp_continue
52 }
53 -re ".*${type}_checkpoint.*$gdb_prompt $" {
54 pass "return from ${type}_func"
55 }
56 -re ".*$gdb_prompt $" {
57 fail "return from ${type}_func"
58 }
59 timeout {
60 fail "return from ${type}_func (timeout)"
61 }
62 }
63 gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
64 "${type} value returned successfully"
65 gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
66 "validate result value not equal to program return value"
67}
68
69proc return_void { } {
70 global gdb_prompt
71
72 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
73 "set break on void_func"
74 gdb_test "continue" "Breakpoint.* void_func.*" \
75 "continue to void_func"
76 send_gdb "return \n"
77 gdb_expect {
78 -re "Make void_func return now.*y or n. $" {
79 send_gdb "y\n"
80 exp_continue
81 }
82 -re ".*void_func.*call to void_func.*$gdb_prompt $" {
83 send_gdb "step\n"
84 exp_continue
85 }
86 -re ".*void_checkpoint.*$gdb_prompt $" {
87 pass "return from void_func"
88 }
89 -re ".*$gdb_prompt $" {
90 fail "return from void_func"
91 }
92 timeout {
93 fail "return from void_func (timeout)"
94 }
95 }
96 gdb_test "print void_test == 0" ".* = 1" \
97 "void function returned successfully"
98}
99
100proc return2_tests { } {
101 global gdb_prompt
102
3ad13771 103 if { ! [ runto_main ] } then {
b60f0898
JB
104 untested return2.exp
105 return -1
efb66345
MS
106 }
107
108 return_void
109 return_1 "char"
110 return_1 "short"
111 return_1 "int"
112 return_1 "long"
686d097c 113 if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
d6f5fea1
SC
114 return_1 "long_long"
115 }
efb66345 116 return_1 "float"
d6f5fea1
SC
117 if { ! [istarget "m6811-*-*"] } then {
118 return_1 "double"
119 }
efb66345
MS
120}
121
122# Start with a fresh gdb.
123
124gdb_exit
125gdb_start
126gdb_reinitialize_dir $srcdir/$subdir
127gdb_load ${binfile}
128
129set timeout 30
130return2_tests