]>
Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2007, 2008, 2009, 2010 |
6aba47ca | 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 | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
c906108c SS |
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. | |
e22f8b7c | 13 | # |
c906108c | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 16 | |
c906108c SS |
17 | # This file was written by Fred Fish. ([email protected]) |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
c906108c SS |
23 | |
24 | set testfile "opaque" | |
25 | set binfile ${objdir}/${subdir}/opaque | |
26 | ||
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." | |
29 | #} | |
30 | ||
31 | if { [gdb_compile "${srcdir}/${subdir}/opaque0.c" "${binfile}0.o" object {debug}] != "" } { | |
b60f0898 JB |
32 | untested opaque.exp |
33 | return -1 | |
c906108c SS |
34 | } |
35 | ||
36 | if { [gdb_compile "${srcdir}/${subdir}/opaque1.c" "${binfile}1.o" object {debug}] != "" } { | |
b60f0898 JB |
37 | untested opaque.exp |
38 | return -1 | |
c906108c SS |
39 | } |
40 | ||
41 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } { | |
b60f0898 JB |
42 | untested opaque.exp |
43 | return -1 | |
c906108c SS |
44 | } |
45 | ||
46 | ||
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}] { | |
50 | return -1; | |
51 | } | |
52 | ||
53 | # Start with a fresh gdb. | |
54 | ||
55 | gdb_exit | |
56 | gdb_start | |
57 | gdb_reinitialize_dir $srcdir/$subdir | |
58 | gdb_load ${binfile} | |
59 | ||
60 | # | |
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. | |
65 | ||
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 | |
71 | # "foop". | |
72 | ||
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). | |
77 | ||
78 | # Native alpha ecoff doesn't support it either. | |
79 | # I don't think this type of cross reference works for any COFF target | |
80 | # either. | |
81 | ||
82 | proc setup_xfail_on_opaque_pointer {} { | |
83 | global gcc_compiled | |
84 | ||
9fbfe2dc | 85 | setup_xfail "vax-*-*" "i*86-sequent-bsd*" |
c906108c SS |
86 | if {!$gcc_compiled} then { |
87 | setup_xfail "alpha-*-*" "mips-sgi-irix5*" | |
88 | } | |
89 | } | |
90 | ||
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" | |
96 | } | |
97 | ||
98 | setup_xfail_on_opaque_pointer | |
99 | gdb_test "whatis foop" \ | |
100 | "type = struct foo \[*\]+" \ | |
101 | "whatis on opaque struct pointer (statically)" | |
102 | ||
103 | ||
104 | # Ensure that we know the form of the structure that foop points to. | |
105 | ||
106 | setup_xfail_on_opaque_pointer | |
085dd6e6 | 107 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
c906108c SS |
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)" | |
111 | ||
112 | ||
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. | |
115 | ||
116 | gdb_test "whatis afoo" \ | |
117 | "type = struct foo" \ | |
118 | "whatis on opaque struct instance (statically)" | |
119 | ||
120 | ||
121 | # Ensure that we know the form of "afoo". | |
122 | ||
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)" | |
126 | ||
127 | ||
128 | # Ensure that we know what a struct foo looks like. | |
129 | ||
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)" | |
133 | ||
134 | ||
135 | # | |
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. | |
139 | # | |
140 | ||
141 | if [istarget "mips-idt-*"] then { | |
142 | # Restart because IDT/SIM runs out of file descriptors. | |
143 | gdb_exit | |
144 | gdb_start | |
145 | } | |
146 | gdb_reinitialize_dir $srcdir/$subdir | |
147 | gdb_load ${binfile} | |
148 | ||
149 | # Run to main, where struct foo is incomplete. | |
150 | if ![runto_main] { | |
151 | perror "cannot run to breakpoint at main" | |
152 | } | |
153 | ||
154 | ||
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. | |
158 | ||
159 | setup_xfail_on_opaque_pointer | |
160 | gdb_test "whatis foop" \ | |
161 | "type = struct foo \[*\]+" \ | |
162 | "whatis on opaque struct pointer (dynamically)" | |
163 | ||
164 | ||
165 | # Ensure that we know the form of the thing foop points to. | |
166 | ||
167 | setup_xfail_on_opaque_pointer | |
085dd6e6 | 168 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } |
c906108c SS |
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" | |
172 | ||
173 | gdb_test "whatis afoo" \ | |
174 | "type = struct foo" \ | |
175 | "whatis on opaque struct instance (dynamically) 1" | |
176 | ||
177 | ||
178 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
179 | ||
180 | gdb_test "ptype afoo" \ | |
181 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
bcf71277 | 182 | "ptype on opaque struct instance (dynamically) 1" |
c906108c SS |
183 | |
184 | ||
185 | # Ensure that we know the form of an explicit struct foo. | |
186 | ||
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" | |
191 | ||
192 | ||
193 | # Now reload the symbols again so we forget about anything we might | |
194 | # have learned reading the symbols during the previous tests. | |
195 | ||
196 | if [istarget "mips-idt-*"] then { | |
197 | # Restart because IDT/SIM runs out of file descriptors. | |
198 | gdb_exit | |
199 | gdb_start | |
200 | } | |
201 | gdb_reinitialize_dir $srcdir/$subdir | |
202 | gdb_load ${binfile} | |
203 | ||
204 | # Run to getfoo, where struct foo is complete. | |
205 | if ![runto getfoo] { | |
206 | perror "cannot run to breakpoint at getfoo" | |
207 | } | |
208 | ||
209 | ||
210 | # Ensure that we know what foop is. | |
211 | ||
212 | setup_xfail_on_opaque_pointer | |
213 | gdb_test "whatis foop" \ | |
214 | "type = struct foo \[*\]+" \ | |
215 | "whatis on opaque struct pointer (dynamically) 1" | |
216 | ||
217 | ||
218 | # Ensure that we know the form of the thing foop points to. | |
219 | ||
220 | setup_xfail_on_opaque_pointer | |
c906108c SS |
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" | |
224 | ||
225 | gdb_test "whatis afoo" \ | |
226 | "type = struct foo" \ | |
227 | "whatis on opaque struct instance (dynamically) 2" | |
228 | ||
229 | ||
230 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
231 | ||
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" | |
235 | ||
236 | ||
237 | # Ensure that we know the form of an explicit struct foo. | |
238 | ||
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" |