* gdb.base/call-signal-resume.exp, gdb.base/unwindonsignal.exp: Skip
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / whatis.c
CommitLineData
96033e83
MC
1/* This test program is part of GDB, the GNU debugger.
2
4c38e0a4 3 Copyright 1992, 1993, 1994, 1997, 1999, 2004, 2007, 2008, 2009, 2010
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
a9762ec7 8 the Free Software Foundation; either version 3 of the License, or
96033e83
MC
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.
a9762ec7 15
96033e83 16 You should have received a copy of the GNU General Public License
a9762ec7 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
96033e83
MC
18 */
19
c906108c
SS
20/*
21 * Test file with lots of different types, for testing the
22 * "whatis" command.
23 */
24
25/*
26 * First the basic C types.
27 */
28
c906108c
SS
29char v_char;
30signed char v_signed_char;
31unsigned char v_unsigned_char;
32
33short v_short;
34signed short v_signed_short;
35unsigned short v_unsigned_short;
36
37int v_int;
38signed int v_signed_int;
39unsigned int v_unsigned_int;
40
41long v_long;
42signed long v_signed_long;
43unsigned long v_unsigned_long;
44
64b2fa04
PA
45#ifndef NO_LONG_LONG
46long long v_long_long;
47signed long long v_signed_long_long;
48unsigned long long v_unsigned_long_long;
49#endif
50
c906108c
SS
51float v_float;
52double v_double;
53
54/*
55 * Now some derived types, which are arrays, functions-returning,
56 * pointers, structures, unions, and enumerations.
57 */
58
59/**** arrays *******/
60
61char v_char_array[2];
62signed char v_signed_char_array[2];
63unsigned char v_unsigned_char_array[2];
64
65short v_short_array[2];
66signed short v_signed_short_array[2];
67unsigned short v_unsigned_short_array[2];
68
69int v_int_array[2];
70signed int v_signed_int_array[2];
71unsigned int v_unsigned_int_array[2];
72
73long v_long_array[2];
74signed long v_signed_long_array[2];
75unsigned long v_unsigned_long_array[2];
76
64b2fa04
PA
77#ifndef NO_LONG_LONG
78long long v_long_long_array[2];
79signed long long v_signed_long_long_array[2];
80unsigned long long v_unsigned_long_long_array[2];
81#endif
82
c906108c
SS
83float v_float_array[2];
84double v_double_array[2];
85
86/**** pointers *******/
87
88/* Make sure they still print as pointer to foo even there is a typedef
89 for that type. Test this not just for char *, which might be
90 a special case kludge in GDB (Unix system include files like to define
91 caddr_t), but for a variety of types. */
92typedef char *char_addr;
f8261448 93static char_addr a_char_addr;
c906108c 94typedef unsigned short *ushort_addr;
f8261448 95static ushort_addr a_ushort_addr;
c906108c 96typedef signed long *slong_addr;
f8261448 97static slong_addr a_slong_addr;
64b2fa04
PA
98#ifndef NO_LONG_LONG
99typedef signed long long *slong_long_addr;
100static slong_long_addr a_slong_long_addr;
101#endif
c906108c
SS
102
103char *v_char_pointer;
104signed char *v_signed_char_pointer;
105unsigned char *v_unsigned_char_pointer;
106
107short *v_short_pointer;
108signed short *v_signed_short_pointer;
109unsigned short *v_unsigned_short_pointer;
110
111int *v_int_pointer;
112signed int *v_signed_int_pointer;
113unsigned int *v_unsigned_int_pointer;
114
115long *v_long_pointer;
116signed long *v_signed_long_pointer;
117unsigned long *v_unsigned_long_pointer;
118
64b2fa04
PA
119#ifndef NO_LONG_LONG
120long long *v_long_long_pointer;
121signed long long *v_signed_long_long_pointer;
122unsigned long long *v_unsigned_long_long_pointer;
123#endif
124
c906108c
SS
125float *v_float_pointer;
126double *v_double_pointer;
127
128/**** structs *******/
129
130struct t_struct {
131 char v_char_member;
132 short v_short_member;
133 int v_int_member;
134 long v_long_member;
64b2fa04
PA
135#ifndef NO_LONG_LONG
136 long long v_long_long_member;
137#endif
c906108c
SS
138 float v_float_member;
139 double v_double_member;
140} v_struct1;
141
142struct {
143 char v_char_member;
144 short v_short_member;
145 int v_int_member;
146 long v_long_member;
64b2fa04
PA
147#ifndef NO_LONG_LONG
148 long long v_long_long_member;
149#endif
c906108c
SS
150 float v_float_member;
151 double v_double_member;
152} v_struct2;
153
154/**** unions *******/
155
156union t_union {
157 char v_char_member;
158 short v_short_member;
159 int v_int_member;
160 long v_long_member;
64b2fa04
PA
161#ifndef NO_LONG_LONG
162 long long v_long_long_member;
163#endif
c906108c
SS
164 float v_float_member;
165 double v_double_member;
166} v_union;
167
168union {
169 char v_char_member;
170 short v_short_member;
171 int v_int_member;
172 long v_long_member;
64b2fa04
PA
173#ifndef NO_LONG_LONG
174 long long v_long_long_member;
175#endif
c906108c
SS
176 float v_float_member;
177 double v_double_member;
178} v_union2;
179
180/*** Functions returning type ********/
181
182char v_char_func () { return(0); }
183signed char v_signed_char_func () { return (0); }
184unsigned char v_unsigned_char_func () { return (0); }
185
186short v_short_func () { return (0); }
187signed short v_signed_short_func () { return (0); }
188unsigned short v_unsigned_short_func () { return (0); }
189
190int v_int_func () { return (0); }
191signed int v_signed_int_func () { return (0); }
192unsigned int v_unsigned_int_func () { return (0); }
193
194long v_long_func () { return (0); }
195signed long v_signed_long_func () { return (0); }
196unsigned long v_unsigned_long_func () { return (0); }
197
64b2fa04
PA
198#ifndef NO_LONG_LONG
199long long v_long_long_func () { return (0); }
200signed long long v_signed_long_long_func () { return (0); }
201unsigned long long v_unsigned_long_long_func () { return (0); }
202#endif
203
c906108c
SS
204float v_float_func () { return (0.0); }
205double v_double_func () { return (0.0); }
206
207/**** Some misc more complicated things *******/
208
209struct link {
210 struct link *next;
211#ifdef __STDC__
212 struct link *(*linkfunc) (struct link *this, int flags);
213#else
214 struct link *(*linkfunc) ();
215#endif
216 struct t_struct stuff[1][2][3];
217} *s_link;
218
219union tu_link {
220 struct link *next;
221#ifdef __STDC__
222 struct link *(*linkfunc) (struct link *this, int flags);
223#else
224 struct link *(*linkfunc) ();
225#endif
226 struct t_struct stuff[1][2][3];
227} u_link;
228
229struct outer_struct {
230 int outer_int;
231 struct inner_struct {
232 int inner_int;
233 long inner_long;
234 }inner_struct_instance;
235 union inner_union {
236 int inner_union_int;
237 long inner_union_long;
238 }inner_union_instance;
239 long outer_long;
240} nested_su;
241
242/**** Enumerations *******/
243
244enum colors {red, green, blue} color;
245enum cars {chevy, ford, porsche} clunker;
246
247/***********/
248
085dd6e6 249int main ()
c906108c
SS
250{
251#ifdef usestubs
252 set_debug_traps();
253 breakpoint();
254#endif
255 /* Some linkers (e.g. on AIX) remove unreferenced variables,
256 so make sure to reference them. */
257 v_char = 0;
258 v_signed_char = 1;
259 v_unsigned_char = 2;
260
261 v_short = 3;
262 v_signed_short = 4;
263 v_unsigned_short = 5;
264
265 v_int = 6;
266 v_signed_int = 7;
267 v_unsigned_int = 8;
268
269 v_long = 9;
270 v_signed_long = 10;
271 v_unsigned_long = 11;
64b2fa04
PA
272
273#ifndef NO_LONG_LONG
274 v_long_long = 12;
275 v_signed_long_long = 13;
276 v_unsigned_long_long = 14;
277#endif
278
c906108c
SS
279 v_float = 100.0;
280 v_double = 200.0;
281
282
283 v_char_array[0] = v_char;
284 v_signed_char_array[0] = v_signed_char;
285 v_unsigned_char_array[0] = v_unsigned_char;
286
287 v_short_array[0] = v_short;
288 v_signed_short_array[0] = v_signed_short;
289 v_unsigned_short_array[0] = v_unsigned_short;
290
291 v_int_array[0] = v_int;
292 v_signed_int_array[0] = v_signed_int;
293 v_unsigned_int_array[0] = v_unsigned_int;
294
295 v_long_array[0] = v_long;
296 v_signed_long_array[0] = v_signed_long;
297 v_unsigned_long_array[0] = v_unsigned_long;
298
64b2fa04
PA
299#ifndef NO_LONG_LONG
300 v_long_long_array[0] = v_long_long;
301 v_signed_long_long_array[0] = v_signed_long_long;
302 v_unsigned_long_long_array[0] = v_unsigned_long_long;
303#endif
304
c906108c
SS
305 v_float_array[0] = v_float;
306 v_double_array[0] = v_double;
307
308 v_char_pointer = &v_char;
309 v_signed_char_pointer = &v_signed_char;
310 v_unsigned_char_pointer = &v_unsigned_char;
311
312 v_short_pointer = &v_short;
313 v_signed_short_pointer = &v_signed_short;
314 v_unsigned_short_pointer = &v_unsigned_short;
315
316 v_int_pointer = &v_int;
317 v_signed_int_pointer = &v_signed_int;
318 v_unsigned_int_pointer = &v_unsigned_int;
319
320 v_long_pointer = &v_long;
321 v_signed_long_pointer = &v_signed_long;
322 v_unsigned_long_pointer = &v_unsigned_long;
323
64b2fa04
PA
324#ifndef NO_LONG_LONG
325 v_long_long_pointer = &v_long_long;
326 v_signed_long_long_pointer = &v_signed_long_long;
327 v_unsigned_long_long_pointer = &v_unsigned_long_long;
328#endif
329
c906108c
SS
330 v_float_pointer = &v_float;
331 v_double_pointer = &v_double;
332
333 color = red;
334 clunker = porsche;
335
336 u_link.next = s_link;
337
338 v_union2.v_short_member = v_union.v_short_member;
339
340 v_struct1.v_char_member = 0;
341 v_struct2.v_char_member = 0;
342
343 nested_su.outer_int = 0;
344 return 0;
345}
This page took 0.982588 seconds and 4 git commands to generate.