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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.python/] [py-prettyprint.c] - Blame information for rev 833

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

Line No. Rev Author Line
1 227 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 ns {
33
  const char *null_str;
34
  int length;
35
};
36
 
37
struct lazystring {
38
  const char *lazy_str;
39
};
40
 
41
#ifdef __cplusplus
42
struct S : public s {
43
  int zs;
44
};
45
 
46
struct SS {
47
  int zss;
48
  S s;
49
};
50
 
51
struct SSS
52
{
53
  SSS (int x, const S& r);
54
  int a;
55
  const S &b;
56
};
57
SSS::SSS (int x, const S& r) : a(x), b(r) { }
58
 
59
class VirtualTest
60
{
61
 private:
62
  int value;
63
 
64
 public:
65
  VirtualTest ()
66
    {
67
      value = 1;
68
    }
69
};
70
 
71
class Vbase1 : public virtual VirtualTest { };
72
class Vbase2 : public virtual VirtualTest { };
73
class Vbase3 : public virtual VirtualTest { };
74
 
75
class Derived : public Vbase1, public Vbase2, public Vbase3
76
{
77
 private:
78
  int value;
79
 
80
 public:
81
  Derived ()
82
    {
83
      value = 2;
84
    }
85
};
86
 
87
#endif
88
 
89
struct substruct {
90
  int a;
91
  int b;
92
};
93
 
94
struct outerstruct {
95
  struct substruct s;
96
  int x;
97
};
98
 
99
struct outerstruct
100
substruct_test (void)
101
{
102
  struct outerstruct outer;
103
  outer.s.a = 0;
104
  outer.s.b = 0;
105
  outer.x = 0;
106
 
107
  outer.s.a = 3;                /* MI outer breakpoint here */
108
 
109
  return outer;
110
}
111
 
112
typedef struct string_repr
113
{
114
  struct whybother
115
  {
116
    const char *contents;
117
  } whybother;
118
} string;
119
 
120
/* This lets us avoid malloc.  */
121
int array[100];
122
 
123
struct container
124
{
125
  string name;
126
  int len;
127
  int *elements;
128
};
129
 
130
typedef struct container zzz_type;
131
 
132
string
133
make_string (const char *s)
134
{
135
  string result;
136
  result.whybother.contents = s;
137
  return result;
138
}
139
 
140
zzz_type
141
make_container (const char *s)
142
{
143
  zzz_type result;
144
 
145
  result.name = make_string (s);
146
  result.len = 0;
147
  result.elements = 0;
148
 
149
  return result;
150
}
151
 
152
void
153
add_item (zzz_type *c, int val)
154
{
155
  if (c->len == 0)
156
    c->elements = array;
157
  c->elements[c->len] = val;
158
  ++c->len;
159
}
160
 
161
void init_s(struct s *s, int a)
162
{
163
  s->a = a;
164
  s->b = &s->a;
165
}
166
 
167
void init_ss(struct ss *s, int a, int b)
168
{
169
  init_s(&s->a, a);
170
  init_s(&s->b, b);
171
}
172
 
173
void do_nothing(void)
174
{
175
  int c;
176
 
177
  c = 23;                       /* Another MI breakpoint */
178
}
179
 
180
struct nullstr
181
{
182
  char *s;
183
};
184
 
185
struct string_repr string_1 = { { "one" } };
186
struct string_repr string_2 = { { "two" } };
187
 
188
int
189
main ()
190
{
191
  struct ss  ss;
192
  struct ss  ssa[2];
193
  string x = make_string ("this is x");
194
  zzz_type c = make_container ("container");
195
  zzz_type c2 = make_container ("container2");
196
  const struct string_repr cstring = { { "const string" } };
197
  /* Clearing by being `static' could invoke an other GDB C++ bug.  */
198
  struct nullstr nullstr;
199
 
200
 
201
  init_ss(&ss, 1, 2);
202
  init_ss(ssa+0, 3, 4);
203
  init_ss(ssa+1, 5, 6);
204
  memset (&nullstr, 0, sizeof nullstr);
205
 
206
  struct ns  ns;
207
  ns.null_str = "embedded\0null\0string";
208
  ns.length = 20;
209
 
210
  struct lazystring estring;
211
  estring.lazy_str = "embedded x\201\202\203\204" ;
212
 
213
#ifdef __cplusplus
214
  S cps;
215
 
216
  cps.zs = 7;
217
  init_s(&cps, 8);
218
 
219
  SS cpss;
220
  cpss.zss = 9;
221
  init_s(&cpss.s, 10);
222
 
223
  SS cpssa[2];
224
  cpssa[0].zss = 11;
225
  init_s(&cpssa[0].s, 12);
226
  cpssa[1].zss = 13;
227
  init_s(&cpssa[1].s, 14);
228
 
229
  SSS sss(15, cps);
230
 
231
  SSS& ref (sss);
232
 
233
  Derived derived;
234
 
235
#endif
236
 
237
  add_item (&c, 23);            /* MI breakpoint here */
238
  add_item (&c, 72);
239
 
240
#ifdef MI
241
  add_item (&c, 1011);
242
  c.elements[0] = 1023;
243
  c.elements[0] = 2323;
244
 
245
  add_item (&c2, 2222);
246
  add_item (&c2, 3333);
247
 
248
  substruct_test ();
249
  do_nothing ();
250
#endif
251
 
252
  return 0;      /* break to inspect struct and union */
253
}

powered by: WebSVN 2.1.0

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