Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. |
c906108c SS |
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 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
26 | set prms_id 0 | |
27 | set bug_id 0 | |
28 | ||
29 | set testfile "opaque" | |
30 | set binfile ${objdir}/${subdir}/opaque | |
31 | ||
32 | #if { [gdb_compile "${srcdir}/${subdir}/opaque0.c ${srcdir}/${subdir}/opaque1.c" "${binfile}" executable {debug}] != "" } { | |
33 | # gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
34 | #} | |
35 | ||
36 | if { [gdb_compile "${srcdir}/${subdir}/opaque0.c" "${binfile}0.o" object {debug}] != "" } { | |
37 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
38 | } | |
39 | ||
40 | if { [gdb_compile "${srcdir}/${subdir}/opaque1.c" "${binfile}1.o" object {debug}] != "" } { | |
41 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
42 | } | |
43 | ||
44 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { | |
45 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
46 | } | |
47 | ||
48 | ||
49 | # Create and source the file that provides information about the compiler | |
50 | # used to compile the test case. | |
51 | if [get_compiler_info ${binfile}] { | |
52 | return -1; | |
53 | } | |
54 | ||
55 | # Start with a fresh gdb. | |
56 | ||
57 | gdb_exit | |
58 | gdb_start | |
59 | gdb_reinitialize_dir $srcdir/$subdir | |
60 | gdb_load ${binfile} | |
61 | ||
62 | # | |
63 | # Test basic opaque structure handling (statically). | |
64 | # The ordering of the tests is significant. We first try the things that | |
65 | # might fail if gdb fails to connect the uses of opaque structures to | |
66 | # the actual opaque structure definition. | |
67 | ||
68 | # When we start up, gdb sets the file containing main() as the current | |
69 | # source file. The actual structure foo is defined in a different file. | |
70 | # A pointer (foop) to an instance of the opaque struct is defined in the same | |
71 | # source file as main(). Ensure that gdb correctly "connected" the definition | |
72 | # in the other file with the pointer to the opaque struct in the file containing | |
73 | # "foop". | |
74 | ||
75 | # Define a procedure to set up an xfail for all targets that do not support | |
76 | # this sort of cross reference. | |
77 | # Any target gcc that has a DBX_NO_XREFS definition in its config file will | |
78 | # not support it (FIXME: Is this still true; I suspect maybe not). | |
79 | ||
80 | # Native alpha ecoff doesn't support it either. | |
81 | # I don't think this type of cross reference works for any COFF target | |
82 | # either. | |
83 | ||
84 | proc setup_xfail_on_opaque_pointer {} { | |
85 | global gcc_compiled | |
86 | ||
9fbfe2dc AC |
87 | setup_xfail "vax-*-*" "i*86-sequent-bsd*" |
88 | # OBSOLETE setup_xfail "a29k-*-udi" | |
c906108c SS |
89 | if {!$gcc_compiled} then { |
90 | setup_xfail "alpha-*-*" "mips-sgi-irix5*" | |
91 | } | |
92 | } | |
93 | ||
94 | # This seems easier than trying to track different versions of xlc; I'm | |
95 | # not sure there is much rhyme or reason regarding which tests it fails | |
96 | # and which ones it passes. | |
97 | if {[istarget "rs6000-*-aix*"] && !$gcc_compiled} then { | |
98 | warning "xfails in opaque.exp may not be set up correctly for xlc" | |
99 | } | |
100 | ||
101 | setup_xfail_on_opaque_pointer | |
102 | gdb_test "whatis foop" \ | |
103 | "type = struct foo \[*\]+" \ | |
104 | "whatis on opaque struct pointer (statically)" | |
105 | ||
106 | ||
107 | # Ensure that we know the form of the structure that foop points to. | |
108 | ||
109 | setup_xfail_on_opaque_pointer | |
085dd6e6 | 110 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
c906108c SS |
111 | gdb_test "ptype foop" \ |
112 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
113 | "ptype on opaque struct pointer (statically)" | |
114 | ||
115 | ||
116 | # An instance of the opaque structure (afoo) is defined in a different file. | |
117 | # Ensure that we can locate afoo and the structure definition. | |
118 | ||
119 | gdb_test "whatis afoo" \ | |
120 | "type = struct foo" \ | |
121 | "whatis on opaque struct instance (statically)" | |
122 | ||
123 | ||
124 | # Ensure that we know the form of "afoo". | |
125 | ||
126 | gdb_test "ptype afoo" \ | |
127 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
128 | "ptype on opaque struct instance (statically)" | |
129 | ||
130 | ||
131 | # Ensure that we know what a struct foo looks like. | |
132 | ||
133 | gdb_test "ptype struct foo" \ | |
134 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
135 | "ptype on opaque struct tagname (statically)" | |
136 | ||
137 | ||
138 | # | |
139 | # Done with static tests, now test dynamic opaque structure handling. | |
140 | # We reload the symbol table so we forget about anything we might | |
141 | # have learned during the static tests. | |
142 | # | |
143 | ||
144 | if [istarget "mips-idt-*"] then { | |
145 | # Restart because IDT/SIM runs out of file descriptors. | |
146 | gdb_exit | |
147 | gdb_start | |
148 | } | |
149 | gdb_reinitialize_dir $srcdir/$subdir | |
150 | gdb_load ${binfile} | |
151 | ||
152 | # Run to main, where struct foo is incomplete. | |
153 | if ![runto_main] { | |
154 | perror "cannot run to breakpoint at main" | |
155 | } | |
156 | ||
157 | ||
158 | # The current source file is now the one containing main(). The structure foo | |
159 | # is defined in a different file, but we have a pointer to an instance of | |
160 | # the opaque structure in the current file. Ensure we know it's type. | |
161 | ||
162 | setup_xfail_on_opaque_pointer | |
163 | gdb_test "whatis foop" \ | |
164 | "type = struct foo \[*\]+" \ | |
165 | "whatis on opaque struct pointer (dynamically)" | |
166 | ||
167 | ||
168 | # Ensure that we know the form of the thing foop points to. | |
169 | ||
170 | setup_xfail_on_opaque_pointer | |
085dd6e6 | 171 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
c906108c SS |
172 | gdb_test "ptype foop" \ |
173 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
174 | "ptype on opaque struct pointer (dynamically) 1" | |
175 | ||
176 | gdb_test "whatis afoo" \ | |
177 | "type = struct foo" \ | |
178 | "whatis on opaque struct instance (dynamically) 1" | |
179 | ||
180 | ||
181 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
182 | ||
183 | gdb_test "ptype afoo" \ | |
184 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
085dd6e6 | 185 | "ptype on opaque struct instance (dynamically) xyz 1" |
c906108c SS |
186 | |
187 | ||
188 | # Ensure that we know the form of an explicit struct foo. | |
189 | ||
190 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } | |
191 | gdb_test "ptype struct foo" \ | |
192 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
193 | "ptype on opaque struct tagname (dynamically) 1" | |
194 | ||
195 | ||
196 | # Now reload the symbols again so we forget about anything we might | |
197 | # have learned reading the symbols during the previous tests. | |
198 | ||
199 | if [istarget "mips-idt-*"] then { | |
200 | # Restart because IDT/SIM runs out of file descriptors. | |
201 | gdb_exit | |
202 | gdb_start | |
203 | } | |
204 | gdb_reinitialize_dir $srcdir/$subdir | |
205 | gdb_load ${binfile} | |
206 | ||
207 | # Run to getfoo, where struct foo is complete. | |
208 | if ![runto getfoo] { | |
209 | perror "cannot run to breakpoint at getfoo" | |
210 | } | |
211 | ||
212 | ||
213 | # Ensure that we know what foop is. | |
214 | ||
215 | setup_xfail_on_opaque_pointer | |
216 | gdb_test "whatis foop" \ | |
217 | "type = struct foo \[*\]+" \ | |
218 | "whatis on opaque struct pointer (dynamically) 1" | |
219 | ||
220 | ||
221 | # Ensure that we know the form of the thing foop points to. | |
222 | ||
223 | setup_xfail_on_opaque_pointer | |
085dd6e6 JM |
224 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
225 | gdb_test "ptype foop" \ | |
226 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
227 | "ptype on opaque struct pointer (dynamically) 2" | |
228 | ||
229 | gdb_test "whatis afoo" \ | |
230 | "type = struct foo" \ | |
231 | "whatis on opaque struct instance (dynamically) 1" | |
232 | ||
233 | ||
234 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
235 | ||
236 | gdb_test "ptype afoo" \ | |
237 | "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \ | |
238 | "ptype on opaque struct instance (dynamically) 1" | |
239 | ||
240 | gdb_test "ptype afoo" \ | |
241 | "type = struct foo \{\[\r\n\]*.*int a;\[\r\n\]*.*int b;\[\r\n\]*}\[\r\n\]*" \ | |
242 | "ptype on opaque struct instance (dynamically) pqr 1" | |
243 | ||
244 | ||
245 | # Ensure that we know the form of an explicit struct foo. | |
246 | ||
c906108c SS |
247 | gdb_test "ptype foop" \ |
248 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
249 | "ptype on opaque struct pointer (dynamically) 2" | |
250 | ||
251 | gdb_test "whatis afoo" \ | |
252 | "type = struct foo" \ | |
253 | "whatis on opaque struct instance (dynamically) 2" | |
254 | ||
255 | ||
256 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
257 | ||
258 | gdb_test "ptype afoo" \ | |
259 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
260 | "ptype on opaque struct instance (dynamically) 2" | |
261 | ||
262 | ||
263 | # Ensure that we know the form of an explicit struct foo. | |
264 | ||
265 | gdb_test "ptype struct foo" \ | |
266 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
267 | "ptype on opaque struct tagname (dynamically) 2" |