]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/structs.exp
* config/vr4300.exp: New file.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / structs.exp
1 # Copyright (C) 1996 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 Jeff Law. (law@cygnus.com)
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 set prototypes 1
30 set testfile "structs"
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33
34 # build the first test case
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36 # built the second test case since we can't use prototypes
37 warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } {
39 perror "Couldn't compile ${testfile}.c"
40 return -1
41 }
42 set prototypes 0
43 }
44
45 # Create and source the file that provides information about the compiler
46 # used to compile the test case.
47 if [get_compiler_info ${binfile}] {
48 return -1;
49 }
50
51 # The a29k can't call functions, so don't even bother with this test.
52 if [istarget "a29k-*-udi"] then {
53 setup_xfail "a29k-*-udi" 2416
54 fail "a29k-*-udi can not call functions"
55 continue
56 }
57
58 # FIXME: Before calling this proc, we should probably verify that
59 # we can call inferior functions and get a valid integral value
60 # returned.
61 # Note that it is OK to check for 0 or 1 as the returned values, because C
62 # specifies that the numeric value of a relational or logical expression
63 # (computed in the inferior) is 1 for true and 0 for false.
64
65 proc do_function_calls {} {
66 global prototypes
67 global gcc_compiled
68 global gdb_prompt
69
70 # First, call the "fun" functions and examine the value they return.
71 gdb_test "p fun1()" " = {a = 49 '1'}"
72 gdb_test "p fun2()" " = {a = 97 'a', b = 98 'b'}"
73 gdb_test "p fun3()" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
74 gdb_test "p fun4()" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
75 gdb_test "p fun5()" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
76 gdb_test "p fun6()" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
77 gdb_test "p fun7()" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
78 gdb_test "p fun8()" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}"
79 gdb_test "p fun9()" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}"
80 gdb_test "p fun10()" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}"
81 gdb_test "p fun11()" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}"
82 gdb_test "p fun12()" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}"
83 gdb_test "p fun16()" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}"
84
85 # Now call the Fun functions to set the L* variables. This
86 # tests that gdb properly passes structures to functions.
87 gdb_test "p Fun1(foo1)" " = (void|0)"
88 gdb_test "p Fun2(foo2)" " = (void|0)"
89 gdb_test "p Fun3(foo3)" " = (void|0)"
90 gdb_test "p Fun4(foo4)" " = (void|0)"
91 gdb_test "p Fun5(foo5)" " = (void|0)"
92 gdb_test "p Fun6(foo6)" " = (void|0)"
93 gdb_test "p Fun7(foo7)" " = (void|0)"
94 gdb_test "p Fun8(foo8)" " = (void|0)"
95 gdb_test "p Fun9(foo9)" " = (void|0)"
96 gdb_test "p Fun10(foo10)" " = (void|0)"
97 gdb_test "p Fun11(foo11)" " = (void|0)"
98 gdb_test "p Fun12(foo12)" " = (void|0)"
99 gdb_test "p Fun16(foo16)" " = (void|0)"
100
101 # Now print the L* variables and examine their values.
102 gdb_test "p L1" " = {a = 49 '1'}"
103 gdb_test "p L2" " = {a = 97 'a', b = 98 'b'}"
104 gdb_test "p L3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}"
105 gdb_test "p L4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}"
106 if {$gcc_compiled} then {
107 setup_xfail "hppa*-*-*"
108 }
109 gdb_test "p L5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}"
110 if {$gcc_compiled} then {
111 setup_xfail "hppa*-*-*"
112 }
113 gdb_test "p L6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}"
114 if {$gcc_compiled} then {
115 setup_xfail "hppa*-*-*"
116 }
117 gdb_test "p L7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}"
118 gdb_test "p L8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}"
119 gdb_test "p L9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}"
120 gdb_test "p L10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}"
121 gdb_test "p L11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}"
122 gdb_test "p L12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}"
123 gdb_test "p L16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}"
124 }
125 # Start with a fresh gdb.
126
127 gdb_exit
128 gdb_start
129 gdb_reinitialize_dir $srcdir/$subdir
130 gdb_load ${binfile}
131
132 send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
133 send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
134 send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
135
136 if [target_info exists gdb,cannot_call_functions] {
137 setup_xfail "*-*-*" 2416
138 fail "This target can not call functions"
139 return 0
140 }
141
142 if [runto_main] then {
143 do_function_calls
144 } else {
145 fail "C function calling tests suppressed"
146 }
147 return 0