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.mi/] [mi-var-child.c] - Blame information for rev 414

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

Line No. Rev Author Line
1 330 jeremybenn
/* Copyright 1999, 2004, 2005, 2007, 2008, 2009, 2010
2
Free Software Foundation, Inc.
3
 
4
   This file is part of GDB.
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3 of the License, or
9
   (at your option) any later version.
10
 
11
   This program is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   You should have received a copy of the GNU General Public License
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
 
19
#include <stdlib.h>
20
#include <string.h>
21
 
22
struct _simple_struct {
23
  int integer;
24
  unsigned int unsigned_integer;
25
  char character;
26
  signed char signed_character;
27
  char *char_ptr;
28
  int array_of_10[10];
29
};
30
 
31
typedef struct _simple_struct simpleton;
32
 
33
simpleton global_simple;
34
 
35
enum foo {
36
  bar = 1,
37
  baz
38
};
39
 
40
typedef enum foo efoo;
41
 
42
union named_union
43
{
44
  int integer;
45
  char *char_ptr;
46
};
47
 
48
typedef struct _struct_decl {
49
  int   integer;
50
  char  character;
51
  char *char_ptr;
52
  long  long_int;
53
  int  **int_ptr_ptr;
54
  long  long_array[12];
55
 
56
  void (*func_ptr) (void);
57
  struct _struct_decl (*func_ptr_struct) (int, char *, long);
58
  struct _struct_decl *(*func_ptr_ptr) (int, char *, long);
59
  union {
60
    int   a;
61
    char *b;
62
    long  c;
63
    enum foo d;
64
  } u1;
65
 
66
  struct {
67
    union {
68
      struct {
69
        int d;
70
        char e[10];
71
        int *(*func) (void);
72
        efoo foo;
73
      } u1s1;
74
 
75
      long f;
76
      struct {
77
        char array_ptr[2];
78
        int (*func) (int, char *);
79
      } u1s2;
80
    } u2;
81
 
82
    int g;
83
    char h;
84
    long i[10];
85
  } s2;
86
} weird_struct;
87
 
88
struct _struct_n_pointer {
89
  char ****char_ptr;
90
  long ****long_ptr;
91
  struct _struct_n_pointer *ptrs[3];
92
  struct _struct_n_pointer *next;
93
};
94
 
95
void do_locals_tests (void);
96
void do_block_tests (void);
97
void subroutine1 (int, long *);
98
void nothing (void);
99
void do_children_tests (void);
100
void do_special_tests (void);
101
void incr_a (char);
102
 
103
void incr_a (char a)
104
{
105
  int b;
106
  b = a;
107
}
108
 
109
void
110
do_locals_tests ()
111
{
112
  int linteger;
113
  int *lpinteger;
114
  char lcharacter;
115
  char *lpcharacter;
116
  long llong;
117
  long *lplong;
118
  float lfloat;
119
  float *lpfloat;
120
  double ldouble;
121
  double *lpdouble;
122
  struct _simple_struct lsimple;
123
  struct _simple_struct *lpsimple;
124
  void (*func) (void);
125
 
126
  /* Simple assignments */
127
  linteger = 1234;
128
  lpinteger = &linteger;
129
  lcharacter = 'a';
130
  lpcharacter = &lcharacter;
131
  llong = 2121L;
132
  lplong = &llong;
133
  lfloat = 2.1;
134
  lpfloat = &lfloat;
135
  ldouble = 2.718281828459045;
136
  lpdouble = &ldouble;
137
  lsimple.integer = 1234;
138
  lsimple.unsigned_integer = 255;
139
  lsimple.character = 'a';
140
  lsimple.signed_character = 21;
141
  lsimple.char_ptr = &lcharacter;
142
  lpsimple = &lsimple;
143
  func = nothing;
144
 
145
  /* Check pointers */
146
  linteger = 4321;
147
  lcharacter = 'b';
148
  llong = 1212L;
149
  lfloat = 1.2;
150
  ldouble = 5.498548281828172;
151
  lsimple.integer = 255;
152
  lsimple.unsigned_integer = 4321;
153
  lsimple.character = 'b';
154
  lsimple.signed_character = 0;
155
 
156
  subroutine1 (linteger, &llong);
157
}
158
 
159
void
160
nothing ()
161
{
162
}
163
 
164
void
165
subroutine1 (int i, long *l)
166
{
167
  global_simple.integer = i + 3;
168
  i = 212;
169
  *l = 12;
170
}
171
 
172
void
173
do_block_tests ()
174
{
175
  int cb = 12;
176
 
177
  {
178
    int foo;
179
    foo = 123;
180
    {
181
      int foo2;
182
      foo2 = 123;
183
      {
184
        int foo;
185
        foo = 321;
186
      }
187
      foo2 = 0;
188
    }
189
    foo = 0;
190
  }
191
 
192
  cb = 21;
193
}
194
 
