OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.trace/] [collection.c] - Blame information for rev 330

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/*
2
 * Test program for trace collection
3
 */
4
 
5
/*
6
 * Typedefs
7
 */
8
 
9
typedef struct TEST_STRUCT {
10
  char   memberc;
11
  int    memberi;
12
  float  memberf;
13
  double memberd;
14
} test_struct;
15
 
16
typedef int test_array [4];
17
 
18
/*
19
 * Global variables to be collected
20
 */
21
 
22
char         globalc;
23
int          globali;
24
float        globalf;
25
double       globald;
26
test_struct  globalstruct;
27
test_struct *globalp;
28
int          globalarr[16];
29
 
30
/*
31
 * Additional globals used in arithmetic tests
32
 */
33
 
34
signed char  c0,  c1,  c2,  c3,  c4,  c5,  c6,  c7,
35
             c8,  c9,  c10, c11, c12, c13, c14, c15, cminus;
36
signed short s0,  s1,  s2,  s3,  s4,  s5,  s6,  s7,
37
             s8,  s9,  s10, s11, s12, s13, s14, s15, sminus;
38
signed long  l0,  l1,  l2,  l3,  l4,  l5,  l6,  l7,
39
             l8,  l9,  l10, l11, l12, l13, l14, l15, lminus;
40
 
41
 
42
/*
43
 * Test functions
44
 */
45
 
46
static void begin ()    /* called before anything else */
47
{
48
}
49
 
50
static void end ()      /* called after everything else */
51
{
52
}
53
 
54
/* Test collecting args. */
55
int args_test_func (argc, argi, argf, argd, argstruct, argarray)
56
     char   argc;
57
     int    argi;
58
     float  argf;
59
     double argd;
60
     test_struct argstruct;
61
     int argarray[4];
62
{
63
  int i;
64
 
65
  i =  (int) argc + argi + argf + argd + argstruct.memberi + argarray[1];
66
 
67
  return i;
68
}
69
 
70
/* Test collecting struct args. */
71
int argstruct_test_func (argstruct)
72
     test_struct argstruct;
73
{
74
  return (int) argstruct.memberc + argstruct.memberi +
75
                 argstruct.memberf + argstruct.memberd;
76
}
77
 
78
/* Test collecting array args. */
79
int argarray_test_func (argarray)
80
     int argarray[4];
81
{
82
  return (int) argarray[0] + argarray[1] + argarray[2] + argarray[3];
83
}
84
 
85
 
86
 
87
int local_test_func ()                  /* test collecting locals */
88
{
89
  char        locc  = 11;
90
  int         loci  = 12;
91
  float       locf  = 13.3;
92
  double      locd  = 14.4;
93
  test_struct locst;
94
  int         locar[4];
95
  int         i;
96
  struct localstruct {} locdefst;
97
 
98
  locst.memberc  = 15;
99
  locst.memberi  = 16;
100
  locst.memberf  = 17.7;
101
  locst.memberd  = 18.8;
102
  locar[0] = 121;
103
  locar[1] = 122;
104
  locar[2] = 123;
105
  locar[3] = 124;
106
 
107
  i = /* Set_Tracepoint_Here */
108
    (int) locc + loci + locf + locd + locst.memberi + locar[1];
109
 
110
  return i;
111
}
112
 
113
int reglocal_test_func ()               /* test collecting register locals */
114
{
115
  register char        locc = 11;
116
  register int         loci = 12;
117
  register float       locf = 13.3;
118
  register double      locd = 14.4;
119
  register test_struct locst;
120
  register int         locar[4];
121
  int                  i;
122
 
123
  locst.memberc  = 15;
124
  locst.memberi  = 16;
125
  locst.memberf  = 17.7;
126
  locst.memberd  = 18.8;
127
  locar[0] = 121;
128
  locar[1] = 122;
129
  locar[2] = 123;
130
  locar[3] = 124;
131
 
132
  i = /* Set_Tracepoint_Here */
133
    (int) locc + loci + locf + locd + locst.memberi + locar[1];
134
 
135
  return i;
136
}
137
 
138
int statlocal_test_func ()              /* test collecting static locals */
139
{
140
  static   char        locc;
141
  static   int         loci;
142
  static   float       locf;
143
  static   double      locd;
144
  static   test_struct locst;
145
  static   int         locar[4];
146
  int                  i;
147
 
148
  locc = 11;
149
  loci = 12;
150
  locf = 13.3;
151
  locd = 14.4;
152
  locst.memberc = 15;
153
  locst.memberi = 16;
154
  locst.memberf = 17.7;
155
  locst.memberd = 18.8;
156
  locar[0] = 121;
157
  locar[1] = 122;
158
  locar[2] = 123;
159
  locar[3] = 124;
160
 
161
  i = /* Set_Tracepoint_Here */
162
    (int) locc + loci + locf + locd + locst.memberi + locar[1];
163
 
164
  /* Set static locals back to zero so collected values are clearly special. */
165
  locc = 0;
166
  loci = 0;
167
  locf = 0;
168
  locd = 0;
169
  locst.memberc = 0;
170
  locst.memberi = 0;
171
  locst.memberf = 0;
172
  locst.memberd = 0;
173
  locar[0] = 0;
174
  locar[1] = 0;
175
  locar[2] = 0;
176
  locar[3] = 0;
177
 
178
  return i;
179
}
180
 
