1 # Copyright (C) 1992, 1994 Free Software Foundation, Inc.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Fred Fish. (fnf@cygnus.com)
30 set srcfile $binfile.c
32 if ![file exists $objdir/$subdir/$binfile] then {
33 perror "$objdir/$subdir/$binfile does not exist."
37 # Start with a fresh gdb.
41 gdb_reinitialize_dir $srcdir/$subdir
42 gdb_load $objdir/$subdir/$binfile
44 source gdb.base/opaque-info.exp
47 # Test basic opaque structure handling (statically).
48 # The ordering of the tests is significant. We first try the things that
49 # might fail if gdb fails to connect the uses of opaque structures to
50 # the actual opaque structure definition.
52 # When we start up, gdb sets the file containing main() as the current
53 # source file. The actual structure foo is defined in a different file.
54 # A pointer (foop) to an instance of the opaque struct is defined in the same
55 # source file as main(). Ensure that gdb correctly "connected" the definition
56 # in the other file with the pointer to the opaque struct in the file containing
59 # Define a procedure to set up an xfail for all targets that do not support
60 # this sort of cross reference.
61 # Any target gcc that has a DBX_NO_XREFS definition in its config file will
63 # XCOFF does not seem to support it either. See the very end of gcc/xcoffout.h.
64 # Native alpha ecoff doesn't support it either.
65 # I don't think this type of cross reference works for any COFF target
68 proc setup_xfail_on_opaque_pointer {} {
71 setup_xfail "rs6000-*-*" "a29k-*-udi" "vax-*-*" "i*86-sequent-bsd*"
72 if {!$gcc_compiled} then {
73 setup_xfail "alpha-*-*"
77 setup_xfail_on_opaque_pointer
81 type = struct foo \[*\]+\r
82 $prompt $" { pass "whatis on opaque struct pointer (statically)"}
83 -re ".*$prompt $" { fail "whatis on opaque struct *" }
84 timeout { fail "(timeout) whatis on opaque struct *" }
88 # Ensure that we know the form of the structure that foop points to.
90 setup_xfail_on_opaque_pointer
94 type = struct foo \{\r
98 $prompt $" { pass "ptype on opaque struct pointer (statically)" }
99 -re ".*$prompt $" { fail "ptype on opaque struct *" }
100 timeout { fail "(timeout) ptype on opaque struct *" }
104 # An instance of the opaque structure (afoo) is defined in a different file.
105 # Ensure that we can locate afoo and the structure definition.
111 $prompt $" { pass "whatis on opaque struct instance (statically)" }
112 -re ".*$prompt $" { fail "whatis on opaque struct" }
113 timeout { fail "(timeout) whatis on opaque struct" }
117 # Ensure that we know the form of "afoo".
122 type = struct foo \{\r
126 $prompt $" { pass "ptype on opaque struct instance (statically)" }
127 -re ".*$prompt $" { fail "ptype on opaque struct instance" }
128 timeout { fail "(timeout) ptype on opaque struct" }
132 # Ensure that we know what a struct foo looks like.
134 send "ptype struct foo\n"
136 -re "ptype struct foo\r
137 type = struct foo \{\r
141 $prompt $" { pass "ptype on opaque struct tagname (statically)" }
142 -re ".*$prompt $" { fail "ptype on opaque struct" }
143 timeout { fail "(timeout) ptype on opaque struct" }
148 # Done with static tests, now test dynamic opaque structure handling.
149 # We reload the symbol table so we forget about anything we might
150 # have learned during the static tests.
153 if [istarget "mips-idt-*"] then {
154 # Restart because IDT/SIM runs out of file descriptors.
158 gdb_reinitialize_dir $srcdir/$subdir
159 gdb_load $objdir/$subdir/$binfile
161 # Run to main, where struct foo is incomplete.
163 perror "cannot run to breakpoint at main"
167 # The current source file is now the one containing main(). The structure foo
168 # is defined in a different file, but we have a pointer to an instance of
169 # the opaque structure in the current file. Ensure we know it's type.
171 setup_xfail_on_opaque_pointer
175 type = struct foo \[*\]+\r
176 $prompt $" { pass "whatis on opaque struct pointer (dynamically)"}
177 -re ".*$prompt $" { fail "whatis on opaque struct pointer" }
178 timeout { fail "(timeout) whatis on opaque struct ptr" }
182 # Ensure that we know the form of the thing foop points to.
184 setup_xfail_on_opaque_pointer
188 type = struct foo \{\r
192 $prompt $" { pass "ptype on opaque struct pointer (dynamically)" }
193 -re ".*$prompt $" { fail "ptype on opaque struct *" }
194 timeout { fail "(timeout) ptype on opaque struct *" }
202 $prompt $" { pass "whatis on opaque struct instance (dynamically)" }
203 -re ".*$prompt $" { fail "whatis on opaque struct" }
204 timeout { fail "(timeout) whatis on opaque struct" }
208 # Ensure that we know the form of afoo, an instance of a struct foo.
213 type = struct foo \{\r
217 $prompt $" { pass "ptype on opaque struct instance (dynamically)" }
218 -re ".*$prompt $" { fail "ptype on opaque struct instance" }
219 timeout { fail "(timeout) ptype on opaque struct" }
223 # Ensure that we know the form of an explicit struct foo.
225 send "ptype struct foo\n"
227 -re "ptype struct foo\r
228 type = struct foo \{\r
232 $prompt $" { pass "ptype on opaque struct tagname (dynamically)" }
233 -re ".*$prompt $" { fail "ptype on opaque struct" }
234 timeout { fail "(timeout) ptype on opaque struct" }
238 # Now reload the symbols again so we forget about anything we might
239 # have learned reading the symbols during the previous tests.
241 if [istarget "mips-idt-*"] then {
242 # Restart because IDT/SIM runs out of file descriptors.
246 gdb_reinitialize_dir $srcdir/$subdir
247 gdb_load $objdir/$subdir/$binfile
249 # Run to getfoo, where struct foo is complete.
251 perror "cannot run to breakpoint at getfoo"
255 # Ensure that we know what foop is.
257 setup_xfail_on_opaque_pointer
261 type = struct foo \[*\]+\r
262 $prompt $" { pass "whatis on opaque struct pointer (dynamically)"}
263 -re ".*$prompt $" { fail "whatis on opaque struct pointer" }
264 timeout { fail "(timeout) whatis on opaque struct ptr" }
268 # Ensure that we know the form of the thing foop points to.
270 setup_xfail_on_opaque_pointer
274 type = struct foo \{\r
278 $prompt $" { pass "ptype on opaque struct pointer (dynamically)" }
279 -re ".*$prompt $" { fail "ptype on opaque struct *" }
280 timeout { fail "(timeout) ptype on opaque struct *" }
288 $prompt $" { pass "whatis on opaque struct instance (dynamically)" }
289 -re ".*$prompt $" { fail "whatis on opaque struct" }
290 timeout { fail "(timeout) whatis on opaque struct" }
294 # Ensure that we know the form of afoo, an instance of a struct foo.
299 type = struct foo \{\r
303 $prompt $" { pass "ptype on opaque struct instance (dynamically)" }
304 -re ".*$prompt $" { fail "ptype on opaque struct instance" }
305 timeout { fail "(timeout) ptype on opaque struct" }
309 # Ensure that we know the form of an explicit struct foo.
311 send "ptype struct foo\n"
313 -re "ptype struct foo\r
314 type = struct foo \{\r
318 $prompt $" { pass "ptype on opaque struct tagname (dynamically)" }
319 -re ".*$prompt $" { fail "ptype on opaque struct" }
320 timeout { fail "(timeout) ptype on opaque struct" }