195
void
196
do_children_tests (void)
197
{
198
  weird_struct *weird;
199
  struct _struct_n_pointer *psnp;
200
  struct _struct_n_pointer snp0, snp1, snp2;
201
  char a0[2] = {}, *a1, **a2, ***a3;
202
  char b0[2] = {}, *b1, **b2, ***b3;
203
  char c0[2] = {}, *c1, **c2, ***c3;
204
  long z0, *z1, **z2, ***z3;
205
  long y0, *y1, **y2, ***y3;
206
  long x0, *x1, **x2, ***x3;
207
  int *foo;
208
  int bar;
209
 
210
  /* Avoid pointing into NULL, as that is editable on some
211
     systems.  */
212
  int dummy;
213
  int *dummy_ptr = &dummy;
214
 
215
  struct _struct_decl struct_declarations = { 0, 0, NULL, 0, &dummy_ptr };
216
  weird = &struct_declarations;
217
 
218
  struct_declarations.integer = 123;
219
  weird->char_ptr = "hello";
220
  bar = 2121;
221
  foo = &bar;
222
  struct_declarations.int_ptr_ptr = &foo;
223
  weird->long_array[0] = 1234;
224
  struct_declarations.long_array[1] = 2345;
225
  weird->long_array[2] = 3456;
226
  struct_declarations.long_array[3] = 4567;
227
  weird->long_array[4] = 5678;
228
  struct_declarations.long_array[5] = 6789;
229
  weird->long_array[6] = 7890;
230
  struct_declarations.long_array[7] = 8901;
231
  weird->long_array[8] = 9012;
232
  struct_declarations.long_array[9] = 1234;
233
 
234
  weird->func_ptr = nothing;
235
  struct_declarations.long_array[10] = 3456;
236
  struct_declarations.long_array[11] = 5678;
237
 
238
  /* Struct/pointer/array tests */
239
  a0[0] = '0';
240
  a1 = a0;
241
  a2 = &a1;
242
  a3 = &a2;
243
  b0[0] = '1';
244
  b1 = b0;
245
  b2 = &b1;
246
  b3 = &b2;
247
  c0[1] = '2';
248
  c1 = c0;
249
  c2 = &c1;
250
  c3 = &c2;
251
  z0 = 0xdead + 0;
252
  z1 = &z0;
253
  z2 = &z1;
254
  z3 = &z2;
255
  y0 = 0xdead + 1;
256
  y1 = &y0;
257
  y2 = &y1;
258
  y3 = &y2;
259
  x0 = 0xdead + 2;
260
  x1 = &x0;
261
  x2 = &x1;
262
  x3 = &x2;
263
  snp0.char_ptr = &a3;
264
  snp0.long_ptr = &z3;
265
  snp0.ptrs[0] = &snp0;
266
  snp0.ptrs[1] = &snp1;
267
  snp0.ptrs[2] = &snp2;
268
  snp0.next = &snp1;
269
  snp1.char_ptr = &b3;
270
  snp1.long_ptr = &y3;
271
  snp1.ptrs[0] = &snp0;
272
  snp1.ptrs[1] = &snp1;
273
  snp1.ptrs[2] = &snp2;
274
  snp1.next = &snp2;
275
  snp2.char_ptr = &c3;
276
  snp2.long_ptr = &x3;
277
  snp2.ptrs[0] = &snp0;
278
  snp2.ptrs[1] = &snp1;
279
  snp2.ptrs[2] = &snp2;
280
  snp2.next = 0x0;
281
  psnp = &snp0;
282
  snp0.char_ptr = &b3;
283
  snp1.char_ptr = &c3;
284
  snp2.char_ptr = &a3;
285
  snp0.long_ptr = &y3;
286
  snp1.long_ptr = &x3;
287
  snp2.long_ptr = &z3;
288
}
289
 
290
void
291
do_special_tests (void)
292
{
293
  union named_union u;
294
  union {
295
    int a;
296
    char b;
297
    long c;
298
  } anonu;
299
  struct _simple_struct s;
300
  struct {
301
    int a;
302
    char b;
303
    long c;
304
  } anons;
305
  enum foo e;
306
  enum { A, B, C } anone;
307
  int array[21];
308
  int a;
309
 
310
  a = 1;
311
  incr_a(2);
312
}
313
 
314
struct very_simple_struct
315
{
316
  int a;
317
  int b;
318
};
319
 
320
int
321
do_child_deletion (void)
322
{
323
  /*: BEGIN: child_deletion :*/
324
  struct very_simple_struct s = {1, 2};
325
  /*:
326
    mi_create_varobj S s "create varobj for s"
327
    mi_list_varobj_children S {{S.a a 0 int} {S.b b 0 int}}     \
328
       "list children of S"
329
    mi_delete_varobj S.a "delete S.a"
330
    mi_delete_varobj S.b "delete S.b"
331
    mi_delete_varobj S "delete S"
332
    :*/
333
  return 99;
334
  /*: END: child_deletion :*/
335
}
336
 
337
int
338
main (int argc, char *argv [])
339
{
340
  do_locals_tests ();
341
  do_block_tests ();
342
  do_children_tests ();
343
  do_special_tests ();
344
  do_child_deletion ();
345
  exit (0);
346
}
347
 
348
 

powered by: WebSVN 2.1.0

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