1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
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.
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.
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/>. */
63 SSS (int x
, const S
& r
);
67 SSS::SSS (int x
, const S
& r
) : a(x
), b(r
) { }
81 class Vbase1
: public virtual VirtualTest
{ };
82 class Vbase2
: public virtual VirtualTest
{ };
83 class Vbase3
: public virtual VirtualTest
{ };
85 class Derived
: public Vbase1
, public Vbase2
, public Vbase3
102 Fake (const int name
= 0):
120 substruct_test (void)
122 struct outerstruct outer
;
127 outer
.s
.a
= 3; /* MI outer breakpoint here */
132 typedef struct string_repr
136 const char *contents
;
140 /* This lets us avoid malloc. */
150 typedef struct justchildren nostring_type
;
164 typedef struct container zzz_type
;
167 make_string (const char *s
)
170 result
.whybother
.contents
= s
;
175 make_container (const char *s
)
179 result
.name
= make_string (s
);
187 add_item (zzz_type
*c
, int val
)
191 c
->elements
[c
->len
] = val
;
195 void init_s(struct s
*s
, int a
)
201 void init_ss(struct ss
*s
, int a
, int b
)
207 void do_nothing(void)
211 c
= 23; /* Another MI breakpoint */
219 struct string_repr string_1
= { { "one" } };
220 struct string_repr string_2
= { { "two" } };
227 struct arraystruct arraystruct
;
228 string x
= make_string ("this is x");
229 zzz_type c
= make_container ("container");
230 zzz_type c2
= make_container ("container2");
231 const struct string_repr cstring
= { { "const string" } };
232 /* Clearing by being `static' could invoke an other GDB C++ bug. */
233 struct nullstr nullstr
;
234 nostring_type nstype
, nstype2
;
235 struct memory_error me
;
237 struct lazystring estring
, estring2
;
238 struct hint_error hint_error
;
240 nstype
.elements
= narray
;
246 init_ss(ssa
+0, 3, 4);
247 init_ss(ssa
+1, 5, 6);
248 memset (&nullstr
, 0, sizeof nullstr
);
251 init_s (&arraystruct
.x
[0], 23);
252 init_s (&arraystruct
.x
[1], 24);
254 ns
.null_str
= "embedded\0null\0string";
257 /* Make a "corrupted" string. */
261 estring
.lazy_str
= "embedded x\201\202\203\204" ;
263 /* Incomplete UTF-8, but ok Latin-1. */
264 estring2
.lazy_str
= "embedded x\302";
278 init_s(&cpssa
[0].s
, 12);
280 init_s(&cpssa
[1].s
, 14);
291 add_item (&c
, 23); /* MI breakpoint here */
296 c
.elements
[0] = 1023;
297 c
.elements
[0] = 2323;
299 add_item (&c2
, 2222);
300 add_item (&c2
, 3333);
306 nstype
.elements
[0] = 7;
307 nstype
.elements
[1] = 42;
312 return 0; /* break to inspect struct and union */