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