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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.trace/] [collection.c] - Blame information for rev 106

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/*
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
 
97
  locst.memberc  = 15;
98
  locst.memberi  = 16;
99
  locst.memberf  = 17.7;
100
  locst.memberd  = 18.8;
101
  locar[0] = 121;
102
  locar[1] = 122;
103
  locar[2] = 123;
104
  locar[3] = 124;
105
 
106
  i = /* Set_Tracepoint_Here */
107
    (int) locc + loci + locf + locd + locst.memberi + locar[1];
108
 
109
  return i;
110
}
111
 
112
int reglocal_test_func ()               /* test collecting register locals */
113
{
114
  register char        locc = 11;
115
  register int         loci = 12;
116
  register float       locf = 13.3;
117
  register double      locd = 14.4;
118
  register test_struct locst;
119
  register int         locar[4];
120
  int                  i;
121
 
122
  locst.memberc  = 15;
123
  locst.memberi  = 16;
124
  locst.memberf  = 17.7;
125
  locst.memberd  = 18.8;
126
  locar[0] = 121;
127
  locar[1] = 122;
128
  locar[2] = 123;
129
  locar[3] = 124;
130
 
131
  i = /* Set_Tracepoint_Here */
132
    (int) locc + loci + locf + locd + locst.memberi + locar[1];
133
 
134
  return i;
135
}
136
 
137
int statlocal_test_func ()              /* test collecting static locals */
138
{
139
  static   char        locc;
140
  static   int         loci;
141
  static   float       locf;
142
  static   double      locd;
143
  static   test_struct locst;
144
  static   int         locar[4];
145
  int                  i;
146
 
147
  locc = 11;
148
  loci = 12;
149
  locf = 13.3;
150
  locd = 14.4;
151
  locst.memberc = 15;
152
  locst.memberi = 16;
153
  locst.memberf = 17.7;
154
  locst.memberd = 18.8;
155
  locar[0] = 121;
156
  locar[1] = 122;
157
  locar[2] = 123;
158
  locar[3] = 124;
159
 
160
  i = /* Set_Tracepoint_Here */
161
    (int) locc + loci + locf + locd + locst.memberi + locar[1];
162
 
163
  /* Set static locals back to zero so collected values are clearly special. */
164
  locc = 0;
165
  loci = 0;
166
  locf = 0;
167
  locd = 0;
168
  locst.memberc = 0;
169
  locst.memberi = 0;
170
  locst.memberf = 0;
171
  locst.memberd = 0;
172
  locar[0] = 0;
173
  locar[1] = 0;
174
  locar[2] = 0;
175
  locar[3] = 0;
176
 
177
  return i;
178
}
179
 
180
 
181
int globals_test_func ()
182
{
183
  int i = 0;
184
 
185
  i += globalc + globali + globalf + globald;
186
  i += globalstruct.memberc + globalstruct.memberi;
187
  i += globalstruct.memberf + globalstruct.memberd;
188
  i += globalarr[1];
189
 
190
  return i;     /* Set_Tracepoint_Here */
191
}
192
 
193
int
194
main (argc, argv, envp)
195
     int argc;
196
     char *argv[], **envp;
197
{
198
  int         i = 0;
199
  test_struct mystruct;
200
  int         myarray[4];
201
 
202
#ifdef usestubs
203
  set_debug_traps ();
204
  breakpoint ();
205
#endif
206
 
207
  begin ();
208
  /* Assign collectable values to global variables. */
209
  l0  = s0  = c0  = 0;     l1  = s1  = c1  = 1;
210
  l2  = s2  = c2  = 2;     l3  = s3  = c3  = 3;
211
  l4  = s4  = c4  = 4;     l5  = s5  = c5  = 5;
212
  l6  = s6  = c6  = 6;     l7  = s7  = c7  = 7;
213
  l8  = s8  = c8  = 8;     l9  = s9  = c9  = 9;
214
  l10 = s10 = c10 = 10;    l11 = s11 = c11 = 11;
215
  l12 = s12 = c12 = 12;    l13 = s13 = c13 = 13;
216
  l14 = s14 = c14 = 14;    l15 = s15 = c15 = 15;
217
  lminus = sminus = cminus = -2;
218
  globalc = 71;
219
  globali = 72;
220
  globalf = 73.3;
221
  globald = 74.4;
222
  globalstruct.memberc = 81;
223
  globalstruct.memberi = 82;
224
  globalstruct.memberf = 83.3;
225
  globalstruct.memberd = 84.4;
226
  globalp = &globalstruct;
227
 
228
  for (i = 0; i < 15; i++)
229
    globalarr[i] = i;
230
 
231
  mystruct.memberc = 101;
232
  mystruct.memberi = 102;
233
  mystruct.memberf = 103.3;
234
  mystruct.memberd = 104.4;
235
  myarray[0] = 111;
236
  myarray[1] = 112;
237
  myarray[2] = 113;
238
  myarray[3] = 114;
239
 
240
  /* Call test functions, so they can be traced and data collected.  */
241
  i = 0;
242
  i += args_test_func (1, 2, 3.3, 4.4, mystruct, myarray);
243
  i += argstruct_test_func (mystruct);
244
  i += argarray_test_func (myarray);
245
  i += local_test_func ();
246
  i += reglocal_test_func ();
247
  i += statlocal_test_func ();
248
  i += globals_test_func ();
249
 
250
  /* Values of globals at end of test should be different from
251
     values that they had when trace data was captured.  */
252
 
253
  l0  = s0  = c0  = 0;     l1  = s1  = c1  = 0;
254
  l2  = s2  = c2  = 0;     l3  = s3  = c3  = 0;
255
  l4  = s4  = c4  = 0;     l5  = s5  = c5  = 0;
256
  l6  = s6  = c6  = 0;     l7  = s7  = c7  = 0;
257
  l8  = s8  = c8  = 0;     l9  = s9  = c9  = 0;
258
  l10 = s10 = c10 = 0;     l11 = s11 = c11 = 0;
259
  l12 = s12 = c12 = 0;     l13 = s13 = c13 = 0;
260
  l14 = s14 = c14 = 0;     l15 = s15 = c15 = 0;
261
  lminus = sminus = cminus = 0;
262
 
263
  /* Set 'em back to zero, so that the collected values will be
264
     distinctly different from the "realtime" (end of test) values.  */
265
 
266
  globalc = 0;
267
  globali = 0;
268
  globalf = 0;
269
  globald = 0;
270
  globalstruct.memberc = 0;
271
  globalstruct.memberi = 0;
272
  globalstruct.memberf = 0;
273
  globalstruct.memberd = 0;
274
  globalp = 0;
275
  for (i = 0; i < 15; i++)
276
    globalarr[i] = 0;
277
 
278
  end ();
279
  return 0;
280
}

powered by: WebSVN 2.1.0

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