]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/opaque.exp
* gdb.base/callfuncs.exp (do_function_calls): Add alpha-dec-osf2*
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / opaque.exp
1 # Copyright (C) 1992, 1994 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 binfile "opaque"
30 set srcfile $binfile.c
31
32 if ![file exists $objdir/$subdir/$binfile] then {
33 perror "$objdir/$subdir/$binfile does not exist."
34 return 0
35 }
36
37 # Start with a fresh gdb.
38
39 gdb_exit
40 gdb_start
41 gdb_reinitialize_dir $srcdir/$subdir
42 gdb_load $objdir/$subdir/$binfile
43
44 source gdb.base/opaque0.ci
45
46 #
47 # Test basic opaque structure handling (statically).
48 # The ordering of the tests is significant. We first try the things that
49 # might fail if gdb fails to connect the uses of opaque structures to
50 # the actual opaque structure definition.
51
52 # When we start up, gdb sets the file containing main() as the current
53 # source file. The actual structure foo is defined in a different file.
54 # A pointer (foop) to an instance of the opaque struct is defined in the same
55 # source file as main(). Ensure that gdb correctly "connected" the definition
56 # in the other file with the pointer to the opaque struct in the file containing
57 # "foop".
58
59 # Define a procedure to set up an xfail for all targets that do not support
60 # this sort of cross reference.
61 # Any target gcc that has a DBX_NO_XREFS definition in its config file will
62 # not support it (FIXME: Is this still true; I suspect maybe not).
63
64 # Native alpha ecoff doesn't support it either.
65 # I don't think this type of cross reference works for any COFF target
66 # either.
67
68 proc setup_xfail_on_opaque_pointer {} {
69 global gcc_compiled
70
71 setup_xfail "a29k-*-udi" "vax-*-*" "i*86-sequent-bsd*"
72 if {!$gcc_compiled} then {
73 setup_xfail "alpha-*-*" "mips-sgi-irix5*"
74 }
75 }
76
77 # This seems easier than trying to track different versions of xlc; I'm
78 # not sure there is much rhyme or reason regarding which tests it fails
79 # and which ones it passes.
80 if {[istarget "rs6000-*-aix*"] && !$gcc_compiled} then {
81 warning "xfails in opaque.exp may not be set up correctly for xlc"
82 }
83
84 setup_xfail_on_opaque_pointer
85 gdb_test "whatis foop" \
86 "type = struct foo \[*\]+" \
87 "whatis on opaque struct pointer (statically)"
88
89
90 # Ensure that we know the form of the structure that foop points to.
91
92 setup_xfail_on_opaque_pointer
93 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
94 gdb_test "ptype foop" \
95 "type = struct foo \{\r\n int a;\r\n int b;\r\n\} \[*\]+" \
96 "ptype on opaque struct pointer (statically)"
97
98
99 # An instance of the opaque structure (afoo) is defined in a different file.
100 # Ensure that we can locate afoo and the structure definition.
101
102 gdb_test "whatis afoo" \
103 "type = struct foo" \
104 "whatis on opaque struct instance (statically)"
105
106
107 # Ensure that we know the form of "afoo".
108
109 gdb_test "ptype afoo" \
110 "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \
111 "ptype on opaque struct instance (statically)"
112
113
114 # Ensure that we know what a struct foo looks like.
115
116 gdb_test "ptype struct foo" \
117 "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \
118 "ptype on opaque struct tagname (statically)"
119
120
121 #
122 # Done with static tests, now test dynamic opaque structure handling.
123 # We reload the symbol table so we forget about anything we might
124 # have learned during the static tests.
125 #
126
127 if [istarget "mips-idt-*"] then {
128 # Restart because IDT/SIM runs out of file descriptors.
129 gdb_exit
130 gdb_start
131 }
132 gdb_reinitialize_dir $srcdir/$subdir
133 gdb_load $objdir/$subdir/$binfile
134
135 # Run to main, where struct foo is incomplete.
136 if ![runto_main] {
137 perror "cannot run to breakpoint at main"
138 }
139
140
141 # The current source file is now the one containing main(). The structure foo
142 # is defined in a different file, but we have a pointer to an instance of
143 # the opaque structure in the current file. Ensure we know it's type.
144
145 setup_xfail_on_opaque_pointer
146 gdb_test "whatis foop" \
147 "type = struct foo \[*\]+" \
148 "whatis on opaque struct pointer (dynamically)"
149
150
151 # Ensure that we know the form of the thing foop points to.
152
153 setup_xfail_on_opaque_pointer
154 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
155 gdb_test "ptype foop" \
156 "type = struct foo \{\r\n int a;\r\n int b;\r\n\} \[*\]+" \
157 "ptype on opaque struct pointer (dynamically) 1"
158
159 gdb_test "whatis afoo" \
160 "type = struct foo" \
161 "whatis on opaque struct instance (dynamically) 1"
162
163
164 # Ensure that we know the form of afoo, an instance of a struct foo.
165
166 gdb_test "ptype afoo" \
167 "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \
168 "ptype on opaque struct instance (dynamically) 1"
169
170
171 # Ensure that we know the form of an explicit struct foo.
172
173 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
174 gdb_test "ptype struct foo" \
175 "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \
176 "ptype on opaque struct tagname (dynamically) 1"
177
178
179 # Now reload the symbols again so we forget about anything we might
180 # have learned reading the symbols during the previous tests.
181
182 if [istarget "mips-idt-*"] then {
183 # Restart because IDT/SIM runs out of file descriptors.
184 gdb_exit
185 gdb_start
186 }
187 gdb_reinitialize_dir $srcdir/$subdir
188 gdb_load $objdir/$subdir/$binfile
189
190 # Run to getfoo, where struct foo is complete.
191 if ![runto getfoo] {
192 perror "cannot run to breakpoint at getfoo"
193 }
194
195
196 # Ensure that we know what foop is.
197
198 setup_xfail_on_opaque_pointer
199 gdb_test "whatis foop" \
200 "type = struct foo \[*\]+" \
201 "whatis on opaque struct pointer (dynamically)"
202
203
204 # Ensure that we know the form of the thing foop points to.
205
206 setup_xfail_on_opaque_pointer
207 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
208 gdb_test "ptype foop" \
209 "type = struct foo \{\r\n int a;\r\n int b;\r\n\} \[*\]+" \
210 "ptype on opaque struct pointer (dynamically) 2"
211
212 gdb_test "whatis afoo" \
213 "type = struct foo" \
214 "whatis on opaque struct instance (dynamically) 2"
215
216
217 # Ensure that we know the form of afoo, an instance of a struct foo.
218
219 gdb_test "ptype afoo" \
220 "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \
221 "ptype on opaque struct instance (dynamically) 2"
222
223
224 # Ensure that we know the form of an explicit struct foo.
225
226 gdb_test "ptype struct foo" \
227 "type = struct foo \{\r\n int a;\r\n int b;\r\n\}" \
228 "ptype on opaque struct tagname (dynamically) 2"