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