aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/structs.c
blob: 7c521e76662874613d83204398f13a1967494271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/* This testcase is part of GDB, the GNU debugger.

   Copyright 1996-2017 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

/* Useful abreviations.  */
typedef void t;
typedef char tc;
typedef short ts;
typedef int ti;
typedef long tl;
typedef long long tll;
typedef float tf;
typedef double td;
typedef long double tld;

/* Force the type of each field.  */
#ifndef tA
typedef t tA;
#endif
#ifndef tB
typedef tA tB;
#endif
#ifndef tC
typedef tB tC;
#endif
#ifndef tD
typedef tC tD;
#endif
#ifndef tE
typedef tD tE;
#endif
#ifndef tF
typedef tE tF;
#endif
#ifndef tG
typedef tF tG;
#endif
#ifndef tH
typedef tG tH;
#endif
#ifndef tI
typedef tH tI;
#endif
#ifndef tJ
typedef tI tJ;
#endif
#ifndef tK
typedef tJ tK;
#endif
#ifndef tL
typedef tK tL;
#endif
#ifndef tM
typedef tL tM;
#endif
#ifndef tN
typedef tM tN;
#endif
#ifndef tO
typedef tN tO;
#endif
#ifndef tP
typedef tO tP;
#endif
#ifndef tQ
typedef tP tQ;
#endif
#ifndef tR
typedef tQ tR;
#endif

struct  struct1 {tA a;};
struct  struct2 {tA a; tB b;};
struct  struct3 {tA a; tB b; tC c; };
struct  struct4 {tA a; tB b; tC c; tD d; };
struct  struct5 {tA a; tB b; tC c; tD d; tE e; };
struct  struct6 {tA a; tB b; tC c; tD d; tE e; tF f; };
struct  struct7 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; };
struct  struct8 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; };
struct  struct9 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; };
struct struct10 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; };
struct struct11 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; };
struct struct12 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; };
struct struct13 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; };
struct struct14 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; };
struct struct15 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; };
struct struct16 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; };
struct struct17 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; };
struct struct18 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; tR r; };

struct  struct1  foo1 = {'1'}, L1;
struct  struct2  foo2 = {'a','2'}, L2;
struct  struct3  foo3 = {'1','b','3'}, L3;
struct  struct4  foo4 = {'a','2','c','4'}, L4;
struct  struct5  foo5 = {'1','b','3','d','5'}, L5;
struct  struct6  foo6 = {'a','2','c','4','e','6'}, L6;
struct  struct7  foo7 = {'1','b','3','d','5','f','7'}, L7;
struct  struct8  foo8 = {'a','2','c','4','e','6','g','8'}, L8;
struct  struct9  foo9 = {'1','b','3','d','5','f','7','h','9'}, L9;
struct struct10 foo10 = {'a','2','c','4','e','6','g','8','i','A'}, L10;
struct struct11 foo11 = {'1','b','3','d','5','f','7','h','9','j','B'}, L11;
struct struct12 foo12 = {'a','2','c','4','e','6','g','8','i','A','k','C'}, L12;
struct struct13 foo13 = {'1','b','3','d','5','f','7','h','9','j','B','l','D'}, L13;
struct struct14 foo14 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E'}, L14;
struct struct15 foo15 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F'}, L15;
struct struct16 foo16 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G'}, L16;
struct struct17 foo17 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F','p','H'}, L17;
struct struct18 foo18 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G','q','I'}, L18;

struct struct1  fun1()
{
  return foo1;  
}
struct struct2  fun2()
{
  return foo2;
}
struct struct3  fun3()
{
  return foo3;
}
struct struct4  fun4()
{
  return foo4;
}
struct struct5  fun5()
{
  return foo5;
}
struct struct6  fun6()
{
  return foo6;
}
struct struct7  fun7()
{
  return foo7;
}
struct struct8  fun8()
{
  return foo8;
}
struct struct9  fun9()
{
  return foo9;
}
struct struct10 fun10()
{
  return foo10; 
}
struct struct11 fun11()
{
  return foo11; 
}
struct struct12 fun12()
{
  return foo12; 
}
struct struct13 fun13()
{
  return foo13; 
}
struct struct14 fun14()
{
  return foo14; 
}
struct struct15 fun15()
{
  return foo15; 
}
struct struct16 fun16()
{
  return foo16; 
}
struct struct17 fun17()
{
  return foo17; 
}
struct struct18 fun18()
{
  return foo18; 
}

