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