]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/whatis.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.c
CommitLineData
96033e83
MC
1/* This test program is part of GDB, the GNU debugger.
2
6aba47ca 3 Copyright 1992, 1993, 1994, 1997, 1999, 2004, 2007
96033e83
MC
4 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
c906108c
SS
21/*
22 * Test file with lots of different types, for testing the
23 * "whatis" command.
24 */
25
26/*
27 * First the basic C types.
28 */
29
c906108c
SS
30char v_char;
31signed char v_signed_char;
32unsigned char v_unsigned_char;
33
34short v_short;
35signed short v_signed_short;
36unsigned short v_unsigned_short;
37
38int v_int;
39signed int v_signed_int;
40unsigned int v_unsigned_int;
41
42long v_long;
43signed long v_signed_long;
44unsigned long v_unsigned_long;
45
46float v_float;
47double v_double;
48
49/*
50 * Now some derived types, which are arrays, functions-returning,
51 * pointers, structures, unions, and enumerations.
52 */
53
54/**** arrays *******/
55
56char v_char_array[2];
57signed char v_signed_char_array[2];
58unsigned char v_unsigned_char_array[2];
59
60short v_short_array[2];
61signed short v_signed_short_array[2];
62unsigned short v_unsigned_short_array[2];
63
64int v_int_array[2];
65signed int v_signed_int_array[2];
66unsigned int v_unsigned_int_array[2];
67
68long v_long_array[2];
69signed long v_signed_long_array[2];
70unsigned long v_unsigned_long_array[2];
71
72float v_float_array[2];
73double v_double_array[2];
74
75/**** pointers *******/
76
77/* Make sure they still print as pointer to foo even there is a typedef
78 for that type. Test this not just for char *, which might be
79 a special case kludge in GDB (Unix system include files like to define
80 caddr_t), but for a variety of types. */
81typedef char *char_addr;
f8261448 82static char_addr a_char_addr;
c906108c 83typedef unsigned short *ushort_addr;
f8261448 84static ushort_addr a_ushort_addr;
c906108c 85typedef signed long *slong_addr;
f8261448 86static slong_addr a_slong_addr;
c906108c
SS
87
88char *v_char_pointer;
89signed char *v_signed_char_pointer;
90unsigned char *v_unsigned_char_pointer;
91
92short *v_short_pointer;
93signed short *v_signed_short_pointer;
94unsigned short *v_unsigned_short_pointer;
95
96int *v_int_pointer;
97signed int *v_signed_int_pointer;
98unsigned int *v_unsigned_int_pointer;
99
100long *v_long_pointer;
101signed long *v_signed_long_pointer;
102unsigned long *v_unsigned_long_pointer;
103
104float *v_float_pointer;
105double *v_double_pointer;
106
107/**** structs *******/
108
109struct t_struct {
110 char v_char_member;
111 short v_short_member;
112 int v_int_member;
113 long v_long_member;
114 float v_float_member;
115 double v_double_member;
116} v_struct1;
117
118struct {
119 char v_char_member;
120 short v_short_member;
121 int v_int_member;
122 long v_long_member;
123 float v_float_member;
124 double v_double_member;
125} v_struct2;
126
127/**** unions *******/
128
129union t_union {
130 char v_char_member;
131 short v_short_member;
132 int v_int_member;
133 long v_long_member;
134 float v_float_member;
135 double v_double_member;
136} v_union;
137
138union {
139 char v_char_member;
140 short v_short_member;
141 int v_int_member;
142 long v_long_member;
143 float v_float_member;
144 double v_double_member;
145} v_union2;
146
147/*** Functions returning type ********/
148
149char v_char_func () { return(0); }
150signed char v_signed_char_func () { return (0); }
151unsigned char v_unsigned_char_func () { return (0); }
152
153short v_short_func () { return (0); }
154signed short v_signed_short_func () { return (0); }
155unsigned short v_unsigned_short_func () { return (0); }
156
157int v_int_func () { return (0); }
158signed int v_signed_int_func () { return (0); }
159unsigned int v_unsigned_int_func () { return (0); }
160
161long v_long_func () { return (0); }
162signed long v_signed_long_func () { return (0); }
163unsigned long v_unsigned_long_func () { return (0); }
164
165float v_float_func () { return (0.0); }
166double v_double_func () { return (0.0); }
167
168/**** Some misc more complicated things *******/
169
170struct link {
171 struct link *next;
172#ifdef __STDC__
173 struct link *(*linkfunc) (struct link *this, int flags);
174#else
175 struct link *(*linkfunc) ();
176#endif
177 struct t_struct stuff[1][2][3];
178} *s_link;
179
180union tu_link {
181 struct link *next;
182#ifdef __STDC__
183 struct link *(*linkfunc) (struct link *this, int flags);
184#else
185 struct link *(*linkfunc) ();
186#endif
187 struct t_struct stuff[1][2][3];
188} u_link;
189
190struct outer_struct {
191 int outer_int;
192 struct inner_struct {
193 int inner_int;
194 long inner_long;
195 }inner_struct_instance;
196 union inner_union {
197 int inner_union_int;
198 long inner_union_long;
199 }inner_union_instance;
200 long outer_long;
201} nested_su;
202
203/**** Enumerations *******/
204
205enum colors {red, green, blue} color;
206enum cars {chevy, ford, porsche} clunker;
207
208/***********/
209
085dd6e6 210int main ()
c906108c
SS
211{
212#ifdef usestubs
213 set_debug_traps();
214 breakpoint();
215#endif
216 /* Some linkers (e.g. on AIX) remove unreferenced variables,
217 so make sure to reference them. */
218 v_char = 0;
219 v_signed_char = 1;
220 v_unsigned_char = 2;
221
222 v_short = 3;
223 v_signed_short = 4;
224 v_unsigned_short = 5;
225
226 v_int = 6;
227 v_signed_int = 7;
228 v_unsigned_int = 8;
229
230 v_long = 9;
231 v_signed_long = 10;
232 v_unsigned_long = 11;
233
234 v_float = 100.0;
235 v_double = 200.0;
236
237
238 v_char_array[0] = v_char;
239 v_signed_char_array[0] = v_signed_char;
240 v_unsigned_char_array[0] = v_unsigned_char;
241
242 v_short_array[0] = v_short;
243 v_signed_short_array[0] = v_signed_short;
244 v_unsigned_short_array[0] = v_unsigned_short;
245
246 v_int_array[0] = v_int;
247 v_signed_int_array[0] = v_signed_int;
248 v_unsigned_int_array[0] = v_unsigned_int;
249
250 v_long_array[0] = v_long;
251 v_signed_long_array[0] = v_signed_long;
252 v_unsigned_long_array[0] = v_unsigned_long;
253
254 v_float_array[0] = v_float;
255 v_double_array[0] = v_double;
256
257 v_char_pointer = &v_char;
258 v_signed_char_pointer = &v_signed_char;
259 v_unsigned_char_pointer = &v_unsigned_char;
260
261 v_short_pointer = &v_short;
262 v_signed_short_pointer = &v_signed_short;
263 v_unsigned_short_pointer = &v_unsigned_short;
264
265 v_int_pointer = &v_int;
266 v_signed_int_pointer = &v_signed_int;
267 v_unsigned_int_pointer = &v_unsigned_int;
268
269 v_long_pointer = &v_long;
270 v_signed_long_pointer = &v_signed_long;
271 v_unsigned_long_pointer = &v_unsigned_long;
272
273 v_float_pointer = &v_float;
274 v_double_pointer = &v_double;
275
276 color = red;
277 clunker = porsche;
278
279 u_link.next = s_link;
280
281 v_union2.v_short_member = v_union.v_short_member;
282
283 v_struct1.v_char_member = 0;
284 v_struct2.v_char_member = 0;
285
286 nested_su.outer_int = 0;
287 return 0;
288}