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