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