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