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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.mi/] [var-cmd.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
struct _simple_struct {
2
  int integer;
3
  unsigned int unsigned_integer;
4
  char character;
5
  signed char signed_character;
6
  char *char_ptr;
7
  int array_of_10[10];
8
};
9
 
10
typedef struct _simple_struct simpleton;
11
 
12
simpleton global_simple;
13
 
14
enum foo {
15
  bar = 1,
16
  baz
17
};
18
 
19
typedef enum foo efoo;
20
 
21
union named_union
22
{
23
  int integer;
24
  char *char_ptr;
25
};
26
 
27
typedef struct _struct_decl {
28
  int   integer;
29
  char  character;
30
  char *char_ptr;
31
  long  long_int;
32
  int  **int_ptr_ptr;
33
  long  long_array[10];
34
 
35
  void (*func_ptr) (void);
36
  struct _struct_decl (*func_ptr_struct) (int, char *, long);
37
  struct _struct_decl *(*func_ptr_ptr) (int, char *, long);
38
  union {
39
    int   a;
40
    char *b;
41
    long  c;
42
    enum foo d;
43
  } u1;
44
 
45
  struct {
46
    union {
47
      struct {
48
        int d;
49
        char e[10];
50
        int *(*func) (void);
51
        efoo foo;
52
      } u1s1;
53
 
54
      long f;
55
      struct {
56
        char array_ptr[2];
57
        int (*func) (int, char *);
58
      } u1s2;
59
    } u2;
60
 
61
    int g;
62
    char h;
63
    long i[10];
64
  } s2;
65
} weird_struct;
66
 
67
struct _struct_n_pointer {
68
  char ****char_ptr;
69
  long ****long_ptr;
70
  struct _struct_n_pointer *ptrs[3];
71
  struct _struct_n_pointer *next;
72
};
73
 
74
void do_locals_tests (void);
75
void do_block_tests (void);
76
void subroutine1 (int, long *);
77
void nothing (void);
78
void do_children_tests (void);
79
void do_special_tests (void);
80
void incr_a (char);
81
 
82
void incr_a (char a)
83
{
84
  int b;
85
  b = a;
86
}
87
 
88
void
89
do_locals_tests ()
90
{
91
  int linteger;
92
  int *lpinteger;
93
  char lcharacter;
94
  char *lpcharacter;
95
  long llong;
96
  long *lplong;
97
  float lfloat;
98
  float *lpfloat;
99
  double ldouble;
100
  double *lpdouble;
101
  struct _simple_struct lsimple;
102
  struct _simple_struct *lpsimple;
103
  void (*func) (void);
104
 
105
  /* Simple assignments */
106
  linteger = 1234;
107
  lpinteger = &linteger;
108
  lcharacter = 'a';
109
  lpcharacter = &lcharacter;
110
  llong = 2121L;
111
  lplong = &llong;
112
  lfloat = 2.1;
113
  lpfloat = &lfloat;
114
  ldouble = 2.718281828459045;
115
  lpdouble = &ldouble;
116
  lsimple.integer = 1234;
117
  lsimple.unsigned_integer = 255;
118
  lsimple.character = 'a';
119
  lsimple.signed_character = 21;
120
  lsimple.char_ptr = &lcharacter;
121
  lpsimple = &lsimple;
122
  func = nothing;
123
 
124
  /* Check pointers */
125
  linteger = 4321;
126
  lcharacter = 'b';
127
  llong = 1212L;
128
  lfloat = 1.2;
129
  ldouble = 5.498548281828172;
130
  lsimple.integer = 255;
131
  lsimple.unsigned_integer = 4321;
132
  lsimple.character = 'b';
133
  lsimple.signed_character = 0;
134
 
135
  subroutine1 (linteger, &llong);
136
}
137
 
138
void
139
nothing ()
140
{
141
}
142
 
143
void
144
subroutine1 (int i, long *l)
145
{
146
  global_simple.integer = i + 3;
147
  i = 212;
148
  *l = 12;
149
}
150
 
151
void
152
do_block_tests ()
153
{
154
  int cb = 12;
155
 
156
  {
157
    int foo;
158
    foo = 123;
159
    {
160
      int foo2;
161
      foo2 = 123;
162
      {
163
        int foo;
164
        foo = 321;
165
      }
166
      foo2 = 0;
167
    }
168
    foo = 0;
169
  }
170
 
171
  cb = 21;
172
}
173
 
174
void
175
do_children_tests (void)
176
{
177
  weird_struct *weird;
178
  struct _struct_n_pointer *psnp;
179
  struct _struct_n_pointer snp0, snp1, snp2;
180
  char a0, *a1, **a2, ***a3;
181
  char b0, *b1, **b2, ***b3;
182
  char c0, *c1, **c2, ***c3;
183
  long z0, *z1, **z2, ***z3;
184
  long y0, *y1, **y2, ***y3;
185
  long x0, *x1, **x2, ***x3;
186
  int *foo;
187
  int bar;
188
 
189
  struct _struct_decl struct_declarations;
190
  weird = &struct_declarations;
191
 
192
  struct_declarations.integer = 123;
193
  weird->char_ptr = "hello";
194
  bar = 2121;
195
  foo = &bar;
196
  struct_declarations.int_ptr_ptr = &foo;
197
  weird->long_array[0] = 1234;
198
  struct_declarations.long_array[1] = 2345;
199
  weird->long_array[2] = 3456;
200
  struct_declarations.long_array[3] = 4567;
201
  weird->long_array[4] = 5678;
202
  struct_declarations.long_array[5] = 6789;
203
  weird->long_array[6] = 7890;
204
  struct_declarations.long_array[7] = 8901;
205
  weird->long_array[8] = 9012;
206
  struct_declarations.long_array[9] = 1234;
207
 
208
  weird->func_ptr = nothing;
209
 
210
  /* Struct/pointer/array tests */
211
  a0 = '0';
212
  a1 = &a0;
213
  a2 = &a1;
214
  a3 = &a2;
215
  b0 = '1';
216
  b1 = &b0;
217
  b2 = &b1;
218
  b3 = &b2;
219
  c0 = '2';
220
  c1 = &c0;
221
  c2 = &c1;
222
  c3 = &c2;
223
  z0 = 0xdead + 0;
224
  z1 = &z0;
225
  z2 = &z1;
226
  z3 = &z2;
227
  y0 = 0xdead + 1;
228
  y1 = &y0;
229
  y2 = &y1;
230
  y3 = &y2;
231
  x0 = 0xdead + 2;
232
  x1 = &x0;
233
  x2 = &x1;
234
  x3 = &x2;
235
  snp0.char_ptr = &a3;
236
  snp0.long_ptr = &z3;
237
  snp0.ptrs[0] = &snp0;
238
  snp0.ptrs[1] = &snp1;
239
  snp0.ptrs[2] = &snp2;
240
  snp0.next = &snp1;
241
  snp1.char_ptr = &b3;
242
  snp1.long_ptr = &y3;
243
  snp1.ptrs[0] = &snp0;
244
  snp1.ptrs[1] = &snp1;
245
  snp1.ptrs[2] = &snp2;
246
  snp1.next = &snp2;
247
  snp2.char_ptr = &c3;
248
  snp2.long_ptr = &x3;
249
  snp2.ptrs[0] = &snp0;
250
  snp2.ptrs[1] = &snp1;
251
  snp2.ptrs[2] = &snp2;
252
  snp2.next = 0x0;
253
  psnp = &snp0;
254
  snp0.char_ptr = &b3;
255
  snp1.char_ptr = &c3;
256
  snp2.char_ptr = &a3;
257
  snp0.long_ptr = &y3;
258
  snp1.long_ptr = &x3;
259
  snp2.long_ptr = &z3;
260
}
261
 
262
void
263
do_special_tests (void)
264
{
265
  union named_union u;
266
  union {
267
    int a;
268
    char b;
269
    long c;
270
  } anonu;
271
  struct _simple_struct s;
272
  struct {
273
    int a;
274
    char b;
275
    long c;
276
  } anons;
277
  enum foo e;
278
  enum { A, B, C } anone;
279
  int array[21];
280
  int a;
281
 
282
  a = 1;
283
  incr_a(2);
284
}
285
 
286
int
287
main (int argc, char *argv [])
288
{
289
  do_locals_tests ();
290
  do_block_tests ();
291
  do_children_tests ();
292
  do_special_tests ();
293
  exit (0);
294
}
295
 
296
 

powered by: WebSVN 2.1.0

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