OSDN Git Service

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