GDB (xrefs)
Loading...
Searching...
No Matches
cp-valprint.c
Go to the documentation of this file.
1/* Support for printing C++ values for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20#include "defs.h"
21#include "gdbsupport/gdb_obstack.h"
22#include "symtab.h"
23#include "gdbtypes.h"
24#include "expression.h"
25#include "value.h"
26#include "command.h"
27#include "gdbcmd.h"
28#include "demangle.h"
29#include "annotate.h"
30#include "c-lang.h"
31#include "target.h"
32#include "cp-abi.h"
33#include "valprint.h"
34#include "cp-support.h"
35#include "language.h"
36#include "extension.h"
37#include "typeprint.h"
38#include "gdbsupport/byte-vector.h"
39#include "gdbarch.h"
40#include "cli/cli-style.h"
41#include "gdbsupport/selftest.h"
42#include "selftest-arch.h"
43
44static struct obstack dont_print_vb_obstack;
45static struct obstack dont_print_statmem_obstack;
46static struct obstack dont_print_stat_array_obstack;
47
48static void cp_print_static_field (struct type *, struct value *,
49 struct ui_file *, int,
50 const struct value_print_options *);
51
52static void cp_print_value (struct value *, struct ui_file *,
53 int, const struct value_print_options *,
54 struct type **);
55
56
57/* GCC versions after 2.4.5 use this. */
58const char vtbl_ptr_name[] = "__vtbl_ptr_type";
59
60/* Return truth value for assertion that TYPE is of the type
61 "pointer to virtual function". */
62
63int
65{
66 const char *type_name = type->name ();
67
68 return (type_name != NULL && !strcmp (type_name, vtbl_ptr_name));
69}
70
71/* Return truth value for the assertion that TYPE is of the type
72 "pointer to virtual function table". */
73
74int
76{
77 /* With older versions of g++, the vtbl field pointed to an array of
78 structures. Nowadays it points directly to the structure. */
79 if (type->code () == TYPE_CODE_PTR)
80 {
81 type = type->target_type ();
82 if (type->code () == TYPE_CODE_ARRAY)
83 {
84 type = type->target_type ();
85 if (type->code () == TYPE_CODE_STRUCT /* if not using thunks */
86 || type->code () == TYPE_CODE_PTR) /* if using thunks */
87 {
88 /* Virtual functions tables are full of pointers
89 to virtual functions. */
91 }
92 }
93 else if (type->code () == TYPE_CODE_STRUCT) /* if not using thunks */
94 {
96 }
97 else if (type->code () == TYPE_CODE_PTR) /* if using thunks */
98 {
99 /* The type name of the thunk pointer is NULL when using
100 dwarf2. We could test for a pointer to a function, but
101 there is no type info for the virtual table either, so it
102 wont help. */
103 return cp_is_vtbl_ptr_type (type);
104 }
105 }
106 return 0;
107}
108
109/* Mutually recursive subroutines of cp_print_value and c_val_print to
110 print out a structure's fields: cp_print_value_fields and
111 cp_print_value.
112
113 TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the same
114 meanings as in cp_print_value and c_val_print.
115
116 2nd argument REAL_TYPE is used to carry over the type of the
117 derived class across the recursion to base classes.
118
119 DONT_PRINT is an array of baseclass types that we should not print,
120 or zero if called from top level. */
121
122void
123cp_print_value_fields (struct value *val, struct ui_file *stream,
124 int recurse, const struct value_print_options *options,
125 struct type **dont_print_vb,
126 int dont_print_statmem)
127{
128 int i, len, n_baseclasses;
129 int fields_seen = 0;
130 static int last_set_recurse = -1;
131
132 struct type *type = check_typedef (val->type ());
133
134 if (recurse == 0)
135 {
136 /* Any object can be left on obstacks only during an unexpected
137 error. */
138
139 if (obstack_object_size (&dont_print_statmem_obstack) > 0)
140 {
141 obstack_free (&dont_print_statmem_obstack, NULL);
142 obstack_begin (&dont_print_statmem_obstack,
143 32 * sizeof (CORE_ADDR));
144 }
145 if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
146 {
147 obstack_free (&dont_print_stat_array_obstack, NULL);
148 obstack_begin (&dont_print_stat_array_obstack,
149 32 * sizeof (struct type *));
150 }
151 }
152
153 gdb_printf (stream, "{");
154 len = type->num_fields ();
155 n_baseclasses = TYPE_N_BASECLASSES (type);
156
157 /* First, print out baseclasses such that we don't print
158 duplicates of virtual baseclasses. */
159
160 if (n_baseclasses > 0)
161 cp_print_value (val, stream, recurse + 1, options, dont_print_vb);
162
163 /* Second, print out data fields */
164
165 /* If there are no data fields, skip this part */
166 if (len == n_baseclasses || !len)
167 fprintf_styled (stream, metadata_style.style (), "<No data fields>");
168 else
169 {
170 size_t statmem_obstack_initial_size = 0;
171 size_t stat_array_obstack_initial_size = 0;
172 struct type *vptr_basetype = NULL;
173 int vptr_fieldno;
174
175 if (dont_print_statmem == 0)
176 {
177 statmem_obstack_initial_size =
178 obstack_object_size (&dont_print_statmem_obstack);
179
180 if (last_set_recurse != recurse)
181 {
182 stat_array_obstack_initial_size =
183 obstack_object_size (&dont_print_stat_array_obstack);
184
185 last_set_recurse = recurse;
186 }
187 }
188
189 vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype);
190 for (i = n_baseclasses; i < len; i++)
191 {
192 const gdb_byte *valaddr = val->contents_for_printing ().data ();
193
194 /* If requested, skip printing of static fields. */
195 if (!options->static_field_print
196 && type->field (i).is_static ())
197 continue;
198
199 if (fields_seen)
200 {
201 gdb_puts (",", stream);
202 if (!options->prettyformat)
203 gdb_puts (" ", stream);
204 }
205 else if (n_baseclasses > 0)
206 {
207 if (options->prettyformat)
208 {
209 gdb_printf (stream, "\n");
210 print_spaces (2 + 2 * recurse, stream);
211 gdb_puts ("members of ", stream);
212 gdb_puts (type->name (), stream);
213 gdb_puts (":", stream);
214 }
215 }
216 fields_seen = 1;
217
218 if (options->prettyformat)
219 {
220 gdb_printf (stream, "\n");
221 print_spaces (2 + 2 * recurse, stream);
222 }
223 else
224 {
225 stream->wrap_here (2 + 2 * recurse);
226 }
227
229
230 if (type->field (i).is_static ())
231 {
232 gdb_puts ("static ", stream);
233 fprintf_symbol (stream,
234 type->field (i).name (),
236 DMGL_PARAMS | DMGL_ANSI);
237 }
238 else
239 fputs_styled (type->field (i).name (),
240 variable_name_style.style (), stream);
242
243 /* We tweak various options in a few cases below. */
244 value_print_options options_copy = *options;
245 value_print_options *opts = &options_copy;
246
247 /* Do not print leading '=' in case of anonymous
248 unions. */
249 if (strcmp (type->field (i).name (), ""))
250 gdb_puts (" = ", stream);
251 else
252 {
253 /* If this is an anonymous field then we want to consider it
254 as though it is at its parent's depth when it comes to the
255 max print depth. */
256 if (opts->max_depth != -1 && opts->max_depth < INT_MAX)
257 ++opts->max_depth;
258 }
260
261 if (!type->field (i).is_static ()
262 && type->field (i).is_packed ())
263 {
264 struct value *v;
265
266 /* Bitfields require special handling, especially due to
267 byte order problems. */
268 if (TYPE_FIELD_IGNORE (type, i))
269 {
270 fputs_styled ("<optimized out or zero length>",
271 metadata_style.style (), stream);
272 }
273 else if (val->bits_synthetic_pointer
274 (type->field (i).loc_bitpos (),
275 type->field (i).bitsize ()))
276 {
277 fputs_styled (_("<synthetic pointer>"),
278 metadata_style.style (), stream);
279 }
280 else
281 {
282 opts->deref_ref = false;
283
284 v = value_field_bitfield (type, i, valaddr,
285 val->embedded_offset (), val);
286
287 common_val_print (v, stream, recurse + 1,
288 opts, current_language);
289 }
290 }
291 else
292 {
293 if (TYPE_FIELD_IGNORE (type, i))
294 {
295 fputs_styled ("<optimized out or zero length>",
296 metadata_style.style (), stream);
297 }
298 else if (type->field (i).is_static ())
299 {
300 try
301 {
302 struct value *v = value_static_field (type, i);
303
305 v, stream, recurse + 1,
306 opts);
307 }
308 catch (const gdb_exception_error &ex)
309 {
311 _("<error reading variable: %s>"),
312 ex.what ());
313 }
314 }
315 else if (i == vptr_fieldno && type == vptr_basetype)
316 {
317 int i_offset = type->field (i).loc_bitpos () / 8;
318 struct type *i_type = type->field (i).type ();
319
320 if (valprint_check_validity (stream, i_type, i_offset, val))
321 {
322 CORE_ADDR addr;
323
324 i_offset += val->embedded_offset ();
325 addr = extract_typed_address (valaddr + i_offset, i_type);
327 type->arch (),
328 addr, stream);
329 }
330 }
331 else
332 {
333 struct value *v = val->primitive_field (0, i, type);
334 opts->deref_ref = false;
335 common_val_print (v, stream, recurse + 1, opts,
337 }
338 }
340 }
341
342 if (dont_print_statmem == 0)
343 {
344 size_t obstack_final_size =
345 obstack_object_size (&dont_print_statmem_obstack);
346
347 if (obstack_final_size > statmem_obstack_initial_size)
348 {
349 /* In effect, a pop of the printed-statics stack. */
350 size_t shrink_bytes
351 = statmem_obstack_initial_size - obstack_final_size;
352 obstack_blank_fast (&dont_print_statmem_obstack, shrink_bytes);
353 }
354
355 if (last_set_recurse != recurse)
356 {
357 obstack_final_size =
358 obstack_object_size (&dont_print_stat_array_obstack);
359
360 if (obstack_final_size > stat_array_obstack_initial_size)
361 {
362 void *free_to_ptr =
363 (char *) obstack_next_free (&dont_print_stat_array_obstack)
364 - (obstack_final_size
365 - stat_array_obstack_initial_size);
366
367 obstack_free (&dont_print_stat_array_obstack,
368 free_to_ptr);
369 }
370 last_set_recurse = -1;
371 }
372 }
373
374 if (options->prettyformat)
375 {
376 gdb_printf (stream, "\n");
377 print_spaces (2 * recurse, stream);
378 }
379 } /* if there are data fields */
380
381 gdb_printf (stream, "}");
382}
383
384/* A wrapper for cp_print_value_fields that tries to apply a
385 pretty-printer first. */
386
387static void
389 struct ui_file *stream,
390 int recurse,
391 const struct value_print_options *options,
392 struct type **dont_print_vb,
393 int dont_print_statmem)
394{
395 int result = 0;
396
397 /* Attempt to run an extension language pretty-printer if
398 possible. */
399 if (!options->raw)
400 result
402 recurse, options,
404
405 if (!result)
406 cp_print_value_fields (val, stream, recurse, options, dont_print_vb,
407 dont_print_statmem);
408}
409
410/* Special val_print routine to avoid printing multiple copies of
411 virtual baseclasses. */
412
413static void
414cp_print_value (struct value *val, struct ui_file *stream,
415 int recurse, const struct value_print_options *options,
416 struct type **dont_print_vb)
417{
418 struct type *type = check_typedef (val->type ());
419 CORE_ADDR address = val->address ();
420 struct type **last_dont_print
421 = (struct type **) obstack_next_free (&dont_print_vb_obstack);
422 struct obstack tmp_obstack = dont_print_vb_obstack;
423 int i, n_baseclasses = TYPE_N_BASECLASSES (type);
424 const gdb_byte *valaddr = val->contents_for_printing ().data ();
425
426 if (dont_print_vb == 0)
427 {
428 /* If we're at top level, carve out a completely fresh chunk of
429 the obstack and use that until this particular invocation
430 returns. */
431 /* Bump up the high-water mark. Now alpha is omega. */
432 obstack_finish (&dont_print_vb_obstack);
433 }
434
435 for (i = 0; i < n_baseclasses; i++)
436 {
437 LONGEST boffset = 0;
438 int skip = 0;
439 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
440 const char *basename = baseclass->name ();
441 struct value *base_val = NULL;
442
443 if (BASETYPE_VIA_VIRTUAL (type, i))
444 {
445 struct type **first_dont_print
446 = (struct type **) obstack_base (&dont_print_vb_obstack);
447
448 int j = (struct type **)
449 obstack_next_free (&dont_print_vb_obstack) - first_dont_print;
450
451 while (--j >= 0)
452 if (baseclass == first_dont_print[j])
453 goto flush_it;
454
455 obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
456 }
457
458 try
459 {
460 boffset = baseclass_offset (type, i, valaddr,
461 val->embedded_offset (),
462 address, val);
463 }
464 catch (const gdb_exception_error &ex)
465 {
466 if (ex.error == NOT_AVAILABLE_ERROR)
467 skip = -1;
468 else
469 skip = 1;
470 }
471
472 if (skip == 0)
473 {
474 if (BASETYPE_VIA_VIRTUAL (type, i))
475 {
476 /* The virtual base class pointer might have been
477 clobbered by the user program. Make sure that it
478 still points to a valid memory location. */
479
480 if (boffset < 0 || boffset >= type->length ())
481 {
482 gdb::byte_vector buf (baseclass->length ());
483
484 if (target_read_memory (address + boffset, buf.data (),
485 baseclass->length ()) != 0)
486 skip = 1;
487 base_val = value_from_contents_and_address (baseclass,
488 buf.data (),
489 address + boffset);
490 baseclass = base_val->type ();
491 boffset = 0;
492 }
493 else
494 {
495 base_val = val;
496 }
497 }
498 else
499 {
500 base_val = val;
501 }
502 }
503
504 /* Now do the printing. */
505 if (options->prettyformat)
506 {
507 gdb_printf (stream, "\n");
508 print_spaces (2 * recurse, stream);
509 }
510 gdb_puts ("<", stream);
511 /* Not sure what the best notation is in the case where there is
512 no baseclass name. */
513 gdb_puts (basename ? basename : "", stream);
514 gdb_puts ("> = ", stream);
515
516 if (skip < 0)
517 val_print_unavailable (stream);
518 else if (skip > 0)
520 else
521 {
522 if (!val_print_check_max_depth (stream, recurse, options,
524 {
525 struct value *baseclass_val = val->primitive_field (0,
526 i, type);
527
529 (baseclass_val, stream, recurse, options,
530 (struct type **) obstack_base (&dont_print_vb_obstack),
531 0);
532 }
533 }
534 gdb_puts (", ", stream);
535
536 flush_it:
537 ;
538 }
539
540 if (dont_print_vb == 0)
541 {
542 /* Free the space used to deal with the printing
543 of this type from top level. */
544 obstack_free (&dont_print_vb_obstack, last_dont_print);
545 /* Reset watermark so that we can continue protecting
546 ourselves from whatever we were protecting ourselves. */
547 dont_print_vb_obstack = tmp_obstack;
548 }
549}
550
551/* Print value of a static member. To avoid infinite recursion when
552 printing a class that contains a static instance of the class, we
553 keep the addresses of all printed static member classes in an
554 obstack and refuse to print them more than once.
555
556 VAL contains the value to print, TYPE, STREAM, RECURSE, and OPTIONS
557 have the same meanings as in c_val_print. */
558
559static void
561 struct value *val,
562 struct ui_file *stream,
563 int recurse,
564 const struct value_print_options *options)
565{
566 struct value_print_options opts;
567
568 if (val->entirely_optimized_out ())
569 {
570 val_print_optimized_out (val, stream);
571 return;
572 }
573
574 struct type *real_type = check_typedef (type);
575 if (real_type->code () == TYPE_CODE_STRUCT)
576 {
577 CORE_ADDR *first_dont_print;
578 CORE_ADDR addr = val->address ();
579 int i;
580
581 first_dont_print
582 = (CORE_ADDR *) obstack_base (&dont_print_statmem_obstack);
583 i = obstack_object_size (&dont_print_statmem_obstack)
584 / sizeof (CORE_ADDR);
585
586 while (--i >= 0)
587 {
588 if (addr == first_dont_print[i])
589 {
590 fputs_styled (_("<same as static member of an already"
591 " seen type>"),
592 metadata_style.style (), stream);
593 return;
594 }
595 }
596
597 obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
598 sizeof (CORE_ADDR));
599 cp_print_value_fields_pp (val, stream, recurse, options, nullptr, 1);
600 return;
601 }
602
603 if (real_type->code () == TYPE_CODE_ARRAY)
604 {
605 struct type **first_dont_print;
606 int i;
607 struct type *target_type = type->target_type ();
608
609 first_dont_print
610 = (struct type **) obstack_base (&dont_print_stat_array_obstack);
611 i = obstack_object_size (&dont_print_stat_array_obstack)
612 / sizeof (struct type *);
613
614 while (--i >= 0)
615 {
616 if (target_type == first_dont_print[i])
617 {
618 fputs_styled (_("<same as static member of an already"
619 " seen type>"),
620 metadata_style.style (), stream);
621 return;
622 }
623 }
624
625 obstack_grow (&dont_print_stat_array_obstack,
626 (char *) &target_type,
627 sizeof (struct type *));
628 }
629
630 opts = *options;
631 opts.deref_ref = false;
632 common_val_print (val, stream, recurse, &opts, current_language);
633}
634
635/* Find the field in *SELF, or its non-virtual base classes, with
636 bit offset OFFSET. Set *SELF to the containing type and *FIELDNO
637 to the containing field number. If OFFSET is not exactly at the
638 start of some field, set *SELF to NULL. */
639
640static void
641cp_find_class_member (struct type **self_p, int *fieldno,
642 LONGEST offset)
643{
644 struct type *self;
645 unsigned int i;
646 unsigned len;
647
648 *self_p = check_typedef (*self_p);
649 self = *self_p;
650 len = self->num_fields ();
651
652 for (i = TYPE_N_BASECLASSES (self); i < len; i++)
653 {
654 field &f = self->field (i);
655 if (f.is_static ())
656 continue;
657 LONGEST bitpos = f.loc_bitpos ();
658
659 QUIT;
660 if (offset == bitpos)
661 {
662 *fieldno = i;
663 return;
664 }
665 }
666
667 for (i = 0; i < TYPE_N_BASECLASSES (self); i++)
668 {
669 LONGEST bitpos = self->field (i).loc_bitpos ();
670 LONGEST bitsize = 8 * self->field (i).type ()->length ();
671
672 if (offset >= bitpos && offset < bitpos + bitsize)
673 {
674 *self_p = self->field (i).type ();
675 cp_find_class_member (self_p, fieldno, offset - bitpos);
676 return;
677 }
678 }
679
680 *self_p = NULL;
681}
682
683void
684cp_print_class_member (const gdb_byte *valaddr, struct type *type,
685 struct ui_file *stream, const char *prefix)
686{
687 enum bfd_endian byte_order = type_byte_order (type);
688
689 /* VAL is a byte offset into the structure type SELF_TYPE.
690 Find the name of the field for that offset and
691 print it. */
692 struct type *self_type = TYPE_SELF_TYPE (type);
693 LONGEST val;
694 int fieldno;
695
696 val = extract_signed_integer (valaddr,
697 type->length (),
698 byte_order);
699
700 /* Pointers to data members are usually byte offsets into an object.
701 Because a data member can have offset zero, and a NULL pointer to
702 member must be distinct from any valid non-NULL pointer to
703 member, either the value is biased or the NULL value has a
704 special representation; both are permitted by ISO C++. HP aCC
705 used a bias of 0x20000000; HP cfront used a bias of 1; g++ 3.x
706 and other compilers which use the Itanium ABI use -1 as the NULL
707 value. GDB only supports that last form; to add support for
708 another form, make this into a cp-abi hook. */
709
710 if (val == -1)
711 {
712 gdb_printf (stream, "NULL");
713 return;
714 }
715
716 cp_find_class_member (&self_type, &fieldno, val << 3);
717
718 if (self_type != NULL)
719 {
720 const char *name;
721
722 gdb_puts (prefix, stream);
723 name = self_type->name ();
724 if (name)
725 gdb_puts (name, stream);
726 else
727 c_type_print_base (self_type, stream, 0, 0, &type_print_raw_options);
728 gdb_printf (stream, "::");
729 fputs_styled (self_type->field (fieldno).name (),
730 variable_name_style.style (), stream);
731 }
732 else
733 gdb_printf (stream, "%ld", (long) val);
734}
735
736#if GDB_SELF_TEST
737
738/* Test printing of TYPE_CODE_STRUCT values. */
739
740static void
741test_print_fields (gdbarch *arch)
742{
743 struct field *f;
744 type *uint8_type = builtin_type (arch)->builtin_uint8;
745 type *bool_type = builtin_type (arch)->builtin_bool;
746 type *the_struct = arch_composite_type (arch, NULL, TYPE_CODE_STRUCT);
747 the_struct->set_length (4);
748
749 /* Value: 1110 1001
750 Fields: C-BB B-A- */
751 if (gdbarch_byte_order (arch) == BFD_ENDIAN_LITTLE)
752 {
753 f = append_composite_type_field_raw (the_struct, "A", bool_type);
754 f->set_loc_bitpos (1);
755 f->set_bitsize (1);
756 f = append_composite_type_field_raw (the_struct, "B", uint8_type);
757 f->set_loc_bitpos (3);
758 f->set_bitsize (3);
759 f = append_composite_type_field_raw (the_struct, "C", bool_type);
760 f->set_loc_bitpos (7);
761 f->set_bitsize (1);
762 }
763 /* According to the logic commented in "make_gdb_type_struct ()" of
764 * target-descriptions.c, bit positions are numbered differently for
765 * little and big endians. */
766 else
767 {
768 f = append_composite_type_field_raw (the_struct, "A", bool_type);
769 f->set_loc_bitpos (30);
770 f->set_bitsize (1);
771 f = append_composite_type_field_raw (the_struct, "B", uint8_type);
772 f->set_loc_bitpos (26);
773 f->set_bitsize (3);
774 f = append_composite_type_field_raw (the_struct, "C", bool_type);
775 f->set_loc_bitpos (24);
776 f->set_bitsize (1);
777 }
778
779 value *val = value::allocate (the_struct);
780 gdb_byte *contents = val->contents_writeable ().data ();
781 store_unsigned_integer (contents, val->enclosing_type ()->length (),
782 gdbarch_byte_order (arch), 0xe9);
783
784 string_file out;
787 cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
788 SELF_CHECK (out.string () == "{A = false, B = 5, C = true}");
789
790 out.clear();
791 opts.format = 'x';
792 cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
793 SELF_CHECK (out.string () == "{A = 0x0, B = 0x5, C = 0x1}");
794}
795
796#endif
797
798
800void
802{
803#if GDB_SELF_TEST
804 selftests::register_test_foreach_arch ("print-fields", test_print_fields);
805#endif
806
807 obstack_begin (&dont_print_stat_array_obstack,
808 32 * sizeof (struct type *));
809 obstack_begin (&dont_print_statmem_obstack,
810 32 * sizeof (CORE_ADDR));
811 obstack_begin (&dont_print_vb_obstack,
812 32 * sizeof (struct type *));
813}
const char *const name
void annotate_field_value(void)
Definition annotate.c:266
void annotate_field_begin(struct type *type)
Definition annotate.c:248
void annotate_field_name_end(void)
Definition annotate.c:259
void annotate_field_end(void)
Definition annotate.c:273
void f()
Definition 1.cc:36
void c_type_print_base(struct type *, struct ui_file *, int, int, const struct type_print_options *)
ui_file_style style() const
Definition cli-style.c:169
const std::string & string()
Definition ui-file.h:198
void clear()
Definition ui-file.h:225
virtual void wrap_here(int indent)
Definition ui-file.h:119
cli_style_option variable_name_style
cli_style_option metadata_style
int baseclass_offset(struct type *type, int index, const gdb_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, const struct value *val)
Definition cp-abi.c:69
static void cp_find_class_member(struct type **self_p, int *fieldno, LONGEST offset)
static struct obstack dont_print_vb_obstack
Definition cp-valprint.c:44
static void cp_print_value(struct value *, struct ui_file *, int, const struct value_print_options *, struct type **)
static struct obstack dont_print_statmem_obstack
Definition cp-valprint.c:45
static void cp_print_value_fields_pp(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, struct type **dont_print_vb, int dont_print_statmem)
void _initialize_cp_valprint()
int cp_is_vtbl_ptr_type(struct type *type)
Definition cp-valprint.c:64
static void cp_print_static_field(struct type *, struct value *, struct ui_file *, int, const struct value_print_options *)
int cp_is_vtbl_member(struct type *type)
Definition cp-valprint.c:75
void cp_print_class_member(const gdb_byte *valaddr, struct type *type, struct ui_file *stream, const char *prefix)
static struct obstack dont_print_stat_array_obstack
Definition cp-valprint.c:46
const char vtbl_ptr_name[]
Definition cp-valprint.c:58
void cp_print_value_fields(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, struct type **dont_print_vb, int dont_print_statmem)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:515
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
Definition findvar.c:152
static LONGEST extract_signed_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:465
#define QUIT
Definition defs.h:187
int apply_ext_lang_val_pretty_printer(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition extension.c:477
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
enum bfd_endian type_byte_order(const struct type *type)
Definition gdbtypes.c:3900
struct type * arch_composite_type(struct gdbarch *gdbarch, const char *name, enum type_code code)
Definition gdbtypes.c:5734
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition gdbtypes.c:6168
struct field * append_composite_type_field_raw(struct type *t, const char *name, struct type *field)
Definition gdbtypes.c:5751
int get_vptr_fieldno(struct type *type, struct type **basetypep)
Definition gdbtypes.c:1977
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
#define TYPE_SELF_TYPE(thistype)
Definition gdbtypes.h:1913
#define TYPE_BASECLASS(thistype, index)
Definition gdbtypes.h:1946
#define TYPE_FIELD_IGNORE(thistype, n)
Definition gdbtypes.h:1980
#define BASETYPE_VIA_VIRTUAL(thistype, index)
Definition gdbtypes.h:1954
#define TYPE_N_BASECLASSES(thistype)
Definition gdbtypes.h:1947
const struct language_defn * current_language
Definition language.c:82
void register_test_foreach_arch(const std::string &name, self_test_foreach_arch_function *function)
#define prefix(a, b, R, do)
Definition ppc64-tdep.c:52
struct type * builtin_bool
Definition gdbtypes.h:2095
struct type * builtin_uint8
Definition gdbtypes.h:2114
LONGEST loc_bitpos() const
Definition gdbtypes.h:611
const char * name() const
Definition gdbtypes.h:557
unsigned int bitsize() const
Definition gdbtypes.h:577
bool is_packed() const
Definition gdbtypes.h:587
struct type * type() const
Definition gdbtypes.h:547
bool is_static() const
Definition gdbtypes.h:593
enum language la_language
Definition language.h:275
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
struct field & field(int idx) const
Definition gdbtypes.h:1012
unsigned int num_fields() const
Definition gdbtypes.h:994
gdbarch * arch() const
Definition gdbtypes.c:273
void set_length(ULONGEST length)
Definition gdbtypes.h:988
const char * name() const
Definition gdbtypes.h:968
enum val_prettyformat prettyformat
Definition valprint.h:41
Definition value.h:130
struct value * primitive_field(LONGEST offset, int fieldno, struct type *arg_type)
Definition value.c:2932
gdb::array_view< gdb_byte > contents_writeable()
Definition value.c:1271
static struct value * allocate(struct type *type)
Definition value.c:957
struct type * enclosing_type() const
Definition value.h:312
LONGEST embedded_offset() const
Definition value.h:244
struct type * type() const
Definition value.h:180
bool entirely_optimized_out()
Definition value.h:529
CORE_ADDR address
Definition value.h:658
bool bits_synthetic_pointer(LONGEST offset, LONGEST length) const
Definition value.c:1339
gdb::array_view< const gdb_byte > contents_for_printing()
Definition value.c:1100
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition target.c:1785
const struct type_print_options type_print_raw_options
Definition typeprint.c:41
void print_spaces(int n, struct ui_file *stream)
Definition utils.c:1968
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
Definition utils.c:1898
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
void fputs_styled(const char *linebuffer, const ui_file_style &style, struct ui_file *stream)
Definition utils.c:1817
void fprintf_symbol(struct ui_file *stream, const char *name, enum language lang, int arg_mode)
Definition utils.c:1981
void gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1809
void get_no_prettyformat_print_options(struct value_print_options *opts)
Definition valprint.c:143
void val_print_unavailable(struct ui_file *stream)
Definition valprint.c:431
int valprint_check_validity(struct ui_file *stream, struct type *type, LONGEST embedded_offset, const struct value *val)
Definition valprint.c:353
void val_print_optimized_out(const struct value *val, struct ui_file *stream)
Definition valprint.c:416
bool val_print_check_max_depth(struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition valprint.c:1104
void val_print_invalid_address(struct ui_file *stream)
Definition valprint.c:437
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition valprint.c:1033
void print_function_pointer_address(const struct value_print_options *options, struct gdbarch *gdbarch, CORE_ADDR address, struct ui_file *stream)
Definition valprint.c:1904
struct value * value_static_field(struct type *type, int fieldno)
Definition value.c:2870
struct value * value_field_bitfield(struct type *type, int fieldno, const gdb_byte *valaddr, LONGEST embedded_offset, const struct value *val)
Definition value.c:3259
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address, frame_info_ptr frame)
Definition value.c:3552