2010-05-27 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / return2.exp
CommitLineData
4c38e0a4
JB
1# Copyright 2000, 2001, 2004, 2007, 2008, 2009, 2010
2# Free Software Foundation, Inc.
efb66345
MS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
efb66345 7# (at your option) any later version.
e22f8b7c 8#
efb66345
MS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
efb66345 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
efb66345 16
efb66345
MS
17# This file was written by Michael Snyder (msnyder@redhat.com)
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
efb66345
MS
23
24set testfile "return2"
25set srcfile ${testfile}.c
26set binfile ${objdir}/${subdir}/${testfile}
27if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
28 untested return2.exp
29 return -1
efb66345
MS
30}
31
32proc return_1 { type } {
33 global gdb_prompt
34
35 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
36 "set break on ${type}_func"
37 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
38 "continue to ${type}_func"
39 send_gdb "return testval.${type}_testval\n"
40 gdb_expect {
41 -re "Make ${type}_func return now.*y or n. $" {
42 send_gdb "y\n"
43 exp_continue
44 }
45 -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
46 send_gdb "step\n"
47 exp_continue
48 }
49 -re ".*${type}_checkpoint.*$gdb_prompt $" {
50 pass "return from ${type}_func"
51 }
52 -re ".*$gdb_prompt $" {
53 fail "return from ${type}_func"
54 }
55 timeout {
56 fail "return from ${type}_func (timeout)"
57 }
58 }
59 gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
60 "${type} value returned successfully"
61 gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
62 "validate result value not equal to program return value"
63}
64
65proc return_void { } {
66 global gdb_prompt
67
68 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
69 "set break on void_func"
70 gdb_test "continue" "Breakpoint.* void_func.*" \
71 "continue to void_func"
72 send_gdb "return \n"
73 gdb_expect {
74 -re "Make void_func return now.*y or n. $" {
75 send_gdb "y\n"
76 exp_continue
77 }
78 -re ".*void_func.*call to void_func.*$gdb_prompt $" {
79 send_gdb "step\n"
80 exp_continue
81 }
82 -re ".*void_checkpoint.*$gdb_prompt $" {
83 pass "return from void_func"
84 }
85 -re ".*$gdb_prompt $" {
86 fail "return from void_func"
87 }
88 timeout {
89 fail "return from void_func (timeout)"
90 }
91 }
92 gdb_test "print void_test == 0" ".* = 1" \
93 "void function returned successfully"
94}
95
96proc return2_tests { } {
97 global gdb_prompt
98
3ad13771 99 if { ! [ runto_main ] } then {
b60f0898
JB
100 untested return2.exp
101 return -1
efb66345
MS
102 }
103
104 return_void
105 return_1 "char"
106 return_1 "short"
107 return_1 "int"
108 return_1 "long"
686d097c 109 if { ! [istarget "m6811-*-*"] && ![istarget "h8300*-*"] } then {
d6f5fea1
SC
110 return_1 "long_long"
111 }
efb66345 112 return_1 "float"
d6f5fea1
SC
113 if { ! [istarget "m6811-*-*"] } then {
114 return_1 "double"
115 }
efb66345
MS
116}
117
118# Start with a fresh gdb.
119
120gdb_exit
121gdb_start
122gdb_reinitialize_dir $srcdir/$subdir
123gdb_load ${binfile}
124
125set timeout 30
126return2_tests
This page took 0.902248 seconds and 4 git commands to generate.