2003-11-22 Andrew Cagney <cagney@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
3# Copyright 1996, 1997, 1999, 2003 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.
84 gdb_start
85 gdb_reinitialize_dir $srcdir/$subdir
86 gdb_load ${binfile}
87
88 # Make certain that the output is consistent
89 gdb_test "set print sevenbit-strings" "" \
90 "set print sevenbit-strings; ${testfile}"
91 gdb_test "set print address off" "" \
92 "set print address off; ${testfile}"
93 gdb_test "set width 0" "" \
94 "set width 0; ${testfile}"
95
96 # Advance to main
97 if { ![runto_main] } then {
98 gdb_suppress_tests;
99 }
100
101 # check that at the struct containing all the relevant types is correct
102 set foo_t "type = struct struct[llength ${types}] \{"
103 for {set n 0} {$n<[llength ${types}]} {incr n} {
104 append foo_t "\[\r\n \]+[lindex ${types} $n] [i2a $n];"
105 }
106 append foo_t "\[\r\n \]+\}"
107 gdb_test "ptype foo[llength ${types}]" "${foo_t}" \
108 "ptype foo[llength ${types}]; ${testfile}"
74cf1395
JM
109}
110
e53890ae
AC
111# The expected value for fun${n}, L${n} and foo${n}. First element is
112# empty to make indexing easier. "foo" returns the modified value,
113# "zed" returns the invalid value.
853d6e5b 114
e53890ae
AC
115proc foo { n } {
116 return [lindex {
117 "{}"
118 "{a = 49 '1'}"
119 "{a = 97 'a', b = 50 '2'}"
120 "{a = 49 '1', b = 98 'b', c = 51 '3'}"
121 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4'}"
122 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5'}"
123 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6'}"
124 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7'}"
125 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8'}"
126 "{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'}"
127 "{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'}"
128 "{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'}"
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', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C'}"
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', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D'}"
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', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E'}"
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', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F'}"
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', m = 109 'm', n = 69 'E', o = 111 'o', p = 71 'G'}"
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', n = 110 'n', o = 70 'F', p = 112 'p', q = 72 'H'}"
135 } $n]
136}
137
138proc zed { n } {
139 return [lindex {
140 "{}"
141 "{a = 90 'Z'}"
142 "{a = 90 'Z', b = 90 'Z'}"
143 "{a = 90 'Z', b = 90 'Z', c = 90 'Z'}"
144 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z'}"
145 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z'}"
146 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z'}"
147 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z'}"
148 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z'}"
149 "{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'}"
150 "{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'}"
151 "{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'}"
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', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 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', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 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', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 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', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 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', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 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', n = 90 'Z', o = 90 'Z', p = 90 'Z', q = 90 'Z'}"
158 } $n]
159}
160
161# Given N (0..25), return the corresponding alphabetic letter in lower
162# or upper case. This is ment to be i18n proof.
163
164proc i2a { n } {
165 return [string range "abcdefghijklmnopqrstuvwxyz" $n $n]
166}
167
168proc I2A { n } {
169 return [string toupper [i2a $n]]
170}
171
172
173# Use the file name, compiler and tuples to set up any needed KFAILs.
174
175proc setup_kfails { file tuples bug } {
176 global testfile
177 if [string match $file $testfile] {
178 foreach f $tuples { setup_kfail $f $bug }
853d6e5b 179 }
74cf1395
JM
180}
181
e53890ae
AC
182proc setup_compiler_kfails { file compiler format tuples bug } {
183 global testfile
184 if {[string match $file $testfile] && [test_compiler_info $compiler] && [test_debug_format $format]} {
185 foreach f $tuples { setup_kfail $f $bug }
186 }
187}
188
189# Test GDB's ability to make inferior function calls to functions
190# returning (or passing in a single structs.
191
192# N identifies the number of elements in the struct that will be used
193# for the test case. FAILS is a list of target tuples that will fail
194# this test.
853d6e5b 195
e53890ae
AC
196# start_structs_test() will have previously built a program with a
197# specified combination of types for those elements. To ensure
198# robustness of the output, "p/c" is used.
199
200# This tests the code paths "which return-value convention?" and
201# "extract return-value from registers" called by "infcall.c".
202
203proc test_struct_calls { n } {
204 global testfile
b4967060 205 global gdb_prompt
853d6e5b 206
e53890ae
AC
207 # Check that GDB can always extract a struct-return value from an
208 # inferior function call. Since GDB always knows the location of an
209 # inferior function call's return value these should never fail
210
211 # Implemented by calling the parameterless function "fun$N" and then
212 # examining the return value printed by GDB.
853d6e5b 213
e53890ae 214 set tests "call $n ${testfile}"
853d6e5b 215
e53890ae
AC
216 # Call fun${n}, checking the printed return-value.
217 setup_kfails structs-*tld* i686-*-* gdb/1447
218 setup_compiler_kfails structs-tc-* gcc-3-3 "DWARF 2" i686-*-* gdb/1455
219 gdb_test "p/c fun${n}()" "[foo ${n}]" "p/c fun<n>(); ${tests}"
853d6e5b 220
e53890ae
AC
221 # Check that GDB can always pass a structure to an inferior function.
222 # This test can never fail.
223
224 # Implemented by calling the one parameter function "Fun$N" which
225 # stores its parameter in the global variable "L$N". GDB then
226 # examining that global to confirm that the value is as expected.
227
228 gdb_test "call Fun${n}(foo${n})" "" "call Fun<n>(foo<n>); ${tests}"
229 setup_kfails structs-*tld* i686-*-* gdb/1447
230 setup_compiler_kfails structs-tc-* gcc-3-3 "DWARF 2" i686-*-* gdb/1455
231 gdb_test "p/c L${n}" [foo ${n}] "p/c L<n>; ${tests}"
b4967060 232}
853d6e5b 233
e53890ae
AC
234# Test GDB's ability to both return a function (with "return" or
235# "finish") and correctly extract/store any corresponding
236# return-value.
237
238# Check that GDB can consistently extract/store structure return
239# values. There are two cases - returned in registers and returned in
240# memory. For the latter case, the return value can't be found and a
241# failure is "expected". However GDB must still both return the
242# function and display the final source and line information.
243
244# N identifies the number of elements in the struct that will be used
245# for the test case. FAILS is a list of target tuples that will fail
246# this test.
247
248# This tests the code paths "which return-value convention?", "extract
249# return-value from registers", and "store return-value in registers".
250# Unlike "test struct calls", this test is expected to "fail" when the
251# return-value is in memory (GDB can't find the location). The test
252# is in three parts: test "return"; test "finish"; check that the two
253# are consistent. GDB can sometimes work for one command and not the
254# other.
255
256proc test_struct_returns { n } {
257 global gdb_prompt
258 global testfile
259
260 set tests "return $n ${testfile}"
261
262
263 # Check that "return" works.
264
265 # GDB must always force the return of a function that has
266 # a struct result. Dependant on the ABI, it may, or may not be
267 # possible to store the return value in a register.
268
269 # The relevant code looks like "L{n} = fun{n}()". The test forces
270 # "fun{n}" to "return" with an explicit value. Since that code
271 # snippet will store the the returned value in "L{n}" the return
272 # is tested by examining "L{n}". This assumes that the
273 # compiler implemented this as fun{n}(&L{n}) and hence that when
274 # the value isn't stored "L{n}" remains unchanged. Also check for
275 # consistency between this and the "finish" case.
276
277 # Get into a call of fun${n}
278 gdb_test "advance fun${n}" \
279 "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \
280 "advance to fun<n> for return; ${tests}"
281
282 # Check that the program invalidated the relevant global.
283 setup_kfails structs-tld i686-*-* gdb/1447
284 gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for return; ${tests} .${testfile}."
285
286 # Force the "return". This checks that the return is always
287 # performed, and that GDB correctly reported this to the user.
288 # GDB 6.0 and earlier, when the return-value's location wasn't
289 # known, both failed to print a final "source and line" and misplaced
290 # the frame ("No frame").
291
292 # The test is writen so that it only reports one FAIL/PASS for the
293 # entire operation. The value returned is checked further down.
294 # "return_value_unknown", if non-empty, records why GDB realised
295 # that it didn't know where the return value was.
296
297 send_gdb "return foo${n}\n"
298 set test "return foo<n>; ${tests}"
299 set return_value_unknown 0
300 gdb_expect {
301 -re "The location" {
302 # Ulgh, a struct return, remember this (still need prompt).
303 set return_value_unknown 1
304 exp_continue
305 }
306 -re "A structure or union" {
307 # Ulgh, a struct return, remember this (still need prompt).
308 # Set it to something unique so that it won't match a
309 # struct return convention value.
310 # set return_value_unknown -1
311 set return_value_unknown 1
312 exp_continue
313 }
314 -re "Make fun${n} return now.*y or n. $" {
315 send_gdb "y\n"
316 gdb_expect {
317 -re "L${n} *= fun${n}.*${gdb_prompt} $" {
318 # Need to step off the function call
319 gdb_test "next" "L.* *= fun.*" "${test}"
320 }
321 -re "L[expr ${n} + 1] *= fun[expr ${n} + 1].*${gdb_prompt} $" {
322 pass "${test}"
323 }
6882279b
AC
324 -re "A problem internal to GDB has been detected" {
325 fail "${test} (GDB internal error 2)"
326 gdb_internal_error_resync
327 }
328 -re "${gdb_prompt} $" {
329 fail "${test} (wrong line info)"
330 }
e53890ae
AC
331 timeout {
332 fail "${test} (timeout 2)"
333 }
334 }
335 }
6882279b
AC
336 -re "A problem internal to GDB has been detected" {
337 fail "${test} (GDB internal error 1)"
338 gdb_internal_error_resync
339 }
e53890ae
AC
340 -re "${gdb_prompt} $" {
341 fail "${test} (no query)"
342 }
343 timeout {
344 fail "${test} (timeout 1)"
345 }
346 }
347
348 # Check that the return-value is as expected. At this stage we're
349 # just checking that GDB has returned a value consistent with
350 # "return_value_unknown" set above.
351
352 send_gdb "p/c L${n}\n"
353 set test "value foo<n> returned; ${tests}"
354 setup_kfails structs-*tld* i686-*-* gdb/1447
355 gdb_expect {
356 -re " = [foo ${n}].*${gdb_prompt} $" {
357 if $return_value_unknown {
358 # This contradicts the above claim that GDB didn't
359 # know the location of the return-value.
360 fail "${test}"
361 } else {
362 pass "${test}"
363 }
364 }
365 -re " = [zed ${n}].*${gdb_prompt} $" {
366 if $return_value_unknown {
367 # The struct return case. Since any modification
368 # would be by reference, and that can't happen, the
369 # value should be unmodified and hence Z is expected.
370 # Is this a reasonable assumption?
371 pass "${test}"
372 } else {
373 # This contradicts the above claim that GDB knew
374 # the location of the return-value.
375 fail "${test}"
376 }
377 }
6882279b
AC
378 -re "A problem internal to GDB has been detected" {
379 fail "${test} (GDB internal error)"
380 gdb_internal_error_resync
381 }
e53890ae
AC
382 -re "${gdb_prompt} $" {
383 # Garbage returned, garbage printed
384 fail "${test}"
385 }
386 timeout {
387 fail "${test} (timeout)"
388 }
389 }
390
391 # Check that a "finish" works.
392
393 # This is almost but not quite the same as "call struct funcs".
394 # Architectures can have subtle differences in the two code paths.
395
396 # The relevant code snippet is "L{n} = fun{n}()". The program is
397 # advanced into a call to "fun{n}" and then that function is
398 # finished. The returned value that GDB prints, reformatted using
399 # "p/c", is checked.
400
401 # Get into "fun${n}()".
402 gdb_test "advance fun${n}" \
403 "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \
404 "advance to fun<n> for finish; ${tests}"
405
406 # Check that the program invalidated the relevant global.
407 setup_kfails structs-tld i686-*-* gdb/1447
408 gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for finish; ${tests}"
409
410 # Finish the function, set 'finish_value_unknown" to non-empty if the
411 # return-value was not found.
412 send_gdb "finish\n"
6882279b 413 set test "finish foo<n>; ${tests}"
e53890ae
AC
414 set finish_value_unknown 0
415 gdb_expect {
416 -re "Value returned is .*${gdb_prompt} $" {
417 pass "${test}"
418 }
419 -re "Cannot determine contents.*${gdb_prompt} $" {
420 # Expected bad value. For the moment this is ok.
421 set finish_value_unknown 1
422 pass "${test}"
423 }
6882279b
AC
424 -re "A problem internal to GDB has been detected" {
425 fail "${test} (GDB internal error)"
426 gdb_internal_error_resync
427 }
e53890ae
AC
428 -re ".*${gdb_prompt} $" {
429 # Garbage returned
430 fail "${test}"
431 }
432 timeout {
433 fail "${test} (timeout)"
434 }
435 }
436
437 # Re-print the last (return-value) using the more robust
438 # "p/c". If no return value was found, the 'Z' from the previous
439 # check that the variable was cleared, is printed.
440 send_gdb "p/c\n"
6882279b 441 set test "value foo<n> finished; ${tests}"
e53890ae
AC
442 setup_kfails structs-*tld* i686-*-* gdb/1447
443 gdb_expect {
444 -re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" {
445 if $finish_value_unknown {
446 # This contradicts the above claim that GDB didn't
447 # know the location of the return-value.
448 fail "${test}"
449 } else {
450 pass "${test}"
451 }
452 }
453 -re "[zed ${n}]\[\r\n\]+${gdb_prompt} $" {
454 # The value didn't get found. This is "expected".
455 if $finish_value_unknown {
456 pass "${test}"
457 } else {
458 # This contradicts the above claim that GDB did
459 # know the location of the return-value.
460 fail "${test}"
461 }
462 }
6882279b
AC
463 -re "A problem internal to GDB has been detected" {
464 fail "${test} (GDB internal error)"
465 gdb_internal_error_resync
466 }
e53890ae
AC
467 -re ".*${gdb_prompt} $" {
468 # Garbage returned
469 fail "${test}"
470 }
471 timeout {
472 fail "${test} (timeout)"
473 }
474 }
475
476 # Finally, check that "return" and finish" have consistent
477 # behavior.
478
479 # Since both "return" and "finish" use equivalent "which
480 # return-value convention" logic, both commands should have
481 # identical can/can-not find return-value messages.
482
483 # Note that since "call" and "finish" use common code paths, a
484 # failure here is a strong indicator of problems with "store
485 # return-value" code paths. Suggest looking at "return_value"
486 # when investigating a fix.
487
488 set test "return and finish use same convention; ${tests}"
489 if {$finish_value_unknown == $return_value_unknown} {
490 pass "${test}"
491 } else {
492 kfail gdb/1444 "${test}"
493 }
b4967060 494}
853d6e5b 495
e53890ae
AC
496# ABIs pass anything >8 or >16 bytes in memory but below that things
497# randomly use register and/and structure conventions. Check all
498# possible sized char structs in that range. But only a restricted
499# range of the other types.
500
501# NetBSD/PPC returns "unnatural" (3, 5, 6, 7) sized structs in memory.
502
503# d10v is weird. 5/6 byte structs go in memory. 2 or more char
504# structs go in memory. Everything else is in a register!
505
506# Test every single char struct from 1..17 in size. This is what the
507# original "structs" test was doing.
508
509start_structs_test { tc }
510test_struct_calls 1
511test_struct_calls 2
512test_struct_calls 3
513test_struct_calls 4
514test_struct_calls 5
515test_struct_calls 6
516test_struct_calls 7
517test_struct_calls 8
518test_struct_calls 9
519test_struct_calls 10
520test_struct_calls 11
521test_struct_calls 12
522test_struct_calls 13
523test_struct_calls 14
524test_struct_calls 15
525test_struct_calls 16
526test_struct_calls 17
527test_struct_returns 1
528test_struct_returns 2
529test_struct_returns 3
530test_struct_returns 4
531test_struct_returns 5
532test_struct_returns 6
533test_struct_returns 7
534test_struct_returns 8
535
536
537# Let the fun begin.
538
539# Assuming that any integer struct larger than 8 bytes goes in memory,
540# come up with many and varied combinations of a return struct. For
541# "struct calls" test just beyond that 8 byte boundary, for "struct
542# returns" test up to that boundary.
543
544# For floats, assumed that up to two struct elements can be stored in
545# floating point registers, regardless of their size.
546
547# The approx size of each structure it is computed assumed that tc=1,
548# ts=2, ti=4, tl=4, tll=8, tf=4, td=8, tld=16, and that all fields are
549# naturally aligned. Padding being added where needed. Note that
550# these numbers are just approx, the d10v has ti=2, a 64-bit has has
551# tl=8.
552
553# Approx size: 2, 4, ...
554start_structs_test { ts }
555test_struct_calls 1
556test_struct_calls 2
557test_struct_calls 3
558test_struct_calls 4
559test_struct_calls 5
560test_struct_returns 1
561test_struct_returns 2
562test_struct_returns 3
563test_struct_returns 4
564
565# Approx size: 4, 8, ...
566start_structs_test { ti }
567test_struct_calls 1
568test_struct_calls 2
569test_struct_calls 3
570test_struct_returns 1
571test_struct_returns 2
572
573# Approx size: 4, 8, ...
574start_structs_test { tl }
575test_struct_calls 1
576test_struct_calls 2
577test_struct_calls 3
578test_struct_returns 1
579test_struct_returns 2
580
581# Approx size: 8, 16, ...
582start_structs_test { tll }
583test_struct_calls 1
584test_struct_calls 2
585test_struct_returns 1
586
587# Approx size: 4, 8, ...
588start_structs_test { tf }
589test_struct_calls 1
590test_struct_calls 2
591test_struct_calls 3
592test_struct_returns 1
593test_struct_returns 2
594
595# Approx size: 8, 16, ...
596start_structs_test { td }
597test_struct_calls 1
598test_struct_calls 2
599test_struct_returns 1
600
601# Approx size: 16, 32, ...
602start_structs_test { tld }
603test_struct_calls 1
604test_struct_calls 2
605test_struct_returns 1
606
607# Approx size: 2+1=3, 4, ...
608start_structs_test { ts tc }
609test_struct_calls 2
610test_struct_calls 3
611test_struct_calls 4
612test_struct_calls 5
613test_struct_calls 6
614test_struct_calls 7
615test_struct_calls 8
616test_struct_returns 2
617
618# Approx size: 4+1=5, 6, ...
619start_structs_test { ti tc }
620test_struct_calls 2
621test_struct_calls 3
622test_struct_calls 4
623test_struct_calls 5
624test_struct_calls 6
625test_struct_returns 2
626
627# Approx size: 4+1=5, 6, ...
628start_structs_test { tl tc }
629test_struct_calls 2
630test_struct_calls 3
631test_struct_calls 4
632test_struct_calls 5
633test_struct_calls 6
634test_struct_returns 2
635
636# Approx size: 8+1=9, 10, ...
637start_structs_test { tll tc }
638test_struct_calls 2
639
640# Approx size: 4+1=5, 6, ...
641start_structs_test { tf tc }
642test_struct_calls 2
643test_struct_calls 3
644test_struct_calls 4
645test_struct_calls 5
646test_struct_calls 6
647test_struct_returns 2
648
649# Approx size: 8+1=9, 10, ...
650start_structs_test { td tc }
651test_struct_calls 2
652
653# Approx size: 16+1=17, 18, ...
654start_structs_test { tld tc }
655test_struct_calls 2
656
657# Approx size: (1+1)+2=4, 6, ...
658start_structs_test { tc ts }
659test_struct_calls 2
660test_struct_calls 3
661test_struct_calls 4
662test_struct_calls 5
663test_struct_calls 6
664test_struct_returns 2
665
666# Approx size: (1+3)+4=8, 12, ...
667start_structs_test { tc ti }
668test_struct_calls 2
669test_struct_calls 3
670test_struct_calls 4
671test_struct_returns 2
672
673# Approx size: (1+3)+4=8, 12, ...
674start_structs_test { tc tl }
675test_struct_calls 2
676test_struct_calls 3
677test_struct_calls 4
678test_struct_returns 2
679
680# Approx size: (1+7)+8=16, 24, ...
681start_structs_test { tc tll }
682test_struct_calls 2
683
684# Approx size: (1+3)+4=8, 12, ...
685start_structs_test { tc tf }
686test_struct_calls 2
687test_struct_calls 3
688test_struct_calls 4
689
690# Approx size: (1+7)+8=16, 24, ...
691start_structs_test { tc td }
692test_struct_calls 2
693
694# Approx size: (1+15)+16=32, 48, ...
695start_structs_test { tc tld }
696test_struct_calls 2
697
698# Some float combinations
699
700# Approx size: 8+4=12, 16, ...
701# d10v: 4+4=8, 12, ...
702start_structs_test { td tf }
703test_struct_calls 2
704test_struct_returns 2
74cf1395 705
e53890ae
AC
706# Approx size: (4+4)+8=16, 32, ...
707# d10v: 4+4=8, 12, ...
708start_structs_test { tf td }
709test_struct_calls 2
710test_struct_returns 2
74cf1395
JM
711
712return 0
This page took 0.405113 seconds and 4 git commands to generate.