181
 
182
int globals_test_func ()
183
{
184
  int i = 0;
185
 
186
  i += globalc + globali + globalf + globald;
187
  i += globalstruct.memberc + globalstruct.memberi;
188
  i += globalstruct.memberf + globalstruct.memberd;
189
  i += globalarr[1];
190
 
191
  return i;     /* Set_Tracepoint_Here */
192
}
193
 
194
int
195
main (argc, argv, envp)
196
     int argc;
197
     char *argv[], **envp;
198
{
199
  int         i = 0;
200
  test_struct mystruct;
201
  int         myarray[4];
202
 
203
#ifdef usestubs
204
  set_debug_traps ();
205
  breakpoint ();
206
#endif
207
 
208
  begin ();
209
  /* Assign collectable values to global variables. */
210
  l0  = s0  = c0  = 0;     l1  = s1  = c1  = 1;
211
  l2  = s2  = c2  = 2;     l3  = s3  = c3  = 3;
212
  l4  = s4  = c4  = 4;     l5  = s5  = c5  = 5;
213
  l6  = s6  = c6  = 6;     l7  = s7  = c7  = 7;
214
  l8  = s8  = c8  = 8;     l9  = s9  = c9  = 9;
215
  l10 = s10 = c10 = 10;    l11 = s11 = c11 = 11;
216
  l12 = s12 = c12 = 12;    l13 = s13 = c13 = 13;
217
  l14 = s14 = c14 = 14;    l15 = s15 = c15 = 15;
218
  lminus = sminus = cminus = -2;
219
  globalc = 71;
220
  globali = 72;
221
  globalf = 73.3;
222
  globald = 74.4;
223
  globalstruct.memberc = 81;
224
  globalstruct.memberi = 82;
225
  globalstruct.memberf = 83.3;
226
  globalstruct.memberd = 84.4;
227
  globalp = &globalstruct;
228
 
229
  for (i = 0; i < 15; i++)
230
    globalarr[i] = i;
231
 
232
  mystruct.memberc = 101;
233
  mystruct.memberi = 102;
234
  mystruct.memberf = 103.3;
235
  mystruct.memberd = 104.4;
236
  myarray[0] = 111;
237
  myarray[1] = 112;
238
  myarray[2] = 113;
239
  myarray[3] = 114;
240
 
241
  /* Call test functions, so they can be traced and data collected.  */
242
  i = 0;
243
  i += args_test_func (1, 2, 3.3, 4.4, mystruct, myarray);
244
  i += argstruct_test_func (mystruct);
245
  i += argarray_test_func (myarray);
246
  i += local_test_func ();
247
  i += reglocal_test_func ();
248
  i += statlocal_test_func ();
249
  i += globals_test_func ();
250
 
251
  /* Values of globals at end of test should be different from
252
     values that they had when trace data was captured.  */
253
 
254
  l0  = s0  = c0  = 0;     l1  = s1  = c1  = 0;
255
  l2  = s2  = c2  = 0;     l3  = s3  = c3  = 0;
256
  l4  = s4  = c4  = 0;     l5  = s5  = c5  = 0;
257
  l6  = s6  = c6  = 0;     l7  = s7  = c7  = 0;
258
  l8  = s8  = c8  = 0;     l9  = s9  = c9  = 0;
259
  l10 = s10 = c10 = 0;     l11 = s11 = c11 = 0;
260
  l12 = s12 = c12 = 0;     l13 = s13 = c13 = 0;
261
  l14 = s14 = c14 = 0;     l15 = s15 = c15 = 0;
262
  lminus = sminus = cminus = 0;
263
 
264
  /* Set 'em back to zero, so that the collected values will be
265
     distinctly different from the "realtime" (end of test) values.  */
266
 
267
  globalc = 0;
268
  globali = 0;
269
  globalf = 0;
270
  globald = 0;
271
  globalstruct.memberc = 0;
272
  globalstruct.memberi = 0;
273
  globalstruct.memberf = 0;
274
  globalstruct.memberd = 0;
275
  globalp = 0;
276
  for (i = 0; i < 15; i++)
277
    globalarr[i] = 0;
278
 
279
  end ();
280
  return 0;
281
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.