]> Git Repo - binutils.git/blame - gdb/testsuite/gdb.base/setvar.c
Initial creation of sourceware repository
[binutils.git] / gdb / testsuite / gdb.base / setvar.c
CommitLineData
c906108c
SS
1main (argc, argv, envp)
2 int argc;
3 char **argv;
4 char **envp;
5{
6 extern void dummy();
7#ifdef usestubs
8 set_debug_traps();
9 breakpoint();
10#endif
11 dummy();
12}
13
14/* We put main() right up front so its line number doesn't keep changing. */
15
16/*
17 * Test file with lots of different types, for testing the
18 * "whatis" command.
19 */
20
21/*
22 * First the basic C types.
23 */
24
25#if !defined (__STDC__) && !defined (_AIX)
26#define signed /**/
27#endif
28
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
45float v_float;
46double v_double;
47
48/*
49 * Now some derived types, which are arrays, functions-returning,
50 * pointers, structures, unions, and enumerations.
51 */
52
53/**** arrays *******/
54
55char v_char_array[2];
56signed char v_signed_char_array[2];
57unsigned char v_unsigned_char_array[2];
58
59short v_short_array[2];
60signed short v_signed_short_array[2];
61unsigned short v_unsigned_short_array[2];
62
63int v_int_array[2];
64signed int v_signed_int_array[2];
65unsigned int v_unsigned_int_array[2];
66
67long v_long_array[2];
68signed long v_signed_long_array[2];
69unsigned long v_unsigned_long_array[2];
70
71float v_float_array[2];
72double v_double_array[2];
73
74/**** pointers *******/
75
76char *v_char_pointer;
77signed char *v_signed_char_pointer;
78unsigned char *v_unsigned_char_pointer;
79
80short *v_short_pointer;
81signed short *v_signed_short_pointer;
82unsigned short *v_unsigned_short_pointer;
83
84int *v_int_pointer;
85signed int *v_signed_int_pointer;
86unsigned int *v_unsigned_int_pointer;
87
88long *v_long_pointer;
89signed long *v_signed_long_pointer;
90unsigned long *v_unsigned_long_pointer;
91
92float *v_float_pointer;
93double *v_double_pointer;
94
95/**** structs *******/
96
97struct t_struct {
98 char v_char_member;
99 short v_short_member;
100 int v_int_member;
101 long v_long_member;
102 float v_float_member;
103 double v_double_member;
104} v_struct1;
105
106struct {
107 char v_char_member;
108 short v_short_member;
109 int v_int_member;
110 long v_long_member;
111 float v_float_member;
112 double v_double_member;
113} v_struct2;
114
115/**** unions *******/
116
117union t_union {
118 char v_char_member;
119 short v_short_member;
120 int v_int_member;
121 long v_long_member;
122 float v_float_member;
123 double v_double_member;
124} v_union;
125
126union {
127 char v_char_member;
128 short v_short_member;
129 int v_int_member;
130 long v_long_member;
131 float v_float_member;
132 double v_double_member;
133} v_union2;
134
135/*** Functions returning type ********/
136
137char v_char_func () { return(0); }
138signed char v_signed_char_func () { return (0); }
139unsigned char v_unsigned_char_func () { return (0); }
140
141short v_short_func () { return (0); }
142signed short v_signed_short_func () { return (0); }
143unsigned short v_unsigned_short_func () { return (0); }
144
145int v_int_func () { return (0); }
146signed int v_signed_int_func () { return (0); }
147unsigned int v_unsigned_int_func () { return (0); }
148
149long v_long_func () { return (0); }
150signed long v_signed_long_func () { return (0); }
151unsigned long v_unsigned_long_func () { return (0); }
152
153float v_float_func () { return (0.0); }
154double v_double_func () { return (0.0); }
155
156/**** Some misc more complicated things *******/
157
158struct link {
159 struct link *next;
160#ifdef __STDC__
161 struct link *(*linkfunc) (struct link *this, int flags);
162#else
163 struct link *(*linkfunc) ();
164#endif
165 struct t_struct stuff[1][2][3];
166} *s_link;
167
168union tu_link {
169 struct link *next;
170#ifdef __STDC__
171 struct link *(*linkfunc) (struct link *this, int flags);
172#else
173 struct link *(*linkfunc) ();
174#endif
175 struct t_struct stuff[1][2][3];
176} u_link;
177
178/**** Enumerations *******/
179
180enum colors {red, green, blue} color;
181enum cars {chevy, ford, porsche} clunker;
182
183/**** Enumeration bitfields, supported by GNU C *******/
184
185#ifdef __GNUC__
186enum senum {sm1 = -1, s1 = 1};
187struct senum_field {enum senum field:2; } sef;
188enum uenum {u1 = 1, u2 = 2};
189struct uenum_field {enum uenum field:2; } uef;
190#endif
191
192void
193dummy ()
194{
195 /* setvar.exp wants to allocate memory for constants. So make sure malloc
196 gets linked into the program. */
197 malloc (1);
198
199 /* Some linkers (e.g. on AIX) remove unreferenced variables,
200 so make sure to reference them. */
201 v_char = 0;
202 v_signed_char = 1;
203 v_unsigned_char = 2;
204
205 v_short = 3;
206 v_signed_short = 4;
207 v_unsigned_short = 5;
208
209 v_int = 6;
210 v_signed_int = 7;
211 v_unsigned_int = 8;
212
213 v_long = 9;
214 v_signed_long = 10;
215 v_unsigned_long = 11;
216
217 v_float = 100.0;
218 v_double = 200.0;
219
220
221 v_char_array[0] = v_char;
222 v_signed_char_array[0] = v_signed_char;
223 v_unsigned_char_array[0] = v_unsigned_char;
224
225 v_short_array[0] = v_short;
226 v_signed_short_array[0] = v_signed_short;
227 v_unsigned_short_array[0] = v_unsigned_short;
228
229 v_int_array[0] = v_int;
230 v_signed_int_array[0] = v_signed_int;
231 v_unsigned_int_array[0] = v_unsigned_int;
232
233 v_long_array[0] = v_long;
234 v_signed_long_array[0] = v_signed_long;
235 v_unsigned_long_array[0] = v_unsigned_long;
236
237 v_float_array[0] = v_float;
238 v_double_array[0] = v_double;
239
240 v_char_pointer = &v_char;
241 v_signed_char_pointer = &v_signed_char;
242 v_unsigned_char_pointer = &v_unsigned_char;
243
244 v_short_pointer = &v_short;
245 v_signed_short_pointer = &v_signed_short;
246 v_unsigned_short_pointer = &v_unsigned_short;
247
248 v_int_pointer = &v_int;
249 v_signed_int_pointer = &v_signed_int;
250 v_unsigned_int_pointer = &v_unsigned_int;
251
252 v_long_pointer = &v_long;
253 v_signed_long_pointer = &v_signed_long;
254 v_unsigned_long_pointer = &v_unsigned_long;
255
256 v_float_pointer = &v_float;
257 v_double_pointer = &v_double;
258
259 color = red;
260 clunker = porsche;
261
262 u_link.next = s_link;
263
264 v_struct2.v_int_member = v_struct1.v_int_member;
265 v_union2.v_short_member = v_union.v_short_member;
266
267#ifdef __GNUC__
268 sef.field = s1;
269 uef.field = u1;
270#endif
271}
This page took 0.047852 seconds and 4 git commands to generate.