2004-06-10 Michael Snyder <msnyder@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / structs.exp
CommitLineData
e53890ae
AC
1# This testcase is part of GDB, the GNU debugger.
2
18b67037 3# Copyright 1996, 1997, 1999, 2003, 2004 Free Software Foundation, Inc.
74cf1395
JM
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19# Please email any bugs, comments, and/or additions to this file to:
20# bug-gdb@prep.ai.mit.edu
21
74cf1395
JM
22if $tracelevel then {
23 strace $tracelevel
24}
25
26set prms_id 0
27set bug_id 0
28
e53890ae
AC
29# Some targets can't call functions, so don't even bother with this
30# test.
31
32if [target_info exists gdb,cannot_call_functions] {
33 setup_xfail "*-*-*"
34 fail "This target can not call functions"
35 continue
36}
37
74cf1395
JM
38set testfile "structs"
39set srcfile ${testfile}.c
40set binfile ${objdir}/${subdir}/${testfile}
41
e53890ae
AC
42# Create and source the file that provides information about the
43# compiler used to compile the test case.
853d6e5b 44
b4967060
AC
45if [get_compiler_info ${binfile}] {
46 return -1;
853d6e5b
AC
47}
48
e53890ae
AC
49# Compile a variant of structs.c using TYPES to specify the type of
50# the first N struct elements (the remaining elements take the type of
51# the last TYPES field). Run the compmiled program up to "main".
52# Also updates the global "testfile" to reflect the most recent build.
853d6e5b 53
e53890ae
AC
54proc start_structs_test { types } {
55 global testfile
56 global srcfile
57 global binfile
58 global objdir
59 global subdir
60 global srcdir
61 global gdb_prompt
62
63 # Create the additional flags
64 set flags "debug"
65 set testfile "structs"
66 set n 0
67 for {set n 0} {$n<[llength ${types}]} {incr n} {
68 set m [I2A ${n}]
69 set t [lindex ${types} $n]
70 lappend flags "additional_flags=-Dt${m}=${t}"
71 append testfile "-" "$t"
72 }
73
74 set binfile ${objdir}/${subdir}/${testfile}
75 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
76 # built the second test case since we can't use prototypes
77 warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
78 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } {
79 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
80 }
81 }
82
83 # Start with a fresh gdb.
e42c7771 84 gdb_exit
e53890ae
AC
85 gdb_start
86 gdb_reinitialize_dir $srcdir/$subdir
87 gdb_load ${binfile}
88
89 # Make certain that the output is consistent
90 gdb_test "set print sevenbit-strings" "" \
91 "set print sevenbit-strings; ${testfile}"
92 gdb_test "set print address off" "" \
93 "set print address off; ${testfile}"
94 gdb_test "set width 0" "" \
95 "set width 0; ${testfile}"
96
97 # Advance to main
98 if { ![runto_main] } then {
99 gdb_suppress_tests;
100 }
b729099e
MC
101
102 # Get the debug format
103 get_debug_format
e53890ae
AC
104
105 # check that at the struct containing all the relevant types is correct
106 set foo_t "type = struct struct[llength ${types}] \{"
107 for {set n 0} {$n<[llength ${types}]} {incr n} {
108 append foo_t "\[\r\n \]+[lindex ${types} $n] [i2a $n];"
109 }
110 append foo_t "\[\r\n \]+\}"
111 gdb_test "ptype foo[llength ${types}]" "${foo_t}" \
112 "ptype foo[llength ${types}]; ${testfile}"
74cf1395
JM
113}
114
e53890ae
AC
115# The expected value for fun${n}, L${n} and foo${n}. First element is
116# empty to make indexing easier. "foo" returns the modified value,
117# "zed" returns the invalid value.
853d6e5b 118
e53890ae
AC
119proc foo { n } {
120 return [lindex {
121 "{}"
122 "{a = 49 '1'}"
123 "{a = 97 'a', b = 50 '2'}"
124 "{a = 49 '1', b = 98 'b', c = 51 '3'}"
125 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4'}"
126 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5'}"
127 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6'}"
128 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7'}"
129 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8'}"
130 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9'}"
131 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A'}"
132 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B'}"
133 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C'}"
134 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D'}"
135 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E'}"
136 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F'}"
137 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E', o = 111 'o', p = 71 'G'}"
138 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F', p = 112 'p', q = 72 'H'}"
139 } $n]
140}
141
142proc zed { n } {
143 return [lindex {
144 "{}"
145 "{a = 90 'Z'}"
146 "{a = 90 'Z', b = 90 'Z'}"
147 "{a = 90 'Z', b = 90 'Z', c = 90 'Z'}"
148 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z'}"
149 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z'}"
150 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z'}"
151 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z'}"
152 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z'}"
153 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z'}"
154 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z'}"
155 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z'}"
156 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z'}"
157 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z'}"
158 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z'}"
159 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z'}"
160 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 90 'Z'}"
161 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 90 'Z', q = 90 'Z'}"
162 } $n]
163}
164
165# Given N (0..25), return the corresponding alphabetic letter in lower
166# or upper case. This is ment to be i18n proof.
167
168proc i2a { n } {
169 return [string range "abcdefghijklmnopqrstuvwxyz" $n $n]
170}
171
172proc I2A { n } {
173 return [string toupper [i2a $n]]
174}
175
176
177# Use the file name, compiler and tuples to set up any needed KFAILs.
178
179proc setup_kfails { file tuples bug } {
180 global testfile
181 if [string match $file $testfile] {
182 foreach f $tuples { setup_kfail $f $bug }
853d6e5b 183 }
74cf1395
JM
184}
185
e53890ae
AC
186proc setup_compiler_kfails { file compiler format tuples bug } {
187 global testfile
188 if {[string match $file $testfile] && [test_compiler_info $compiler] && [test_debug_format $format]} {
189 foreach f $tuples { setup_kfail $f $bug }
190 }
191}
192
193# Test GDB's ability to make inferior function calls to functions
194# returning (or passing in a single structs.
195
196# N identifies the number of elements in the struct that will be used
197# for the test case. FAILS is a list of target tuples that will fail
198# this test.
853d6e5b 199
e53890ae
AC
200# start_structs_test() will have previously built a program with a
201# specified combination of types for those elements. To ensure
202# robustness of the output, "p/c" is used.
203
204# This tests the code paths "which return-value convention?" and
205# "extract return-value from registers" called by "infcall.c".
206
207proc test_struct_calls { n } {
208 global testfile
b4967060 209 global gdb_prompt
853d6e5b 210
e53890ae
AC
211 # Check that GDB can always extract a struct-return value from an
212 # inferior function call. Since GDB always knows the location of an
213 # inferior function call's return value these should never fail
214
215 # Implemented by calling the parameterless function "fun$N" and then
216 # examining the return value printed by GDB.
853d6e5b 217
e53890ae 218 set tests "call $n ${testfile}"
853d6e5b 219
e53890ae 220 # Call fun${n}, checking the printed return-value.
b4d946af
AC
221 setup_compiler_kfails structs-tc-tll gcc-3-3 "DWARF 2" i*86-*-* gdb/1455
222 setup_compiler_kfails structs-tc-td gcc-3-3 "DWARF 2" i*86-*-* gdb/1455
e53890ae 223 gdb_test "p/c fun${n}()" "[foo ${n}]" "p/c fun<n>(); ${tests}"
853d6e5b 224
e53890ae
AC
225 # Check that GDB can always pass a structure to an inferior function.
226 # This test can never fail.
227
228 # Implemented by calling the one parameter function "Fun$N" which
229 # stores its parameter in the global variable "L$N". GDB then
230 # examining that global to confirm that the value is as expected.
231
232 gdb_test "call Fun${n}(foo${n})" "" "call Fun<n>(foo<n>); ${tests}"
b4d946af
AC
233 setup_compiler_kfails structs-tc-tll gcc-3-3 "DWARF 2" i*86-*-* gdb/1455
234 setup_compiler_kfails structs-tc-td gcc-3-3 "DWARF 2" i*86-*-* gdb/1455
e53890ae 235 gdb_test "p/c L${n}" [foo ${n}] "p/c L<n>; ${tests}"
b4967060 236}
853d6e5b 237
e53890ae
AC
238# Test GDB's ability to both return a function (with "return" or
239# "finish") and correctly extract/store any corresponding
240# return-value.
241
242# Check that GDB can consistently extract/store structure return
243# values. There are two cases - returned in registers and returned in
244# memory. For the latter case, the return value can't be found and a
245# failure is "expected". However GDB must still both return the
246# function and display the final source and line information.
247
248# N identifies the number of elements in the struct that will be used
249# for the test case. FAILS is a list of target tuples that will fail
250# this test.
251
252# This tests the code paths "which return-value convention?", "extract
253# return-value from registers", and "store return-value in registers".
254# Unlike "test struct calls", this test is expected to "fail" when the
255# return-value is in memory (GDB can't find the location). The test
256# is in three parts: test "return"; test "finish"; check that the two
257# are consistent. GDB can sometimes work for one command and not the
258# other.
259
260proc test_struct_returns { n } {
261 global gdb_prompt
262 global testfile
263
264 set tests "return $n ${testfile}"
265
266
267 # Check that "return" works.
268
269 # GDB must always force the return of a function that has
270 # a struct result. Dependant on the ABI, it may, or may not be
271 # possible to store the return value in a register.
272
273 # The relevant code looks like "L{n} = fun{n}()". The test forces
274 # "fun{n}" to "return" with an explicit value. Since that code
275 # snippet will store the the returned value in "L{n}" the return
276 # is tested by examining "L{n}". This assumes that the
277 # compiler implemented this as fun{n}(&L{n}) and hence that when
278 # the value isn't stored "L{n}" remains unchanged. Also check for
279 # consistency between this and the "finish" case.
280
281 # Get into a call of fun${n}
282 gdb_test "advance fun${n}" \
283 "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \
284 "advance to fun<n> for return; ${tests}"
285
286 # Check that the program invalidated the relevant global.
1bfbbb9d 287 gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for return; ${tests}"
e53890ae
AC
288
289 # Force the "return". This checks that the return is always
290 # performed, and that GDB correctly reported this to the user.
291 # GDB 6.0 and earlier, when the return-value's location wasn't
292 # known, both failed to print a final "source and line" and misplaced
293 # the frame ("No frame").
294
295 # The test is writen so that it only reports one FAIL/PASS for the
296 # entire operation. The value returned is checked further down.
b5c0bfa2
AC
297 # "return_value_known", if non-zero, indicates that GDB knew where
298 # the return value was located.
e53890ae 299
e53890ae 300 set test "return foo<n>; ${tests}"
b5c0bfa2 301 set return_value_known 1
5266b69c 302 set return_value_unimplemented 0
d422fe19 303 gdb_test_multiple "return foo${n}" "${test}" {
e53890ae
AC
304 -re "The location" {
305 # Ulgh, a struct return, remember this (still need prompt).
b5c0bfa2 306 set return_value_known 0
e53890ae
AC
307 exp_continue
308 }
309 -re "A structure or union" {
310 # Ulgh, a struct return, remember this (still need prompt).
b5c0bfa2 311 set return_value_known 0
5266b69c
AC
312 # Double ulgh. Architecture doesn't use return_value and
313 # hence hasn't implemented small structure return.
314 set return_value_unimplemented 1
e53890ae
AC
315 exp_continue
316 }
317 -re "Make fun${n} return now.*y or n. $" {
d422fe19 318 gdb_test_multiple "y" "${test}" {
e53890ae
AC
319 -re "L${n} *= fun${n}.*${gdb_prompt} $" {
320 # Need to step off the function call
321 gdb_test "next" "L.* *= fun.*" "${test}"
322 }
323 -re "L[expr ${n} + 1] *= fun[expr ${n} + 1].*${gdb_prompt} $" {
324 pass "${test}"
325 }
e53890ae
AC
326 }
327 }
e53890ae
AC
328 }
329
330 # Check that the return-value is as expected. At this stage we're
331 # just checking that GDB has returned a value consistent with
b5c0bfa2 332 # "return_value_known" set above.
e53890ae 333
e53890ae 334 set test "value foo<n> returned; ${tests}"
d422fe19 335 gdb_test_multiple "p/c L${n}" "${test}" {
e53890ae 336 -re " = [foo ${n}].*${gdb_prompt} $" {
b5c0bfa2
AC
337 if $return_value_known {
338 pass "${test}"
e53890ae
AC
339 # This contradicts the above claim that GDB didn't
340 # know the location of the return-value.
e53890ae 341 } else {
b5c0bfa2 342 fail "${test}"
e53890ae
AC
343 }
344 }
345 -re " = [zed ${n}].*${gdb_prompt} $" {
b5c0bfa2
AC
346 if $return_value_known {
347 # This contradicts the above claim that GDB knew
348 # the location of the return-value.
349 fail "${test}"
350 } else {
e53890ae
AC
351 # The struct return case. Since any modification
352 # would be by reference, and that can't happen, the
353 # value should be unmodified and hence Z is expected.
354 # Is this a reasonable assumption?
355 pass "${test}"
e53890ae
AC
356 }
357 }
5266b69c
AC
358 -re ".*${gdb_prompt} $" {
359 if $return_value_unimplemented {
360 # What a suprize. The architecture hasn't implemented
361 # return_value, and hence has to fail.
362 kfail "$test" gdb/1444
363 } else {
364 fail "$test"
365 }
366 }
e53890ae
AC
367 }
368
369 # Check that a "finish" works.
370
371 # This is almost but not quite the same as "call struct funcs".
372 # Architectures can have subtle differences in the two code paths.
373
374 # The relevant code snippet is "L{n} = fun{n}()". The program is
375 # advanced into a call to "fun{n}" and then that function is
376 # finished. The returned value that GDB prints, reformatted using
377 # "p/c", is checked.
378
379 # Get into "fun${n}()".
380 gdb_test "advance fun${n}" \
381 "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \
382 "advance to fun<n> for finish; ${tests}"
383
384 # Check that the program invalidated the relevant global.
e53890ae
AC
385 gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for finish; ${tests}"
386
b5c0bfa2
AC
387 # Finish the function, set 'finish_value_known" to non-empty if
388 # the return-value was found.
389
6882279b 390 set test "finish foo<n>; ${tests}"
b5c0bfa2 391 set finish_value_known 1
d422fe19 392 gdb_test_multiple "finish" "${test}" {
e53890ae
AC
393 -re "Value returned is .*${gdb_prompt} $" {
394 pass "${test}"
395 }
396 -re "Cannot determine contents.*${gdb_prompt} $" {
397 # Expected bad value. For the moment this is ok.
b5c0bfa2 398 set finish_value_known 0
e53890ae
AC
399 pass "${test}"
400 }
e53890ae
AC
401 }
402
403 # Re-print the last (return-value) using the more robust
404 # "p/c". If no return value was found, the 'Z' from the previous
405 # check that the variable was cleared, is printed.
6882279b 406 set test "value foo<n> finished; ${tests}"
d422fe19 407 gdb_test_multiple "p/c" "${test}" {
e53890ae 408 -re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" {
b5c0bfa2
AC
409 if $finish_value_known {
410 pass "${test}"
411 } else {
e53890ae
AC
412 # This contradicts the above claim that GDB didn't
413 # know the location of the return-value.
414 fail "${test}"
e53890ae
AC
415 }
416 }
417 -re "[zed ${n}]\[\r\n\]+${gdb_prompt} $" {
418 # The value didn't get found. This is "expected".
b5c0bfa2 419 if $finish_value_known {
e53890ae
AC
420 # This contradicts the above claim that GDB did
421 # know the location of the return-value.
422 fail "${test}"
b5c0bfa2
AC
423 } else {
424 pass "${test}"
e53890ae
AC
425 }
426 }
e53890ae
AC
427 }
428
429 # Finally, check that "return" and finish" have consistent
430 # behavior.
431
b5c0bfa2
AC
432 # Since "finish" works in more cases than "return" (see
433 # RETURN_VALUE_ABI_RETURNS_ADDRESS and
434 # RETURN_VALUE_ABI_PRESERVES_ADDRESS), the "return" value being
435 # known implies that the "finish" value is known (but not the
436 # reverse).
e53890ae 437
b5c0bfa2
AC
438 set test "return value known implies finish value known; ${tests}"
439 if {$return_value_known && ! $finish_value_known} {
e53890ae 440 kfail gdb/1444 "${test}"
b5c0bfa2
AC
441 } else {
442 pass "${test}"
e53890ae 443 }
b4967060 444}
853d6e5b 445
e53890ae
AC
446# ABIs pass anything >8 or >16 bytes in memory but below that things
447# randomly use register and/and structure conventions. Check all
448# possible sized char structs in that range. But only a restricted
449# range of the other types.
450
451# NetBSD/PPC returns "unnatural" (3, 5, 6, 7) sized structs in memory.
452
453# d10v is weird. 5/6 byte structs go in memory. 2 or more char
454# structs go in memory. Everything else is in a register!
455
456# Test every single char struct from 1..17 in size. This is what the
457# original "structs" test was doing.
458
459start_structs_test { tc }
460test_struct_calls 1
461test_struct_calls 2
462test_struct_calls 3
463test_struct_calls 4
464test_struct_calls 5
465test_struct_calls 6
466test_struct_calls 7
467test_struct_calls 8
468test_struct_calls 9
469test_struct_calls 10
470test_struct_calls 11
471test_struct_calls 12
472test_struct_calls 13
473test_struct_calls 14
474test_struct_calls 15
475test_struct_calls 16
476test_struct_calls 17
477test_struct_returns 1
478test_struct_returns 2
479test_struct_returns 3
480test_struct_returns 4
481test_struct_returns 5
482test_struct_returns 6
483test_struct_returns 7
484test_struct_returns 8
485
486
487# Let the fun begin.
488
489# Assuming that any integer struct larger than 8 bytes goes in memory,
490# come up with many and varied combinations of a return struct. For
491# "struct calls" test just beyond that 8 byte boundary, for "struct
492# returns" test up to that boundary.
493
494# For floats, assumed that up to two struct elements can be stored in
495# floating point registers, regardless of their size.
496
497# The approx size of each structure it is computed assumed that tc=1,
498# ts=2, ti=4, tl=4, tll=8, tf=4, td=8, tld=16, and that all fields are
499# naturally aligned. Padding being added where needed. Note that
500# these numbers are just approx, the d10v has ti=2, a 64-bit has has
501# tl=8.
502
503# Approx size: 2, 4, ...
504start_structs_test { ts }
505test_struct_calls 1
506test_struct_calls 2
507test_struct_calls 3
508test_struct_calls 4
509test_struct_calls 5
510test_struct_returns 1
511test_struct_returns 2
512test_struct_returns 3
513test_struct_returns 4
514
515# Approx size: 4, 8, ...
516start_structs_test { ti }
517test_struct_calls 1
518test_struct_calls 2
519test_struct_calls 3
520test_struct_returns 1
521test_struct_returns 2
522
523# Approx size: 4, 8, ...
524start_structs_test { tl }
525test_struct_calls 1
526test_struct_calls 2
527test_struct_calls 3
528test_struct_returns 1
529test_struct_returns 2
530
531# Approx size: 8, 16, ...
532start_structs_test { tll }
533test_struct_calls 1
534test_struct_calls 2
535test_struct_returns 1
536
537# Approx size: 4, 8, ...
538start_structs_test { tf }
539test_struct_calls 1
540test_struct_calls 2
541test_struct_calls 3
542test_struct_returns 1
543test_struct_returns 2
544
545# Approx size: 8, 16, ...
546start_structs_test { td }
547test_struct_calls 1
548test_struct_calls 2
549test_struct_returns 1
550
551# Approx size: 16, 32, ...
552start_structs_test { tld }
553test_struct_calls 1
554test_struct_calls 2
555test_struct_returns 1
556
557# Approx size: 2+1=3, 4, ...
558start_structs_test { ts tc }
559test_struct_calls 2
560test_struct_calls 3
561test_struct_calls 4
562test_struct_calls 5
563test_struct_calls 6
564test_struct_calls 7
565test_struct_calls 8
566test_struct_returns 2
567
568# Approx size: 4+1=5, 6, ...
569start_structs_test { ti tc }
570test_struct_calls 2
571test_struct_calls 3
572test_struct_calls 4
573test_struct_calls 5
574test_struct_calls 6
575test_struct_returns 2
576
577# Approx size: 4+1=5, 6, ...
578start_structs_test { tl tc }
579test_struct_calls 2
580test_struct_calls 3
581test_struct_calls 4
582test_struct_calls 5
583test_struct_calls 6
584test_struct_returns 2
585
586# Approx size: 8+1=9, 10, ...
587start_structs_test { tll tc }
588test_struct_calls 2
589
590# Approx size: 4+1=5, 6, ...
591start_structs_test { tf tc }
592test_struct_calls 2
593test_struct_calls 3
594test_struct_calls 4
595test_struct_calls 5
596test_struct_calls 6
597test_struct_returns 2
598
599# Approx size: 8+1=9, 10, ...
600start_structs_test { td tc }
601test_struct_calls 2
602
603# Approx size: 16+1=17, 18, ...
604start_structs_test { tld tc }
605test_struct_calls 2
606
607# Approx size: (1+1)+2=4, 6, ...
608start_structs_test { tc ts }
609test_struct_calls 2
610test_struct_calls 3
611test_struct_calls 4
612test_struct_calls 5
613test_struct_calls 6
614test_struct_returns 2
615
616# Approx size: (1+3)+4=8, 12, ...
617start_structs_test { tc ti }
618test_struct_calls 2
619test_struct_calls 3
620test_struct_calls 4
621test_struct_returns 2
622
623# Approx size: (1+3)+4=8, 12, ...
624start_structs_test { tc tl }
625test_struct_calls 2
626test_struct_calls 3
627test_struct_calls 4
628test_struct_returns 2
629
630# Approx size: (1+7)+8=16, 24, ...
631start_structs_test { tc tll }
632test_struct_calls 2
633
634# Approx size: (1+3)+4=8, 12, ...
635start_structs_test { tc tf }
636test_struct_calls 2
637test_struct_calls 3
638test_struct_calls 4
639
640# Approx size: (1+7)+8=16, 24, ...
641start_structs_test { tc td }
642test_struct_calls 2
643
644# Approx size: (1+15)+16=32, 48, ...
645start_structs_test { tc tld }
646test_struct_calls 2
647
648# Some float combinations
649
650# Approx size: 8+4=12, 16, ...
651# d10v: 4+4=8, 12, ...
652start_structs_test { td tf }
653test_struct_calls 2
654test_struct_returns 2
74cf1395 655
e53890ae
AC
656# Approx size: (4+4)+8=16, 32, ...
657# d10v: 4+4=8, 12, ...
658start_structs_test { tf td }
659test_struct_calls 2
660test_struct_returns 2
74cf1395
JM
661
662return 0
This page took 0.464021 seconds and 4 git commands to generate.