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