1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008-2023 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/>. */
51 struct children_as_list
{
67 SSS (int x
, const S
& r
);
71 SSS::SSS (int x
, const S
& r
) : a(x
), b(r
) { }
85 class Vbase1
: public virtual VirtualTest
{ };
86 class Vbase2
: public virtual VirtualTest
{ };
87 class Vbase3
: public virtual VirtualTest
{ };
89 class Derived
: public Vbase1
, public Vbase2
, public Vbase3
106 Fake (const int name
= 0):
124 substruct_test (void)
126 struct outerstruct outer
;
131 outer
.s
.a
= 3; /* MI outer breakpoint here */
136 typedef struct string_repr
140 const char *contents
;
144 /* This lets us avoid malloc. */
154 typedef struct justchildren nostring_type
;
168 typedef struct container zzz_type
;
171 make_string (const char *s
)
174 result
.whybother
.contents
= s
;
179 make_container (const char *s
)
183 result
.name
= make_string (s
);
191 add_item (zzz_type
*c
, int val
)
195 c
->elements
[c
->len
] = val
;
200 set_item(zzz_type
*c
, int i
, int val
)
203 c
->elements
[i
] = val
;
206 void init_s(struct s
*s
, int a
)
212 void init_ss(struct ss
*s
, int a
, int b
)
218 void do_nothing(void)
222 c
= 23; /* Another MI breakpoint */
230 struct string_repr string_1
= { { "one" } };
231 struct string_repr string_2
= { { "two" } };
233 static int __attribute__ ((used
))
234 eval_func (int p1
, int p2
, int p3
, int p4
, int p5
, int p6
, int p7
, int p8
)
242 struct eval_type_s
{ int x
; } eval1
= { 1 }, eval2
= { 2 }, eval3
= { 3 },
243 eval4
= { 4 }, eval5
= { 5 }, eval6
= { 6 },
244 eval7
= { 7 }, eval8
= { 8 }, eval9
= { 9 };
246 eval1
.x
++; /* eval-break */
252 zzz_type c
= make_container ("bug_14741");
254 set_item(&c
, 0, 42); /* breakpoint bug 14741 */
263 struct arraystruct arraystruct
;
264 string x
= make_string ("this is x");
265 zzz_type c
= make_container ("container");
266 zzz_type c2
= make_container ("container2");
267 const struct string_repr cstring
= { { "const string" } };
268 /* Clearing by being `static' could invoke an other GDB C++ bug. */
269 struct nullstr nullstr
;
270 nostring_type nstype
, nstype2
;
271 struct memory_error me
;
273 struct lazystring estring
, estring2
;
274 struct hint_error hint_error
;
275 struct children_as_list children_as_list
;
277 nstype
.elements
= narray
;
283 init_ss(ssa
+0, 3, 4);
284 init_ss(ssa
+1, 5, 6);
285 memset (&nullstr
, 0, sizeof nullstr
);
288 init_s (&arraystruct
.x
[0], 23);
289 init_s (&arraystruct
.x
[1], 24);
291 ns
.null_str
= "embedded\0null\0string";
294 /* Make a "corrupted" string. */
298 estring
.lazy_str
= "embedded x\201\202\203\204" ;
300 /* Incomplete UTF-8, but ok Latin-1. */
301 estring2
.lazy_str
= "embedded x\302";
315 init_s(&cpssa
[0].s
, 12);
317 init_s(&cpssa
[1].s
, 14);
328 add_item (&c
, 23); /* MI breakpoint here */
333 c
.elements
[0] = 1023;
334 c
.elements
[0] = 2323;
336 add_item (&c2
, 2222);
337 add_item (&c2
, 3333);
343 nstype
.elements
[0] = 7;
344 nstype
.elements
[1] = 42;
351 bug_14741(); /* break to inspect struct and union */