void Fun1(struct struct1 foo1)
{
  L1 = foo1;
}
void Fun2(struct struct2 foo2)
{
  L2 = foo2;
}
void Fun3(struct struct3 foo3)
{
  L3 = foo3;
}
void Fun4(struct struct4 foo4)
{
  L4 = foo4;
}
void Fun5(struct struct5 foo5)
{
  L5 = foo5;
}
void Fun6(struct struct6 foo6)
{
  L6 = foo6;
}
void Fun7(struct struct7 foo7)
{
  L7 = foo7;
}
void Fun8(struct struct8 foo8)
{
  L8 = foo8;
}
void Fun9(struct struct9 foo9)
{
  L9 = foo9;
}
void Fun10(struct struct10 foo10)
{
  L10 = foo10; 
}
void Fun11(struct struct11 foo11)
{
  L11 = foo11; 
}
void Fun12(struct struct12 foo12)
{
  L12 = foo12; 
}
void Fun13(struct struct13 foo13)
{
  L13 = foo13; 
}
void Fun14(struct struct14 foo14)
{
  L14 = foo14; 
}
void Fun15(struct struct15 foo15)
{
  L15 = foo15; 
}
void Fun16(struct struct16 foo16)
{
  L16 = foo16; 
}
void Fun17(struct struct17 foo17)
{
  L17 = foo17; 
}
void Fun18(struct struct18 foo18)
{
  L18 = foo18; 
}

void
zed ()
{

  L1.a = L2.a = L3.a = L4.a = L5.a = L6.a = L7.a = L8.a = L9.a = L10.a = L11.a = L12.a = L13.a = L14.a = L15.a = L16.a = L17.a = L18.a = 'Z';

  L2.b = L3.b = L4.b = L5.b = L6.b = L7.b = L8.b = L9.b = L10.b = L11.b = L12.b = L13.b = L14.b = L15.b = L16.b = L17.b = L18.b = 'Z';

  L3.c = L4.c = L5.c = L6.c = L7.c = L8.c = L9.c = L10.c = L11.c = L12.c = L13.c = L14.c = L15.c = L16.c = L17.c = L18.c = 'Z';

  L4.d = L5.d = L6.d = L7.d = L8.d = L9.d = L10.d = L11.d = L12.d = L13.d = L14.d = L15.d = L16.d = L17.d = L18.d = 'Z';

  L5.e = L6.e = L7.e = L8.e = L9.e = L10.e = L11.e = L12.e = L13.e = L14.e = L15.e = L16.e = L17.e = L18.e = 'Z';

  L6.f = L7.f = L8.f = L9.f = L10.f = L11.f = L12.f = L13.f = L14.f = L15.f = L16.f = L17.f = L18.f = 'Z';

  L7.g = L8.g = L9.g = L10.g = L11.g = L12.g = L13.g = L14.g = L15.g = L16.g = L17.g = L18.g = 'Z';

  L8.h = L9.h = L10.h = L11.h = L12.h = L13.h = L14.h = L15.h = L16.h = L17.h = L18.h = 'Z';

  L9.i = L10.i = L11.i = L12.i = L13.i = L14.i = L15.i = L16.i = L17.i = L18.i = 'Z';

  L10.j = L11.j = L12.j = L13.j = L14.j = L15.j = L16.j = L17.j = L18.j = 'Z';

  L11.k = L12.k = L13.k = L14.k = L15.k = L16.k = L17.k = L18.k = 'Z';

  L12.l = L13.l = L14.l = L15.l = L16.l = L17.l = L18.l = 'Z';

  L13.m = L14.m = L15.m = L16.m = L17.m = L18.m = 'Z';

  L14.n = L15.n = L16.n = L17.n = L18.n = 'Z';

  L15.o = L16.o = L17.o = L18.o = 'Z';

  L16.p = L17.p = L18.p = 'Z';

  L17.q = L18.q = 'Z';

  L18.r = 'Z';
}

static struct { char c; } chartest[256];

int main()
{
  int i;

  for (i = 0; i < 256; i++)
    chartest[i].c = i;
  chartest[0].c = 0;  /* chartest-done */

  Fun1(foo1);	
  Fun2(foo2);	
  Fun3(foo3);	
  Fun4(foo4);	
  Fun5(foo5);	
  Fun6(foo6);	
  Fun7(foo7);	
  Fun8(foo8);	
  Fun9(foo9);	
  Fun10(foo10);
  Fun11(foo11);
  Fun12(foo12);
  Fun13(foo13);
  Fun14(foo14);
  Fun15(foo15);
  Fun16(foo16);
  Fun17(foo17);
  Fun18(foo18);

  /* An (almost-)infinite loop that first clears all the variables and then
     calls each function.  This "hack" is to make testing random
     functions easier - "advance funN" is guaranteed to have always
     been preceded by a global variable clearing zed call.
     We don't let this run forever in case gdb crashes while testing,
     we don't want to be left eating all cpu on the user's system.  */

  for (i = 0; i < 1000000; ++i)
    {
      zed ();
      L1  = fun1();	
      L2  = fun2();	
      L3  = fun3();	
      L4  = fun4();	
      L5  = fun5();	
      L6  = fun6();	
      L7  = fun7();	
      L8  = fun8();	
      L9  = fun9();	
      L10 = fun10();
      L11 = fun11();
      L12 = fun12();
      L13 = fun13();
      L14 = fun14();
      L15 = fun15();
      L16 = fun16();
      L17 = fun17();
      L18 = fun18();
    }

  return 0;
}