1 # Copyright 1992, 1994-1997, 1999, 2002, 2007-2012 Free Software
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # This file was written by Fred Fish. (fnf@cygnus.com)
25 set binfile ${objdir}/${subdir}/opaque
27 #if { [gdb_compile "${srcdir}/${subdir}/opaque0.c ${srcdir}/${subdir}/opaque1.c" "${binfile}" executable {debug}] != "" } {
28 # gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
31 if { [gdb_compile "${srcdir}/${subdir}/opaque0.c" "${binfile}0.o" object {debug}] != "" } {
36 if { [gdb_compile "${srcdir}/${subdir}/opaque1.c" "${binfile}1.o" object {debug}] != "" } {
41 if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
47 # Create and source the file that provides information about the compiler
48 # used to compile the test case.
49 if [get_compiler_info ${binfile}] {
53 # Start with a fresh gdb.
57 gdb_reinitialize_dir $srcdir/$subdir
61 # Test basic opaque structure handling (statically).
62 # The ordering of the tests is significant. We first try the things that
63 # might fail if gdb fails to connect the uses of opaque structures to
64 # the actual opaque structure definition.
66 # When we start up, gdb sets the file containing main() as the current
67 # source file. The actual structure foo is defined in a different file.
68 # A pointer (foop) to an instance of the opaque struct is defined in the same
69 # source file as main(). Ensure that gdb correctly "connected" the definition
70 # in the other file with the pointer to the opaque struct in the file containing
73 # Define a procedure to set up an xfail for all targets that do not support
74 # this sort of cross reference.
75 # Any target gcc that has a DBX_NO_XREFS definition in its config file will
76 # not support it (FIXME: Is this still true; I suspect maybe not).
78 # Native alpha ecoff doesn't support it either.
79 # I don't think this type of cross reference works for any COFF target
82 proc setup_xfail_on_opaque_pointer {} {
85 setup_xfail "vax-*-*" "i*86-sequent-bsd*"
86 if {!$gcc_compiled} then {
87 setup_xfail "alpha-*-*" "mips-sgi-irix5*"
91 # This seems easier than trying to track different versions of xlc; I'm
92 # not sure there is much rhyme or reason regarding which tests it fails
93 # and which ones it passes.
94 if {[istarget "rs6000-*-aix*"] && !$gcc_compiled} then {
95 warning "xfails in opaque.exp may not be set up correctly for xlc"
98 setup_xfail_on_opaque_pointer
99 gdb_test "whatis foop" \
100 "type = struct foo \[*\]+" \
101 "whatis on opaque struct pointer (statically)"
104 # Ensure that we know the form of the structure that foop points to.
106 setup_xfail_on_opaque_pointer
107 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
108 gdb_test "ptype foop" \
109 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \
110 "ptype on opaque struct pointer (statically)"
113 # An instance of the opaque structure (afoo) is defined in a different file.
114 # Ensure that we can locate afoo and the structure definition.
116 gdb_test "whatis afoo" \
117 "type = struct foo" \
118 "whatis on opaque struct instance (statically)"
121 # Ensure that we know the form of "afoo".
123 gdb_test "ptype afoo" \
124 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
125 "ptype on opaque struct instance (statically)"
128 # Ensure that we know what a struct foo looks like.
130 gdb_test "ptype struct foo" \
131 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
132 "ptype on opaque struct tagname (statically)"
136 # Done with static tests, now test dynamic opaque structure handling.
137 # We reload the symbol table so we forget about anything we might
138 # have learned during the static tests.
141 if [istarget "mips-idt-*"] then {
142 # Restart because IDT/SIM runs out of file descriptors.
146 gdb_reinitialize_dir $srcdir/$subdir
149 # Run to main, where struct foo is incomplete.
151 perror "cannot run to breakpoint at main"
155 # The current source file is now the one containing main(). The structure foo
156 # is defined in a different file, but we have a pointer to an instance of
157 # the opaque structure in the current file. Ensure we know it's type.
159 setup_xfail_on_opaque_pointer
160 gdb_test "whatis foop" \
161 "type = struct foo \[*\]+" \
162 "whatis on opaque struct pointer (dynamically)"
165 # Ensure that we know the form of the thing foop points to.
167 setup_xfail_on_opaque_pointer
168 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
169 gdb_test "ptype foop" \
170 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \
171 "ptype on opaque struct pointer (dynamically) 1"
173 gdb_test "whatis afoo" \
174 "type = struct foo" \
175 "whatis on opaque struct instance (dynamically) 1"
178 # Ensure that we know the form of afoo, an instance of a struct foo.
180 gdb_test "ptype afoo" \
181 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
182 "ptype on opaque struct instance (dynamically) 1"
185 # Ensure that we know the form of an explicit struct foo.
187 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
188 gdb_test "ptype struct foo" \
189 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
190 "ptype on opaque struct tagname (dynamically) 1"
193 # Now reload the symbols again so we forget about anything we might
194 # have learned reading the symbols during the previous tests.
196 if [istarget "mips-idt-*"] then {
197 # Restart because IDT/SIM runs out of file descriptors.
201 gdb_reinitialize_dir $srcdir/$subdir
204 # Run to getfoo, where struct foo is complete.
206 perror "cannot run to breakpoint at getfoo"
210 # Ensure that we know what foop is.
212 setup_xfail_on_opaque_pointer
213 gdb_test "whatis foop" \
214 "type = struct foo \[*\]+" \
215 "whatis on opaque struct pointer (dynamically) 1"
218 # Ensure that we know the form of the thing foop points to.
220 setup_xfail_on_opaque_pointer
221 gdb_test "ptype foop" \
222 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \
223 "ptype on opaque struct pointer (dynamically) 2"
225 gdb_test "whatis afoo" \
226 "type = struct foo" \
227 "whatis on opaque struct instance (dynamically) 2"
230 # Ensure that we know the form of afoo, an instance of a struct foo.
232 gdb_test "ptype afoo" \
233 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
234 "ptype on opaque struct instance (dynamically) 2"
237 # Ensure that we know the form of an explicit struct foo.
239 gdb_test "ptype struct foo" \
240 "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
241 "ptype on opaque struct tagname (dynamically) 2"