This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / callfwmall.exp
1 # Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
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 Fred Fish. (fnf@cygnus.com)
21
22 # SAME tests as in callfns.exp but here the inferior program does not
23 # call malloc.
24
25
26
27 if $tracelevel then {
28 strace $tracelevel
29 }
30
31 set prms_id 0
32 set bug_id 0
33
34 set testfile "callfwmall"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
40 }
41
42 # Create and source the file that provides information about the compiler
43 # used to compile the test case.
44
45 if [get_compiler_info ${binfile}] {
46 return -1;
47 }
48
49 if {$hp_aCC_compiler} {
50 set prototypes 1
51 } else {
52 set prototypes 0
53 }
54
55
56 # The a29k can't call functions, so don't even bother with this test.
57 if [target_info exists gdb,cannot_call_functions] {
58 setup_xfail "*-*-*" 2416
59 fail "This target can not call functions"
60 continue
61 }
62
63 # Set the current language to C. This counts as a test. If it
64 # fails, then we skip the other tests.
65
66 proc set_lang_c {} {
67 global gdb_prompt
68
69 send_gdb "set language c\n"
70 gdb_expect {
71 -re ".*$gdb_prompt $" {}
72 timeout { fail "set language c (timeout)" ; return 0 }
73 }
74
75 send_gdb "show language\n"
76 gdb_expect {
77 -re ".* source language is \"c\".*$gdb_prompt $" {
78 pass "set language to \"c\""
79 return 1
80 }
81 -re ".*$gdb_prompt $" {
82 fail "setting language to \"c\""
83 return 0
84 }
85 timeout {
86 fail "can't show language (timeout)"
87 return 0
88 }
89 }
90 }
91
92 # FIXME: Before calling this proc, we should probably verify that
93 # we can call inferior functions and get a valid integral value
94 # returned.
95 # Note that it is OK to check for 0 or 1 as the returned values, because C
96 # specifies that the numeric value of a relational or logical expression
97 # (computed in the inferior) is 1 for true and 0 for false.
98
99 proc do_function_calls {} {
100 global prototypes
101 global gcc_compiled
102 # We need to up this because this can be really slow on some boards.
103 set timeout 60;
104
105 gdb_test "p t_char_values(0,0)" " = 0"
106 gdb_test "p t_char_values('a','b')" " = 1"
107 gdb_test "p t_char_values(char_val1,char_val2)" " = 1"
108 gdb_test "p t_char_values('a',char_val2)" " = 1"
109 gdb_test "p t_char_values(char_val1,'b')" " = 1"
110
111 gdb_test "p t_short_values(0,0)" " = 0"
112 gdb_test "p t_short_values(10,-23)" " = 1"
113 gdb_test "p t_short_values(short_val1,short_val2)" " = 1"
114 gdb_test "p t_short_values(10,short_val2)" " = 1"
115 gdb_test "p t_short_values(short_val1,-23)" " = 1"
116
117 gdb_test "p t_int_values(0,0)" " = 0"
118 gdb_test "p t_int_values(87,-26)" " = 1"
119 gdb_test "p t_int_values(int_val1,int_val2)" " = 1"
120 gdb_test "p t_int_values(87,int_val2)" " = 1"
121 gdb_test "p t_int_values(int_val1,-26)" " = 1"
122
123 gdb_test "p t_long_values(0,0)" " = 0"
124 gdb_test "p t_long_values(789,-321)" " = 1"
125 gdb_test "p t_long_values(long_val1,long_val2)" " = 1"
126 gdb_test "p t_long_values(789,long_val2)" " = 1"
127 gdb_test "p t_long_values(long_val1,-321)" " = 1"
128
129 if ![target_info exists gdb,skip_float_tests] {
130 gdb_test "p t_float_values(0.0,0.0)" " = 0"
131
132 # These next four tests fail on the mn10300.
133 # The first value is passed in regs, the other in memory.
134 # Gcc emits different stabs for the two parameters; the first is
135 # claimed to be a float, the second a double.
136 # dbxout.c in gcc claims this is the desired behavior.
137 setup_xfail "mn10300-*-*" "hppa*-*-*11*"
138 gdb_test "p t_float_values(3.14159,-2.3765)" " = 1"
139 setup_xfail "mn10300-*-*" "hppa*-*-*11*"
140 gdb_test "p t_float_values(float_val1,float_val2)" " = 1"
141 setup_xfail "mn10300-*-*" "hppa*-*-*11*"
142 gdb_test "p t_float_values(3.14159,float_val2)" " = 1"
143 setup_xfail "mn10300-*-*" "hppa*-*-*11*"
144 gdb_test "p t_float_values(float_val1,-2.3765)" " = 1"
145
146 # Test passing of arguments which might not be widened.
147 gdb_test "p t_float_values2(0.0,0.0)" " = 0"
148
149 # Although PR 5318 mentions SunOS specifically, this seems
150 # to be a generic problem on quite a few platforms.
151 if $prototypes then {
152 setup_xfail "sparc-*-*" "mips*-*-*" 5318
153 if {!$gcc_compiled} then {
154 setup_xfail "alpha-dec-osf2*" "i*86-*-sysv4*" 5318
155 }
156 }
157 gdb_test "p t_float_values2(3.14159,float_val2)" " = 1"
158 gdb_test "p t_small_values(1,2,3,4,5,6,7,8,9,10)" " = 55"
159
160 gdb_test "p t_double_values(0.0,0.0)" " = 0"
161 gdb_test "p t_double_values(45.654,-67.66)" " = 1"
162 gdb_test "p t_double_values(double_val1,double_val2)" " = 1"
163 gdb_test "p t_double_values(45.654,double_val2)" " = 1"
164 gdb_test "p t_double_values(double_val1,-67.66)" " = 1"
165
166 }
167
168 gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
169 gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
170 gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
171 gdb_test "p t_string_values(\"string 1\",string_val2)" " = 1"
172 gdb_test "p t_string_values(string_val1,\"string 2\")" " = 1"
173
174 gdb_test "p t_char_array_values(char_array_val2,char_array_val1)" " = 0"
175 gdb_test "p t_char_array_values(char_array_val1,char_array_val2)" " = 1"
176 gdb_test "p t_char_array_values(\"carray 1\",\"carray 2\")" " = 1"
177 gdb_test "p t_char_array_values(\"carray 1\",char_array_val2)" " = 1"
178 gdb_test "p t_char_array_values(char_array_val1,\"carray 2\")" " = 1"
179
180 gdb_test "p doubleit(4)" " = 8"
181 gdb_test "p add(4,5)" " = 9"
182 gdb_test "p t_func_values(func_val2,func_val1)" " = 0"
183 gdb_test "p t_func_values(func_val1,func_val2)" " = 1"
184
185 # On the rs6000, we need to pass the address of the trampoline routine,
186 # not the address of add itself. I don't know how to go from add to
187 # the address of the trampoline. Similar problems exist on the HPPA,
188 # and in fact can present an unsolvable problem as the stubs may not
189 # even exist in the user's program. We've slightly recoded t_func_values
190 # to avoid such problems in the common case. This may or may not help
191 # the RS6000.
192 setup_xfail "rs6000*-*-*"
193 setup_xfail "powerpc*-*-*"
194
195 if {!$gcc_compiled && [istarget hppa*-*-hpux*]} then {
196 send_gdb "p t_func_values(add,func_val2)\n"
197 gdb_expect {
198 -re "You cannot.*ignored.*" {pass "p t_func_values(add,func_val2)"}
199 -re "Program received signal SIGBUS, Bus error.*" {
200 if [istarget hppa*-*-hpux*] {
201 pass "p t_func_values(add,func_val2)"
202 } else {
203 fail "p t_func_values(add,func_val2)"
204 }
205 }
206 }
207 } else {
208 gdb_test "p t_func_values(add,func_val2)" " = 1"
209 }
210
211 setup_xfail "rs6000*-*-*"
212 setup_xfail "powerpc*-*-*"
213
214 if {!$gcc_compiled && [istarget hppa*-*-hpux*]} then {
215 send_gdb "p t_func_values(func_val1,doubleit)\n"
216 gdb_expect {
217 -re "You cannot.*ignored.*" {pass "p t_func_values(func_val1,doubleit)"}
218 -re "Program received signal SIGBUS, Bus error.*" {
219 if [istarget hppa*-*-hpux*] {
220 pass "p t_func_values(func_val1,doubleit)"
221 } else {
222 fail "p t_func_values(func_val1,doubleit)"
223 }
224 }
225 }
226 } else {
227 gdb_test "p t_func_values(func_val1,doubleit)" " = 1"
228 }
229
230 gdb_test "p t_call_add(func_val1,3,4)" " = 7"
231
232 setup_xfail "rs6000*-*-*"
233 setup_xfail "powerpc*-*-*"
234
235 if {!$gcc_compiled && [istarget hppa*-*-hpux*]} then {
236 send_gdb "p t_call_add(add,3,4)\n"
237 gdb_expect {
238 -re "You cannot.*ignored.*" {pass "p t_call_add(add,3,4)"}
239 -re "Program received signal SIGBUS, Bus error.*" {
240 if [istarget hppa*-*-hpux*] {
241 pass "p t_call_add(add,3,4)"
242 } else {
243 fail "p t_call_add(add,3,4)"
244 }
245 }
246 }
247 } else {
248 gdb_test "p t_call_add(add,3,4)" " = 7"
249 }
250
251 gdb_test "p t_enum_value1(enumval1)" " = 1"
252 gdb_test "p t_enum_value1(enum_val1)" " = 1"
253 gdb_test "p t_enum_value1(enum_val2)" " = 0"
254
255 gdb_test "p t_enum_value2(enumval2)" " = 1"
256 gdb_test "p t_enum_value2(enum_val2)" " = 1"
257 gdb_test "p t_enum_value2(enum_val1)" " = 0"
258
259 gdb_test "p sum_args(1,{2})" " = 2"
260 gdb_test "p sum_args(2,{2,3})" " = 5"
261 gdb_test "p sum_args(3,{2,3,4})" " = 9"
262 gdb_test "p sum_args(4,{2,3,4,5})" " = 14"
263 gdb_test "p sum10 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" " = 55"
264
265 gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \
266 "call inferior func with struct - returns char"
267 gdb_test "p t_structs_s(struct_val1)" "= 87" \
268 "call inferior func with struct - returns short"
269 gdb_test "p t_structs_i(struct_val1)" "= 76" \
270 "call inferior func with struct - returns int"
271 gdb_test "p t_structs_l(struct_val1)" "= 51" \
272 "call inferior func with struct - returns long"
273 setup_xfail "i*86-*-*"
274 gdb_test "p t_structs_f(struct_val1)" "= 2.12.*" \
275 "call inferior func with struct - returns float"
276 setup_xfail "i*86-*-*"
277 gdb_test "p t_structs_d(struct_val1)" "= 9.87.*" \
278 "call inferior func with struct - returns double"
279 gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
280 "call inferior func with struct - returns char *"
281
282 }
283
284 # Start with a fresh gdb.
285
286 gdb_exit
287 gdb_start
288 gdb_reinitialize_dir $srcdir/$subdir
289 gdb_load ${binfile}
290
291 gdb_test "set print sevenbit-strings" ""
292 gdb_test "set print address off" ""
293 gdb_test "set width 0" ""
294
295 if { $hp_aCC_compiler } {
296 # Do not set language explicitly to 'C'. This will cause aCC
297 # tests to fail because promotion rules are different. Just let
298 # the language be set to the default.
299
300 if { ![runto_main] } {
301 gdb_suppress_tests;
302 }
303
304 gdb_test "set overload-resolution 0" ".*"
305 } else {
306 if { ![set_lang_c] } {
307 gdb_suppress_tests;
308 } else {
309 if { ![runto_main] } {
310 gdb_suppress_tests;
311 }
312 }
313 }
314
315 gdb_test "next" ".*"
316 do_function_calls
317
318 return 0
This page took 0.03557 seconds and 4 git commands to generate.