OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-7.2/] [gdb-7.2-or32-1.0rc1/] [gdb/] [testsuite/] [gdb.python/] [py-prettyprint.c] - Blame information for rev 341

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/* This testcase is part of GDB, the GNU debugger.
2
 
3
   Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
4
 
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3 of the License, or
8
   (at your option) any later version.
9
 
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
 
18
#include <string.h>
19
 
20
struct s
21
{
22
  int a;
23
  int *b;
24
};
25
 
26
struct ss
27
{
28
  struct s a;
29
  struct s b;
30
};
31
 
32
struct arraystruct
33
{
34
  int y;
35
  struct s x[2];
36
};
37
 
38
struct ns {
39
  const char *null_str;
40
  int length;
41
};
42
 
43
struct lazystring {
44
  const char *lazy_str;
45
};
46
 
47
#ifdef __cplusplus
48
struct S : public s {
49
  int zs;
50
};
51
 
52
struct SS {
53
  int zss;
54
  S s;
55
};
56
 
57
struct SSS
58
{
59
  SSS (int x, const S& r);
60
  int a;
61
  const S &b;
62
};
63
SSS::SSS (int x, const S& r) : a(x), b(r) { }
64
 
65
class VirtualTest
66
{
67
 private:
68
  int value;
69
 
70
 public:
71
  VirtualTest ()
72
    {
73
      value = 1;
74
    }
75
};
76
 
77
class Vbase1 : public virtual VirtualTest { };
78
class Vbase2 : public virtual VirtualTest { };
79
class Vbase3 : public virtual VirtualTest { };
80
 
81
class Derived : public Vbase1, public Vbase2, public Vbase3
82
{
83
 private:
84
  int value;
85
 
86
 public:
87
  Derived ()
88
    {
89
      value = 2;
90
    }
91
};
92
 
93
#endif
94
 
95
struct substruct {
96
  int a;
97
  int b;
98
};
99
 
100
struct outerstruct {
101
  struct substruct s;
102
  int x;
103
};
104
 
105
struct outerstruct
106
substruct_test (void)
107
{
108
  struct outerstruct outer;
109
  outer.s.a = 0;
110
  outer.s.b = 0;
111
  outer.x = 0;
112
 
113
  outer.s.a = 3;                /* MI outer breakpoint here */
114
 
115
  return outer;
116
}
117
 
118
typedef struct string_repr
119
{
120
  struct whybother
121
  {
122
    const char *contents;
123
  } whybother;
124
} string;
125
 
126
/* This lets us avoid malloc.  */
127
int array[100];
128
int narray[10];
129
 
130
struct justchildren
131
{
132
  int len;
133
  int *elements;
134
};
135
 
136
typedef struct justchildren nostring_type;
137
 
138
struct container
139
{
140
  string name;
141
  int len;
142
  int *elements;
143
};
144
 
145
typedef struct container zzz_type;
146
 
147
string
148
make_string (const char *s)
149
{
150
  string result;
151
  result.whybother.contents = s;
152
  return result;
153
}
154
 
155
zzz_type
156
make_container (const char *s)
157
{
158
  zzz_type result;
159
 
160
  result.name = make_string (s);
161
  result.len = 0;
162
  result.elements = 0;
163
 
164
  return result;
165
}
166
 
167
void
168
add_item (zzz_type *c, int val)
169
{
170
  if (c->len == 0)
171
    c->elements = array;
172
  c->elements[c->len] = val;
173
  ++c->len;
174
}
175
 
176
void init_s(struct s *s, int a)
177
{
178
  s->a = a;
179
  s->b = &s->a;
180
}
181
 
182
void init_ss(struct ss *s, int a, int b)
183
{
184
  init_s(&s->a, a);
185
  init_s(&s->b, b);
186
}
187
 
188
void do_nothing(void)
189
{
190
  int c;
191
 
192
  c = 23;                       /* Another MI breakpoint */
193
}
194
 
195
struct nullstr
196
{
197
  char *s;
198
};
199
 
200
struct string_repr string_1 = { { "one" } };
201
struct string_repr string_2 = { { "two" } };
202
 
203
int
204
main ()
205
{
206
  struct ss  ss;
207
  struct ss  ssa[2];
208
  struct arraystruct arraystruct;
209
  string x = make_string ("this is x");
210
  zzz_type c = make_container ("container");
211
  zzz_type c2 = make_container ("container2");
212
  const struct string_repr cstring = { { "const string" } };
213
  /* Clearing by being `static' could invoke an other GDB C++ bug.  */
214
  struct nullstr nullstr;
215
  nostring_type nstype;
216
  nstype.elements = narray;
217
  nstype.len = 0;
218
 
219
  init_ss(&ss, 1, 2);
220
  init_ss(ssa+0, 3, 4);
221
  init_ss(ssa+1, 5, 6);
222
  memset (&nullstr, 0, sizeof nullstr);
223
 
224
  arraystruct.y = 7;
225
  init_s (&arraystruct.x[0], 23);
226
  init_s (&arraystruct.x[1], 24);
227
 
228
  struct ns  ns;
229
  ns.null_str = "embedded\0null\0string";
230
  ns.length = 20;
231
 
232
  struct lazystring estring;
233
  estring.lazy_str = "embedded x\201\202\203\204" ;
234
 
235
#ifdef __cplusplus
236
  S cps;
237
 
238
  cps.zs = 7;
239
  init_s(&cps, 8);
240
 
241
  SS cpss;
242
  cpss.zss = 9;
243
  init_s(&cpss.s, 10);
244
 
245
  SS cpssa[2];
246
  cpssa[0].zss = 11;
247
  init_s(&cpssa[0].s, 12);
248
  cpssa[1].zss = 13;
249
  init_s(&cpssa[1].s, 14);
250
 
251
  SSS sss(15, cps);
252
 
253
  SSS& ref (sss);
254
 
255
  Derived derived;
256
 
257
#endif
258
 
259
  add_item (&c, 23);            /* MI breakpoint here */
260
  add_item (&c, 72);
261
 
262
#ifdef MI
263
  add_item (&c, 1011);
264
  c.elements[0] = 1023;
265
  c.elements[0] = 2323;
266
 
267
  add_item (&c2, 2222);
268
  add_item (&c2, 3333);
269
 
270
  substruct_test ();
271
  do_nothing ();
272
#endif
273
 
274
  nstype.elements[0] = 7;
275
  nstype.elements[1] = 42;
276
  nstype.len = 2;
277
 
278
  return 0;      /* break to inspect struct and union */
279
}

powered by: WebSVN 2.1.0

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