Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1992, 1994, 1997 Free Software Foundation, Inc. |
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 | ||
87 | setup_xfail "a29k-*-udi" "vax-*-*" "i*86-sequent-bsd*" | |
88 | if {!$gcc_compiled} then { | |
89 | setup_xfail "alpha-*-*" "mips-sgi-irix5*" | |
90 | } | |
91 | } | |
92 | ||
93 | # This seems easier than trying to track different versions of xlc; I'm | |
94 | # not sure there is much rhyme or reason regarding which tests it fails | |
95 | # and which ones it passes. | |
96 | if {[istarget "rs6000-*-aix*"] && !$gcc_compiled} then { | |
97 | warning "xfails in opaque.exp may not be set up correctly for xlc" | |
98 | } | |
99 | ||
100 | setup_xfail_on_opaque_pointer | |
101 | gdb_test "whatis foop" \ | |
102 | "type = struct foo \[*\]+" \ | |
103 | "whatis on opaque struct pointer (statically)" | |
104 | ||
105 | ||
106 | # Ensure that we know the form of the structure that foop points to. | |
107 | ||
108 | setup_xfail_on_opaque_pointer | |
109 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "hppa*-*-hpux*" } | |
110 | gdb_test "ptype foop" \ | |
111 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
112 | "ptype on opaque struct pointer (statically)" | |
113 | ||
114 | ||
115 | # An instance of the opaque structure (afoo) is defined in a different file. | |
116 | # Ensure that we can locate afoo and the structure definition. | |
117 | ||
118 | gdb_test "whatis afoo" \ | |
119 | "type = struct foo" \ | |
120 | "whatis on opaque struct instance (statically)" | |
121 | ||
122 | ||
123 | # Ensure that we know the form of "afoo". | |
124 | ||
125 | gdb_test "ptype afoo" \ | |
126 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
127 | "ptype on opaque struct instance (statically)" | |
128 | ||
129 | ||
130 | # Ensure that we know what a struct foo looks like. | |
131 | ||
132 | gdb_test "ptype struct foo" \ | |
133 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
134 | "ptype on opaque struct tagname (statically)" | |
135 | ||
136 | ||
137 | # | |
138 | # Done with static tests, now test dynamic opaque structure handling. | |
139 | # We reload the symbol table so we forget about anything we might | |
140 | # have learned during the static tests. | |
141 | # | |
142 | ||
143 | if [istarget "mips-idt-*"] then { | |
144 | # Restart because IDT/SIM runs out of file descriptors. | |
145 | gdb_exit | |
146 | gdb_start | |
147 | } | |
148 | gdb_reinitialize_dir $srcdir/$subdir | |
149 | gdb_load ${binfile} | |
150 | ||
151 | # Run to main, where struct foo is incomplete. | |
152 | if ![runto_main] { | |
153 | perror "cannot run to breakpoint at main" | |
154 | } | |
155 | ||
156 | ||
157 | # The current source file is now the one containing main(). The structure foo | |
158 | # is defined in a different file, but we have a pointer to an instance of | |
159 | # the opaque structure in the current file. Ensure we know it's type. | |
160 | ||
161 | setup_xfail_on_opaque_pointer | |
162 | gdb_test "whatis foop" \ | |
163 | "type = struct foo \[*\]+" \ | |
164 | "whatis on opaque struct pointer (dynamically)" | |
165 | ||
166 | ||
167 | # Ensure that we know the form of the thing foop points to. | |
168 | ||
169 | setup_xfail_on_opaque_pointer | |
170 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "hppa*-*-hpux*" } | |
171 | gdb_test "ptype foop" \ | |
172 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
173 | "ptype on opaque struct pointer (dynamically) 1" | |
174 | ||
175 | gdb_test "whatis afoo" \ | |
176 | "type = struct foo" \ | |
177 | "whatis on opaque struct instance (dynamically) 1" | |
178 | ||
179 | ||
180 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
181 | ||
182 | gdb_test "ptype afoo" \ | |
183 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
184 | "ptype on opaque struct instance (dynamically) 1" | |
185 | ||
186 | ||
187 | # Ensure that we know the form of an explicit struct foo. | |
188 | ||
189 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } | |
190 | gdb_test "ptype struct foo" \ | |
191 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
192 | "ptype on opaque struct tagname (dynamically) 1" | |
193 | ||
194 | ||
195 | # Now reload the symbols again so we forget about anything we might | |
196 | # have learned reading the symbols during the previous tests. | |
197 | ||
198 | if [istarget "mips-idt-*"] then { | |
199 | # Restart because IDT/SIM runs out of file descriptors. | |
200 | gdb_exit | |
201 | gdb_start | |
202 | } | |
203 | gdb_reinitialize_dir $srcdir/$subdir | |
204 | gdb_load ${binfile} | |
205 | ||
206 | # Run to getfoo, where struct foo is complete. | |
207 | if ![runto getfoo] { | |
208 | perror "cannot run to breakpoint at getfoo" | |
209 | } | |
210 | ||
211 | ||
212 | # Ensure that we know what foop is. | |
213 | ||
214 | setup_xfail_on_opaque_pointer | |
215 | gdb_test "whatis foop" \ | |
216 | "type = struct foo \[*\]+" \ | |
217 | "whatis on opaque struct pointer (dynamically) 1" | |
218 | ||
219 | ||
220 | # Ensure that we know the form of the thing foop points to. | |
221 | ||
222 | setup_xfail_on_opaque_pointer | |
223 | if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "hppa*-*-hpux*" } | |
224 | gdb_test "ptype foop" \ | |
225 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \ | |
226 | "ptype on opaque struct pointer (dynamically) 2" | |
227 | ||
228 | gdb_test "whatis afoo" \ | |
229 | "type = struct foo" \ | |
230 | "whatis on opaque struct instance (dynamically) 2" | |
231 | ||
232 | ||
233 | # Ensure that we know the form of afoo, an instance of a struct foo. | |
234 | ||
235 | gdb_test "ptype afoo" \ | |
236 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
237 | "ptype on opaque struct instance (dynamically) 2" | |
238 | ||
239 | ||
240 | # Ensure that we know the form of an explicit struct foo. | |
241 | ||
242 | gdb_test "ptype struct foo" \ | |
243 | "type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \ | |
244 | "ptype on opaque struct tagname (dynamically) 2" |