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