GDB (xrefs)
Loading...
Searching...
No Matches
typeprint.c
Go to the documentation of this file.
1/* Language independent support for printing types 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 "bfd.h"
23#include "symtab.h"
24#include "gdbtypes.h"
25#include "expression.h"
26#include "value.h"
27#include "gdbcore.h"
28#include "command.h"
29#include "gdbcmd.h"
30#include "target.h"
31#include "language.h"
32#include "cp-abi.h"
33#include "typeprint.h"
34#include "valprint.h"
35#include <ctype.h>
36#include "cli/cli-utils.h"
37#include "extension.h"
38#include "completer.h"
39#include "cli/cli-style.h"
40
42{
43 1, /* raw */
44 1, /* print_methods */
45 1, /* print_typedefs */
46 0, /* print_offsets */
47 0, /* print_in_hex */
48 0, /* print_nested_type_limit */
49 NULL, /* local_typedefs */
50 NULL, /* global_table */
51 NULL /* global_printers */
52};
53
54/* The default flags for 'ptype' and 'whatis'. */
55
57{
58 0, /* raw */
59 1, /* print_methods */
60 1, /* print_typedefs */
61 0, /* print_offsets */
62 0, /* print_in_hex */
63 0, /* print_nested_type_limit */
64 NULL, /* local_typedefs */
65 NULL, /* global_table */
66 NULL /* global_printers */
67};
68
69
70
71/* See typeprint.h. */
72
74
75/* See typeprint.h. */
76
82
83/* See typeprint.h. */
84
85void
87 unsigned int bitpos,
88 const char *for_what)
89{
90 /* We check for END_BITPOS > 0 because there is a specific
91 scenario when END_BITPOS can be zero and BITPOS can be >
92 0: when we are dealing with a struct/class with a virtual method.
93 Because of the vtable, the first field of the struct/class will
94 have an offset of sizeof (void *) (the size of the vtable). If
95 we do not check for END_BITPOS > 0 here, GDB will report
96 a hole before the first field, which is not accurate. */
97 if (end_bitpos > 0 && end_bitpos < bitpos)
98 {
99 /* If END_BITPOS is smaller than the current type's
100 bitpos, it means there's a hole in the struct, so we report
101 it here. */
102 unsigned int hole = bitpos - end_bitpos;
103 unsigned int hole_byte = hole / TARGET_CHAR_BIT;
104 unsigned int hole_bit = hole % TARGET_CHAR_BIT;
105
106 if (hole_bit > 0)
107 {
109 "/* XXX %2u-bit %-7s */", hole_bit, for_what);
110 gdb_puts ("\n", stream);
111 }
112
113 if (hole_byte > 0)
114 {
116 "/* XXX %2u-byte %-7s */", hole_byte, for_what);
117 gdb_puts ("\n", stream);
118 }
119 }
120}
121
122/* See typeprint.h. */
123
124void
125print_offset_data::update (struct type *type, unsigned int field_idx,
126 struct ui_file *stream)
127{
128 if (type->field (field_idx).is_static ())
129 {
130 print_spaces (indentation, stream);
131 return;
132 }
133
134 struct type *ftype = check_typedef (type->field (field_idx).type ());
135 if (type->code () == TYPE_CODE_UNION)
136 {
137 /* Since union fields don't have the concept of offsets, we just
138 print their sizes. */
139 gdb_printf (stream, "/* %6s */",
140 (print_in_hex ?
141 hex_string_custom (ftype->length (), 4) :
142 pulongest (ftype->length ())));
143 return;
144 }
145
146 unsigned int bitpos = type->field (field_idx).loc_bitpos ();
147 unsigned int fieldsize_byte = ftype->length ();
148 unsigned int fieldsize_bit = fieldsize_byte * TARGET_CHAR_BIT;
149
150 maybe_print_hole (stream, bitpos, "hole");
151
152 if (type->field (field_idx).is_packed ()
153 || offset_bitpos % TARGET_CHAR_BIT != 0)
154 {
155 /* We're dealing with a bitfield. Print the bit offset. */
156 fieldsize_bit = type->field (field_idx).bitsize ();
157
158 unsigned real_bitpos = bitpos + offset_bitpos;
159
160 gdb_printf (stream,
161 (print_in_hex ? "/* 0x%04x: 0x%x" : "/* %6u:%2u "),
162 real_bitpos / TARGET_CHAR_BIT,
163 real_bitpos % TARGET_CHAR_BIT);
164 }
165 else
166 {
167 /* The position of the field, relative to the beginning of the
168 struct. */
169 gdb_printf (stream, (print_in_hex ? "/* 0x%04x" : "/* %6u"),
170 (bitpos + offset_bitpos) / TARGET_CHAR_BIT);
171
172 gdb_printf (stream, " ");
173 }
174
175 gdb_printf (stream, (print_in_hex ? " | 0x%04x */" : " | %6u */"),
176 fieldsize_byte);
177
178 end_bitpos = bitpos + fieldsize_bit;
179}
180
181/* See typeprint.h. */
182
183void
185 struct ui_file *stream)
186{
187 unsigned int bitpos = type->length () * TARGET_CHAR_BIT;
188 maybe_print_hole (stream, bitpos, "padding");
189
190 gdb_puts ("\n", stream);
191 print_spaces (level + 4 + print_offset_data::indentation, stream);
192 gdb_printf (stream, "/* total size (bytes): %4s */\n",
193 pulongest (type->length ()));
194}
195
196
197
198/* A hash function for a typedef_field. */
199
200static hashval_t
201hash_typedef_field (const void *p)
202{
203 const struct decl_field *tf = (const struct decl_field *) p;
204
205 return htab_hash_string (TYPE_SAFE_NAME (tf->type));
206}
207
208/* An equality function for a typedef field. */
209
210static int
211eq_typedef_field (const void *a, const void *b)
212{
213 const struct decl_field *tfa = (const struct decl_field *) a;
214 const struct decl_field *tfb = (const struct decl_field *) b;
215
216 return types_equal (tfa->type, tfb->type);
217}
218
219/* See typeprint.h. */
220
221void
223{
224 int i;
225
226 for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (t); ++i)
227 {
228 struct decl_field *tdef = &TYPE_TYPEDEF_FIELD (t, i);
229 void **slot;
230
231 slot = htab_find_slot (m_table.get (), tdef, INSERT);
232 /* Only add a given typedef name once. Really this shouldn't
233 happen; but it is safe enough to do the updates breadth-first
234 and thus use the most specific typedef. */
235 if (*slot == NULL)
236 *slot = tdef;
237 }
238
239 /* Recurse into superclasses. */
240 for (i = 0; i < TYPE_N_BASECLASSES (t); ++i)
242}
243
244/* See typeprint.h. */
245
246void
248{
249 int i;
250
251 for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (t); ++i)
252 {
253 struct decl_field *tf;
254 void **slot;
255
256 /* We only want type-valued template parameters in the hash. */
257 if (TYPE_TEMPLATE_ARGUMENT (t, i)->aclass () != LOC_TYPEDEF)
258 continue;
259
260 tf = XOBNEW (&m_storage, struct decl_field);
261 tf->name = TYPE_TEMPLATE_ARGUMENT (t, i)->linkage_name ();
262 tf->type = TYPE_TEMPLATE_ARGUMENT (t, i)->type ();
263
264 slot = htab_find_slot (m_table.get (), tf, INSERT);
265 if (*slot == NULL)
266 *slot = tf;
267 }
268}
269
270/* See typeprint.h. */
271
273 : m_table (htab_create_alloc (10, hash_typedef_field, eq_typedef_field,
274 NULL, xcalloc, xfree))
275{
276}
277
278/* Helper function for typedef_hash_table::copy. */
279
280static int
281copy_typedef_hash_element (void **slot, void *nt)
282{
283 htab_t new_table = (htab_t) nt;
284 void **new_slot;
285
286 new_slot = htab_find_slot (new_table, *slot, INSERT);
287 if (*new_slot == NULL)
288 *new_slot = *slot;
289
290 return 1;
291}
292
293/* See typeprint.h. */
294
296{
297 m_table.reset (htab_create_alloc (10, hash_typedef_field, eq_typedef_field,
298 NULL, xcalloc, xfree));
299 htab_traverse_noresize (table.m_table.get (), copy_typedef_hash_element,
300 m_table.get ());
301}
302
303/* Look up the type T in the global typedef hash. If it is found,
304 return the typedef name. If it is not found, apply the
305 type-printers, if any, given by start_script_type_printers and return the
306 result. A NULL return means that the name was not found. */
307
308const char *
310 struct type *t)
311{
312 void **slot;
313 struct decl_field tf, *new_tf;
314
315 if (flags->global_typedefs == NULL)
316 return NULL;
317
318 tf.name = NULL;
319 tf.type = t;
320
321 slot = htab_find_slot (flags->global_typedefs->m_table.get (), &tf, INSERT);
322 if (*slot != NULL)
323 {
324 new_tf = (struct decl_field *) *slot;
325 return new_tf->name;
326 }
327
328 /* Put an entry into the hash table now, in case
329 apply_ext_lang_type_printers recurses. */
330 new_tf = XOBNEW (&flags->global_typedefs->m_storage, struct decl_field);
331 new_tf->name = NULL;
332 new_tf->type = t;
333
334 *slot = new_tf;
335
336 gdb::unique_xmalloc_ptr<char> applied
337 = apply_ext_lang_type_printers (flags->global_printers, t);
338
339 if (applied != nullptr)
340 new_tf->name = obstack_strdup (&flags->global_typedefs->m_storage,
341 applied.get ());
342
343 return new_tf->name;
344}
345
346/* See typeprint.h. */
347
348const char *
350 struct type *t)
351{
352 if (flags->local_typedefs != NULL)
353 {
354 struct decl_field tf, *found;
355
356 tf.name = NULL;
357 tf.type = t;
358 htab_t table = flags->local_typedefs->m_table.get ();
359 found = (struct decl_field *) htab_find (table, &tf);
360
361 if (found != NULL)
362 return found->name;
363 }
364
365 return find_global_typedef (flags, t);
366}
367
368
369
370/* Print a description of a type in the format of a
371 typedef for the current language.
372 NEW is the new name for a type TYPE. */
373
374void
375typedef_print (struct type *type, struct symbol *newobj, struct ui_file *stream)
376{
377 current_language->print_typedef (type, newobj, stream);
378}
379
380/* Print a description of a type TYPE in the form of a declaration of a
381 variable named VARSTRING. (VARSTRING is demangled if necessary.)
382 Output goes to STREAM (via stdio).
383 If SHOW is positive, we show the contents of the outermost level
384 of structure even if there is a type name that could be used instead.
385 If SHOW is negative, we never show the details of elements' types. */
386
387void
388type_print (struct type *type, const char *varstring, struct ui_file *stream,
389 int show)
390{
391 current_language->print_type (type, varstring, stream, show, 0,
393}
394
395/* Print TYPE to a string, returning it. The caller is responsible for
396 freeing the string. */
397
398std::string
400{
401 try
402 {
403 string_file stb;
404
405 type_print (type, "", &stb, -1);
406 return stb.release ();
407 }
408 catch (const gdb_exception &except)
409 {
410 }
411
412 return {};
413}
414
415/* See typeprint.h. */
416
417void
419{
421 _("<unknown return type>"));
422}
423
424/* See typeprint.h. */
425
426void
427error_unknown_type (const char *sym_print_name)
428{
429 error (_("'%s' has unknown type; cast it to its declared type"),
430 sym_print_name);
431}
432
433/* Print type of EXP, or last thing in value history if EXP == NULL.
434 show is passed to type_print. */
435
436static void
437whatis_exp (const char *exp, int show)
438{
439 struct value *val;
440 struct type *real_type = NULL;
441 struct type *type;
442 int full = 0;
443 LONGEST top = -1;
444 int using_enc = 0;
445 struct value_print_options opts;
447
448 if (exp)
449 {
450 if (*exp == '/')
451 {
452 int seen_one = 0;
453
454 for (++exp; *exp && !isspace (*exp); ++exp)
455 {
456 switch (*exp)
457 {
458 case 'r':
459 flags.raw = 1;
460 break;
461 case 'm':
462 flags.print_methods = 0;
463 break;
464 case 'M':
465 flags.print_methods = 1;
466 break;
467 case 't':
468 flags.print_typedefs = 0;
469 break;
470 case 'T':
471 flags.print_typedefs = 1;
472 break;
473 case 'o':
474 {
475 /* Filter out languages which don't implement the
476 feature. */
477 if (show > 0
479 {
480 flags.print_offsets = 1;
481 flags.print_typedefs = 0;
482 flags.print_methods = 0;
483 }
484 break;
485 }
486 case 'x':
487 flags.print_in_hex = 1;
488 break;
489 case 'd':
490 flags.print_in_hex = 0;
491 break;
492 default:
493 error (_("unrecognized flag '%c'"), *exp);
494 }
495 seen_one = 1;
496 }
497
498 if (!*exp && !seen_one)
499 error (_("flag expected"));
500 if (!isspace (*exp))
501 error (_("expected space after format"));
502 exp = skip_spaces (exp);
503 }
504
506
507 /* The behavior of "whatis" depends on whether the user
508 expression names a type directly, or a language expression
509 (including variable names). If the former, then "whatis"
510 strips one level of typedefs, only. If an expression,
511 "whatis" prints the type of the expression without stripping
512 any typedef level. "ptype" always strips all levels of
513 typedefs. */
514 val = expr->evaluate_type ();
515 type = val->type ();
516
517 if (show == -1 && expr->first_opcode () == OP_TYPE)
518 {
519 /* The user expression names a type directly. */
520
521 /* If this is a typedef, then find its immediate target.
522 Use check_typedef to resolve stubs, but ignore its result
523 because we do not want to dig past all typedefs. */
525 if (type->code () == TYPE_CODE_TYPEDEF)
526 type = type->target_type ();
527
528 /* If the expression is actually a type, then there's no
529 value to fetch the dynamic type from. */
530 val = NULL;
531 }
532 }
533 else
534 {
535 val = access_value_history (0);
536 type = val->type ();
537 }
538
539 if (flags.print_offsets && is_dynamic_type (type))
540 {
541 warning (_("ptype/o does not work with dynamic types; disabling '/o'"));
542 flags.print_offsets = 0;
543 }
544
546 if (val != NULL && opts.objectprint)
547 {
549 && (type->target_type ()->code () == TYPE_CODE_STRUCT))
550 real_type = value_rtti_indirect_type (val, &full, &top, &using_enc);
551 else if (type->code () == TYPE_CODE_STRUCT)
552 real_type = value_rtti_type (val, &full, &top, &using_enc);
553 }
554
555 if (flags.print_offsets
556 && (type->code () == TYPE_CODE_STRUCT
557 || type->code () == TYPE_CODE_UNION))
558 gdb_printf ("/* offset | size */ ");
559
560 gdb_printf ("type = ");
561
562 std::unique_ptr<typedef_hash_table> table_holder;
563 std::unique_ptr<ext_lang_type_printers> printer_holder;
564 if (!flags.raw)
565 {
566 table_holder.reset (new typedef_hash_table);
567 flags.global_typedefs = table_holder.get ();
568
569 printer_holder.reset (new ext_lang_type_printers);
570 flags.global_printers = printer_holder.get ();
571 }
572
573 if (real_type)
574 {
575 gdb_printf ("/* real type = ");
576 type_print (real_type, "", gdb_stdout, -1);
577 if (! full)
578 gdb_printf (" (incomplete object)");
579 gdb_printf (" */\n");
580 }
581
583 gdb_printf ("\n");
584}
585
586static void
587whatis_command (const char *exp, int from_tty)
588{
589 /* Most of the time users do not want to see all the fields
590 in a structure. If they do they can use the "ptype" command.
591 Hence the "-1" below. */
592 whatis_exp (exp, -1);
593}
594
595/* TYPENAME is either the name of a type, or an expression. */
596
597static void
598ptype_command (const char *type_name, int from_tty)
599{
600 whatis_exp (type_name, 1);
601}
602
603/* Print integral scalar data VAL, of type TYPE, onto stdio stream STREAM.
604 Used to print data from type structures in a specified type. For example,
605 array bounds may be characters or booleans in some languages, and this
606 allows the ranges to be printed in their "natural" form rather than as
607 decimal integer values.
608
609 FIXME: This is here simply because only the type printing routines
610 currently use it, and it wasn't clear if it really belonged somewhere
611 else (like printcmd.c). There are a lot of other gdb routines that do
612 something similar, but they are generally concerned with printing values
613 that come from the inferior in target byte order and target size. */
614
615void
616print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
617{
618 unsigned int i;
619 unsigned len;
620
622
623 switch (type->code ())
624 {
625
626 case TYPE_CODE_ENUM:
627 len = type->num_fields ();
628 for (i = 0; i < len; i++)
629 {
630 if (type->field (i).loc_enumval () == val)
631 {
632 break;
633 }
634 }
635 if (i < len)
636 {
637 gdb_puts (type->field (i).name (), stream);
638 }
639 else
640 {
641 print_longest (stream, 'd', 0, val);
642 }
643 break;
644
645 case TYPE_CODE_INT:
646 print_longest (stream, type->is_unsigned () ? 'u' : 'd', 0, val);
647 break;
648
649 case TYPE_CODE_CHAR:
650 current_language->printchar ((unsigned char) val, type, stream);
651 break;
652
653 case TYPE_CODE_BOOL:
654 gdb_printf (stream, val ? "TRUE" : "FALSE");
655 break;
656
657 case TYPE_CODE_RANGE:
658 print_type_scalar (type->target_type (), val, stream);
659 return;
660
661 case TYPE_CODE_FIXED_POINT:
663 break;
664
665 case TYPE_CODE_UNDEF:
666 case TYPE_CODE_PTR:
667 case TYPE_CODE_ARRAY:
668 case TYPE_CODE_STRUCT:
669 case TYPE_CODE_UNION:
670 case TYPE_CODE_FUNC:
671 case TYPE_CODE_FLT:
672 case TYPE_CODE_VOID:
673 case TYPE_CODE_SET:
674 case TYPE_CODE_STRING:
675 case TYPE_CODE_ERROR:
676 case TYPE_CODE_MEMBERPTR:
677 case TYPE_CODE_METHODPTR:
678 case TYPE_CODE_METHOD:
679 case TYPE_CODE_REF:
680 case TYPE_CODE_RVALUE_REF:
681 case TYPE_CODE_NAMESPACE:
682 error (_("internal error: unhandled type in print_type_scalar"));
683 break;
684
685 default:
686 error (_("Invalid type code in symbol table."));
687 }
688}
689
690/* See typeprint.h. */
691
692void
693print_type_fixed_point (struct type *type, struct ui_file *stream)
694{
695 std::string small_img = type->fixed_point_scaling_factor ().str ();
696
697 gdb_printf (stream, "%s-byte fixed point (small = %s)",
698 pulongest (type->length ()), small_img.c_str ());
699}
700
701/* Dump details of a type specified either directly or indirectly.
702 Uses the same sort of type lookup mechanism as ptype_command()
703 and whatis_command(). */
704
705void
706maintenance_print_type (const char *type_name, int from_tty)
707{
708 if (type_name != NULL)
709 {
710 expression_up expr = parse_expression (type_name);
711 struct value *val = expr->evaluate_type ();
712 struct type *type = val->type ();
713
714 if (type != nullptr)
716 }
717}
718
719
721
723
724static bool print_methods = true;
725
726static void
727set_print_type_methods (const char *args,
728 int from_tty, struct cmd_list_element *c)
729{
731}
732
733static void
734show_print_type_methods (struct ui_file *file, int from_tty,
735 struct cmd_list_element *c, const char *value)
736{
737 gdb_printf (file, _("Printing of methods defined in a class in %s\n"),
738 value);
739}
740
741static bool print_typedefs = true;
742
743static void
744set_print_type_typedefs (const char *args,
745 int from_tty, struct cmd_list_element *c)
746{
748}
749
750static void
751show_print_type_typedefs (struct ui_file *file, int from_tty,
752 struct cmd_list_element *c, const char *value)
753{
754 gdb_printf (file, _("Printing of typedefs defined in a class in %s\n"),
755 value);
756}
757
758/* Limit on the number of nested type definitions to print or -1 to print
759 all nested type definitions in a class. By default, we do not print
760 nested definitions. */
761
763
764/* Set how many nested type definitions should be printed by the type
765 printer. */
766
767static void
773
774/* Show how many nested type definitions the type printer will print. */
775
776static void
777show_print_type_nested_types (struct ui_file *file, int from_tty,
778 struct cmd_list_element *c, const char *value)
779{
780 if (*value == '0')
781 {
782 gdb_printf (file,
783 _("Will not print nested types defined in a class\n"));
784 }
785 else
786 {
787 gdb_printf (file,
788 _("Will print %s nested types defined in a class\n"),
789 value);
790 }
791}
792
793/* When printing structs, offsets and sizes of members can be displayed using
794 decimal notation or hexadecimal notation. By default, Decimal notation is
795 used. */
796
798
799/* Set the flags that instructs if sizes and offsets of struct members are
800 displayed in hexadecimal or decimal notation. */
801
802static void
808
809/* Display whether struct members sizes and offsets are printed
810 using decimal or hexadecimal notation. */
811
812static void
814 struct cmd_list_element *c,
815 const char *value)
816{
817 gdb_printf (file, _("\
818Display of struct members offsets and sizes in hexadecimal is %s\n"),
819 value);
820}
821
823void
825{
826 struct cmd_list_element *c;
827
828 c = add_com ("ptype", class_vars, ptype_command, _("\
829Print definition of type TYPE.\n\
830Usage: ptype[/FLAGS] TYPE | EXPRESSION\n\
831Argument may be any type (for example a type name defined by typedef,\n\
832or \"struct STRUCT-TAG\" or \"class CLASS-NAME\" or \"union UNION-TAG\"\n\
833or \"enum ENUM-TAG\") or an expression.\n\
834The selected stack frame's lexical context is used to look up the name.\n\
835Contrary to \"whatis\", \"ptype\" always unrolls any typedefs.\n\
836\n\
837Available FLAGS are:\n\
838 /r print in \"raw\" form; do not substitute typedefs\n\
839 /m do not print methods defined in a class\n\
840 /M print methods defined in a class\n\
841 /t do not print typedefs defined in a class\n\
842 /T print typedefs defined in a class\n\
843 /o print offsets and sizes of fields in a struct (like pahole)\n\
844 /x use hexadecimal notation when displaying sizes and offsets\n\
845 of struct members\n\
846 /d use decimal notation when displaying sizes and offsets\n\
847 of struct members "));
849
850 c = add_com ("whatis", class_vars, whatis_command,
851 _("Print data type of expression EXP.\n\
852Only one level of typedefs is unrolled. See also \"ptype\"."));
854
856 _("Generic command for showing type-printing settings."),
857 _("Generic command for setting how types print."),
860
862 _("\
863Set printing of methods defined in classes."), _("\
864Show printing of methods defined in classes."), NULL,
869 _("\
870Set printing of typedefs defined in classes."), _("\
871Show printing of typedefs defined in classes."), NULL,
875
876 add_setshow_zuinteger_unlimited_cmd ("nested-type-limit", no_class,
878 _("\
879Set the number of recursive nested type definitions to print \
880(\"unlimited\" or -1 to show all)."), _("\
881Show the number of recursive nested type definitions to print."), NULL,
885
887 _("\
888Set printing of struct members sizes and offsets using hex notation."), _("\
889Show whether sizes and offsets of struct members are printed using hex \
890notation."), nullptr, set_print_offsets_and_sizes_in_hex,
893}
894
895/* Print <not allocated> status to stream STREAM. */
896
897void
899{
900 fprintf_styled (stream, metadata_style.style (), _("<not allocated>"));
901}
902
903/* Print <not associated> status to stream STREAM. */
904
905void
907{
908 fprintf_styled (stream, metadata_style.style (), _("<not associated>"));
909}
void xfree(void *)
void * xcalloc(size_t number, size_t size)
Definition alloc.c:85
ui_file_style style() const
Definition cli-style.c:169
std::string release()
Definition ui-file.h:204
auto_obstack m_storage
Definition typeprint.h:157
void add_template_parameters(struct type *t)
Definition typeprint.c:247
static const char * find_global_typedef(const struct type_print_options *flags, struct type *t)
Definition typeprint.c:309
static const char * find_typedef(const struct type_print_options *flags, struct type *t)
Definition typeprint.c:349
void recursively_update(struct type *)
Definition typeprint.c:222
struct cmd_list_element * showprintlist
Definition cli-cmds.c:163
struct cmd_list_element * setprintlist
Definition cli-cmds.c:161
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition cli-decode.c:117
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_zuinteger_unlimited_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:428
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:809
cli_style_option highlight_style
cli_style_option metadata_style
@ class_vars
Definition command.h:55
@ no_class
Definition command.h:53
void expression_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition completer.c:1092
struct type * value_rtti_type(struct value *v, int *full, LONGEST *top, int *using_enc)
Definition cp-abi.c:108
std::unique_ptr< expression > expression_up
Definition expression.h:241
expression_up parse_expression(const char *, innermost_block_tracker *=nullptr, parser_flags flags=0)
Definition parse.c:458
gdb::unique_xmalloc_ptr< char > apply_ext_lang_type_printers(struct ext_lang_type_printers *printers, struct type *type)
Definition extension.c:422
int is_dynamic_type(struct type *type)
Definition gdbtypes.c:2140
bool types_equal(struct type *a, struct type *b)
Definition gdbtypes.c:4114
void recursive_dump_type(struct type *type, int spaces)
Definition gdbtypes.c:5103
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
#define TYPE_SAFE_NAME(type)
Definition gdbtypes.h:2060
#define TYPE_BASECLASS(thistype, index)
Definition gdbtypes.h:1946
@ TYPE_CODE_UNDEF
Definition gdbtypes.h:83
#define TYPE_N_TEMPLATE_ARGUMENTS(thistype)
Definition gdbtypes.h:1993
#define TYPE_TEMPLATE_ARGUMENT(thistype, n)
Definition gdbtypes.h:1997
#define TYPE_TYPEDEF_FIELD(thistype, n)
Definition gdbtypes.h:2021
#define TYPE_TYPEDEF_FIELD_COUNT(thistype)
Definition gdbtypes.h:2027
#define TYPE_N_BASECLASSES(thistype)
Definition gdbtypes.h:1947
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition gnu-nat.c:1861
const struct language_defn * current_language
Definition language.c:82
Definition ada-exp.h:87
enum var_types type
Definition scm-param.c:142
const char * name
Definition gdbtypes.h:1607
struct type * type
Definition gdbtypes.h:1611
LONGEST loc_bitpos() const
Definition gdbtypes.h:611
LONGEST loc_enumval() const
Definition gdbtypes.h:623
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
std::string str() const
Definition gmp-utils.h:508
virtual bool can_print_type_offsets() const
Definition language.h:456
virtual void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const =0
virtual void printchar(int ch, struct type *chtype, struct ui_file *stream) const
Definition c-lang.c:158
virtual void print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream) const
Definition language.c:614
void update(struct type *type, unsigned int field_idx, struct ui_file *stream)
Definition typeprint.c:125
static const int indentation
Definition typeprint.h:100
void finish(struct type *type, int level, struct ui_file *stream)
Definition typeprint.c:184
unsigned int offset_bitpos
Definition typeprint.h:72
print_offset_data(const struct type_print_options *flags)
Definition typeprint.c:77
void maybe_print_hole(struct ui_file *stream, unsigned int bitpos, const char *for_what)
Definition typeprint.c:86
unsigned int end_bitpos
Definition typeprint.h:77
unsigned int print_in_hex
Definition typeprint.h:44
unsigned int print_methods
Definition typeprint.h:35
unsigned int print_typedefs
Definition typeprint.h:38
unsigned int raw
Definition typeprint.h:32
int print_nested_type_limit
Definition typeprint.h:47
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
bool is_unsigned() const
Definition gdbtypes.h:1100
unsigned int num_fields() const
Definition gdbtypes.h:994
const gdb_mpq & fixed_point_scaling_factor()
Definition gdbtypes.c:5888
bool is_pointer_or_reference() const
Definition gdbtypes.h:1431
Definition value.h:130
struct type * type() const
Definition value.h:180
@ LOC_TYPEDEF
Definition symtab.h:1018
static void set_print_offsets_and_sizes_in_hex(const char *args, int from_tty, struct cmd_list_element *c)
Definition typeprint.c:803
static struct type_print_options default_ptype_flags
Definition typeprint.c:56
void val_print_not_allocated(struct ui_file *stream)
Definition typeprint.c:898
void print_type_fixed_point(struct type *type, struct ui_file *stream)
Definition typeprint.c:693
static int eq_typedef_field(const void *a, const void *b)
Definition typeprint.c:211
void maintenance_print_type(const char *type_name, int from_tty)
Definition typeprint.c:706
struct cmd_list_element * showprinttypelist
Definition typeprint.c:722
void print_type_scalar(struct type *type, LONGEST val, struct ui_file *stream)
Definition typeprint.c:616
static void show_print_type_methods(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition typeprint.c:734
static void set_print_type_typedefs(const char *args, int from_tty, struct cmd_list_element *c)
Definition typeprint.c:744
static void set_print_type_nested_types(const char *args, int from_tty, struct cmd_list_element *c)
Definition typeprint.c:768
static int copy_typedef_hash_element(void **slot, void *nt)
Definition typeprint.c:281
const struct type_print_options type_print_raw_options
Definition typeprint.c:41
static void whatis_command(const char *exp, int from_tty)
Definition typeprint.c:587
std::string type_to_string(struct type *type)
Definition typeprint.c:399
static void show_print_type_nested_types(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition typeprint.c:777
static void ptype_command(const char *type_name, int from_tty)
Definition typeprint.c:598
static bool print_offsets_and_sizes_in_hex
Definition typeprint.c:797
static void whatis_exp(const char *exp, int show)
Definition typeprint.c:437
static void show_print_offsets_and_sizes_in_hex(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition typeprint.c:813
void val_print_not_associated(struct ui_file *stream)
Definition typeprint.c:906
static hashval_t hash_typedef_field(const void *p)
Definition typeprint.c:201
static bool print_typedefs
Definition typeprint.c:741
static int print_nested_type_limit
Definition typeprint.c:762
static void show_print_type_typedefs(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition typeprint.c:751
void type_print(struct type *type, const char *varstring, struct ui_file *stream, int show)
Definition typeprint.c:388
void _initialize_typeprint()
Definition typeprint.c:824
void error_unknown_type(const char *sym_print_name)
Definition typeprint.c:427
static bool print_methods
Definition typeprint.c:724
void typedef_print(struct type *type, struct symbol *newobj, struct ui_file *stream)
Definition typeprint.c:375
static void set_print_type_methods(const char *args, int from_tty, struct cmd_list_element *c)
Definition typeprint.c:727
struct cmd_list_element * setprinttypelist
Definition typeprint.c:720
void type_print_unknown_return_type(struct ui_file *stream)
Definition typeprint.c:418
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 gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1809
#define gdb_stdout
Definition utils.h:182
struct type * value_rtti_indirect_type(struct value *v, int *full, LONGEST *top, int *using_enc)
Definition valops.c:3849
void get_user_print_options(struct value_print_options *opts)
Definition valprint.c:135
void print_longest(struct ui_file *stream, int format, int use_c_format, LONGEST val_long)
Definition valprint.c:1335
struct value * access_value_history(int num)
Definition value.c:1709