1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008-2024 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/>. */
45 /* If -1, don't pass length to gdb.lazy_string(). */
53 struct children_as_list
{
69 SSS (int x
, const S
& r
);
73 SSS::SSS (int x
, const S
& r
) : a(x
), b(r
) { }
87 class Vbase1
: public virtual VirtualTest
{ };
88 class Vbase2
: public virtual VirtualTest
{ };
89 class Vbase3
: public virtual VirtualTest
{ };
91 class Derived
: public Vbase1
, public Vbase2
, public Vbase3
108 Fake (const int name
= 0):
114 struct has_static_member
119 s
has_static_member::global
;
123 struct to_string_returns_value_inner
128 struct to_string_returns_value_wrapper
130 struct to_string_returns_value_inner inner
;
144 substruct_test (void)
146 struct outerstruct outer
;
151 outer
.s
.a
= 3; /* MI outer breakpoint here */
156 typedef struct string_repr
160 const char *contents
;
164 /* This lets us avoid malloc. */
174 typedef struct justchildren nostring_type
;
190 typedef struct container zzz_type
;
193 make_string (const char *s
)
196 result
.whybother
.contents
= s
;
201 make_container (const char *s
)
205 result
.name
= make_string (s
);
209 result
.is_array_p
= 0;
215 add_item (zzz_type
*c
, int val
)
219 c
->elements
[c
->len
] = val
;
224 set_item(zzz_type
*c
, int i
, int val
)
227 c
->elements
[i
] = val
;
230 void init_s(struct s
*s
, int a
)
236 void init_ss(struct ss
*s
, int a
, int b
)
242 void do_nothing(void)
246 c
= 23; /* Another MI breakpoint */
254 struct string_repr string_1
= { { "one" } };
255 struct string_repr string_2
= { { "two" } };
258 eval_func (int p1
, int p2
, int p3
, int p4
, int p5
, int p6
, int p7
, int p8
)
266 struct eval_type_s
{ int x
; } eval1
= { 1 }, eval2
= { 2 }, eval3
= { 3 },
267 eval4
= { 4 }, eval5
= { 5 }, eval6
= { 6 },
268 eval7
= { 7 }, eval8
= { 8 }, eval9
= { 9 };
270 eval1
.x
++; /* eval-break */
276 zzz_type c
= make_container ("bug_14741");
278 set_item(&c
, 0, 42); /* breakpoint bug 14741 */
282 /* Some typedefs/variables for checking that GDB doesn't lose typedefs
283 when looking for a printer. */
284 typedef int int_type
;
285 typedef int_type int_type2
;
286 typedef int_type int_type3
;
289 int_type an_int_type
= 1;
290 int_type2 an_int_type2
= 2;
291 int_type3 an_int_type3
= 3;
298 struct arraystruct arraystruct
;
299 string x
= make_string ("this is x");
300 zzz_type c
= make_container ("container");
301 zzz_type c2
= make_container ("container2");
302 const struct string_repr cstring
= { { "const string" } };
303 /* Clearing by being `static' could invoke an other GDB C++ bug. */
304 struct nullstr nullstr
;
305 nostring_type nstype
, nstype2
;
306 struct memory_error me
;
308 struct lazystring estring
, estring2
, estring3
;
309 struct hint_error hint_error
;
310 struct children_as_list children_as_list
;
311 struct to_string_returns_value_wrapper tsrvw
= { { 1989 } };
313 nstype
.elements
= narray
;
319 init_ss(ssa
+0, 3, 4);
320 init_ss(ssa
+1, 5, 6);
321 memset (&nullstr
, 0, sizeof nullstr
);
324 init_s (&arraystruct
.x
[0], 23);
325 init_s (&arraystruct
.x
[1], 24);
327 ns
.null_str
= "embedded\0null\0string";
330 /* Make a "corrupted" string. */
334 estring
.lazy_str
= "embedded x\201\202\203\204";
337 /* Incomplete UTF-8, but ok Latin-1. */
338 estring2
.lazy_str
= "embedded x\302";
341 estring3
.lazy_str
= NULL
;
356 init_s(&cpssa
[0].s
, 12);
358 init_s(&cpssa
[1].s
, 14);
368 init_s (&has_static_member::global
, 23);
369 has_static_member has_member
;
372 add_item (&c
, 23); /* MI breakpoint here */
377 c
.elements
[0] = 1023;
378 c
.elements
[0] = 2323;
380 add_item (&c2
, 2222);
381 add_item (&c2
, 3333);
387 nstype
.elements
[0] = 7;
388 nstype
.elements
[1] = 42;
395 bug_14741(); /* break to inspect struct and union */