PR 9167
[platform/upstream/binutils.git] / gdb / cp-valprint.c
1 /* Support for printing C++ values for GDB, the GNU debugger.
2
3    Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
4    2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010
5    Free Software Foundation, Inc.
6
7    This file is part of GDB.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
22 #include "defs.h"
23 #include "gdb_obstack.h"
24 #include "symtab.h"
25 #include "gdbtypes.h"
26 #include "expression.h"
27 #include "value.h"
28 #include "command.h"
29 #include "gdbcmd.h"
30 #include "demangle.h"
31 #include "annotate.h"
32 #include "gdb_string.h"
33 #include "c-lang.h"
34 #include "target.h"
35 #include "cp-abi.h"
36 #include "valprint.h"
37 #include "cp-support.h"
38 #include "language.h"
39 #include "python/python.h"
40
41 /* Controls printing of vtbl's */
42 static void
43 show_vtblprint (struct ui_file *file, int from_tty,
44                 struct cmd_list_element *c, const char *value)
45 {
46   fprintf_filtered (file, _("\
47 Printing of C++ virtual function tables is %s.\n"),
48                     value);
49 }
50
51 /* Controls looking up an object's derived type using what we find in
52    its vtables.  */
53 static void
54 show_objectprint (struct ui_file *file, int from_tty,
55                   struct cmd_list_element *c,
56                   const char *value)
57 {
58   fprintf_filtered (file, _("\
59 Printing of object's derived type based on vtable info is %s.\n"),
60                     value);
61 }
62
63 static void
64 show_static_field_print (struct ui_file *file, int from_tty,
65                          struct cmd_list_element *c, const char *value)
66 {
67   fprintf_filtered (file, _("Printing of C++ static members is %s.\n"),
68                     value);
69 }
70
71
72 static struct obstack dont_print_vb_obstack;
73 static struct obstack dont_print_statmem_obstack;
74 static struct obstack dont_print_stat_array_obstack;
75
76 extern void _initialize_cp_valprint (void);
77
78 static void cp_print_static_field (struct type *, struct value *,
79                                    struct ui_file *, int,
80                                    const struct value_print_options *);
81
82 static void cp_print_value (struct type *, struct type *, const gdb_byte *,
83                             int, CORE_ADDR, struct ui_file *, int,
84                             const struct value_print_options *, struct type **);
85
86
87 /* GCC versions after 2.4.5 use this.  */
88 const char vtbl_ptr_name[] = "__vtbl_ptr_type";
89
90 /* Return truth value for assertion that TYPE is of the type
91    "pointer to virtual function".  */
92
93 int
94 cp_is_vtbl_ptr_type (struct type *type)
95 {
96   char *typename = type_name_no_tag (type);
97
98   return (typename != NULL && !strcmp (typename, vtbl_ptr_name));
99 }
100
101 /* Return truth value for the assertion that TYPE is of the type
102    "pointer to virtual function table".  */
103
104 int
105 cp_is_vtbl_member (struct type *type)
106 {
107   /* With older versions of g++, the vtbl field pointed to an array
108      of structures.  Nowadays it points directly to the structure. */
109   if (TYPE_CODE (type) == TYPE_CODE_PTR)
110     {
111       type = TYPE_TARGET_TYPE (type);
112       if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
113         {
114           type = TYPE_TARGET_TYPE (type);
115           if (TYPE_CODE (type) == TYPE_CODE_STRUCT      /* if not using thunks */
116               || TYPE_CODE (type) == TYPE_CODE_PTR)     /* if using thunks */
117             {
118               /* Virtual functions tables are full of pointers
119                  to virtual functions. */
120               return cp_is_vtbl_ptr_type (type);
121             }
122         }
123       else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)  /* if not using thunks */
124         {
125           return cp_is_vtbl_ptr_type (type);
126         }
127       else if (TYPE_CODE (type) == TYPE_CODE_PTR)     /* if using thunks */
128         {
129           /* The type name of the thunk pointer is NULL when using dwarf2.
130              We could test for a pointer to a function, but there is
131              no type info for the virtual table either, so it wont help.  */
132           return cp_is_vtbl_ptr_type (type);
133         }
134     }
135   return 0;
136 }
137
138 /* Mutually recursive subroutines of cp_print_value and c_val_print to
139    print out a structure's fields: cp_print_value_fields and cp_print_value.
140
141    TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
142    same meanings as in cp_print_value and c_val_print.
143
144    2nd argument REAL_TYPE is used to carry over the type of the derived
145    class across the recursion to base classes. 
146
147    DONT_PRINT is an array of baseclass types that we
148    should not print, or zero if called from top level.  */
149
150 void
151 cp_print_value_fields (struct type *type, struct type *real_type,
152                        const gdb_byte *valaddr, int offset, CORE_ADDR address,
153                        struct ui_file *stream, int recurse,
154                        const struct value_print_options *options,
155                        struct type **dont_print_vb, int dont_print_statmem)
156 {
157   int i, len, n_baseclasses;
158   int fields_seen = 0;
159   static int last_set_recurse = -1;
160
161   CHECK_TYPEDEF (type);
162   
163   if (recurse == 0)
164     {
165       if (obstack_object_size (&dont_print_statmem_obstack) > 0)
166         obstack_free (&dont_print_statmem_obstack, NULL);
167       if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
168         obstack_free (&dont_print_stat_array_obstack, NULL);
169     }
170
171   fprintf_filtered (stream, "{");
172   len = TYPE_NFIELDS (type);
173   n_baseclasses = TYPE_N_BASECLASSES (type);
174
175   /* First, print out baseclasses such that we don't print
176      duplicates of virtual baseclasses.  */
177
178   if (n_baseclasses > 0)
179     cp_print_value (type, real_type, valaddr, offset, address, stream,
180                     recurse + 1, options, dont_print_vb);
181
182   /* Second, print out data fields */
183
184   /* If there are no data fields, skip this part */
185   if (len == n_baseclasses || !len)
186     fprintf_filtered (stream, "<No data fields>");
187   else
188     {
189       int obstack_initial_size = 0;
190       void *stat_array_obstack_top = NULL;
191       
192       if (dont_print_statmem == 0)
193         {
194           obstack_initial_size =
195             obstack_object_size (&dont_print_statmem_obstack);
196
197           if (last_set_recurse != recurse)
198             {
199               stat_array_obstack_top
200                 = obstack_next_free (&dont_print_stat_array_obstack);
201               last_set_recurse = recurse;
202             }
203         }
204
205       for (i = n_baseclasses; i < len; i++)
206         {
207           /* If requested, skip printing of static fields.  */
208           if (!options->static_field_print
209               && field_is_static (&TYPE_FIELD (type, i)))
210             continue;
211
212           if (fields_seen)
213             fprintf_filtered (stream, ", ");
214           else if (n_baseclasses > 0)
215             {
216               if (options->pretty)
217                 {
218                   fprintf_filtered (stream, "\n");
219                   print_spaces_filtered (2 + 2 * recurse, stream);
220                   fputs_filtered ("members of ", stream);
221                   fputs_filtered (type_name_no_tag (type), stream);
222                   fputs_filtered (": ", stream);
223                 }
224             }
225           fields_seen = 1;
226
227           if (options->pretty)
228             {
229               fprintf_filtered (stream, "\n");
230               print_spaces_filtered (2 + 2 * recurse, stream);
231             }
232           else
233             {
234               wrap_here (n_spaces (2 + 2 * recurse));
235             }
236           if (options->inspect_it)
237             {
238               if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
239                 fputs_filtered ("\"( ptr \"", stream);
240               else
241                 fputs_filtered ("\"( nodef \"", stream);
242               if (field_is_static (&TYPE_FIELD (type, i)))
243                 fputs_filtered ("static ", stream);
244               fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
245                                        current_language->la_language,
246                                        DMGL_PARAMS | DMGL_ANSI);
247               fputs_filtered ("\" \"", stream);
248               fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
249                                        current_language->la_language,
250                                        DMGL_PARAMS | DMGL_ANSI);
251               fputs_filtered ("\") \"", stream);
252             }
253           else
254             {
255               annotate_field_begin (TYPE_FIELD_TYPE (type, i));
256
257               if (field_is_static (&TYPE_FIELD (type, i)))
258                 fputs_filtered ("static ", stream);
259               fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
260                                        current_language->la_language,
261                                        DMGL_PARAMS | DMGL_ANSI);
262               annotate_field_name_end ();
263               /* do not print leading '=' in case of anonymous unions */
264               if (strcmp (TYPE_FIELD_NAME (type, i), ""))
265                 fputs_filtered (" = ", stream);
266               annotate_field_value ();
267             }
268
269           if (!field_is_static (&TYPE_FIELD (type, i))
270               && TYPE_FIELD_PACKED (type, i))
271             {
272               struct value *v;
273
274               /* Bitfields require special handling, especially due to byte
275                  order problems.  */
276               if (TYPE_FIELD_IGNORE (type, i))
277                 {
278                   fputs_filtered ("<optimized out or zero length>", stream);
279                 }
280               else
281                 {
282                   struct value_print_options opts = *options;
283                   opts.deref_ref = 0;
284                   v = value_from_longest
285                     (TYPE_FIELD_TYPE (type, i), 
286                      unpack_field_as_long (type, valaddr + offset, i));
287
288                   common_val_print (v, stream, recurse + 1, &opts,
289                                     current_language);
290                 }
291             }
292           else
293             {
294               if (TYPE_FIELD_IGNORE (type, i))
295                 {
296                   fputs_filtered ("<optimized out or zero length>", stream);
297                 }
298               else if (field_is_static (&TYPE_FIELD (type, i)))
299                 {
300                   struct value *v = value_static_field (type, i);
301                   if (v == NULL)
302                     fputs_filtered ("<optimized out>", stream);
303                   else
304                     cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
305                                            stream, recurse + 1, options);
306                 }
307               else
308                 {
309                   struct value_print_options opts = *options;
310                   opts.deref_ref = 0;
311                   val_print (TYPE_FIELD_TYPE (type, i),
312                              valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
313                              address,
314                              stream, recurse + 1, &opts,
315                              current_language);
316                 }
317             }
318           annotate_field_end ();
319         }
320
321       if (dont_print_statmem == 0)
322         {
323           int obstack_final_size =
324            obstack_object_size (&dont_print_statmem_obstack);
325
326           if (obstack_final_size > obstack_initial_size) {
327             /* In effect, a pop of the printed-statics stack.  */
328
329             void *free_to_ptr =
330               obstack_next_free (&dont_print_statmem_obstack) -
331               (obstack_final_size - obstack_initial_size);
332
333             obstack_free (&dont_print_statmem_obstack,
334                           free_to_ptr);
335           }
336
337           if (last_set_recurse != recurse)
338             {
339               if (obstack_object_size (&dont_print_stat_array_obstack) > 0) 
340                 obstack_free (&dont_print_stat_array_obstack,
341                               stat_array_obstack_top);
342               last_set_recurse = -1;
343             }
344         }
345
346       if (options->pretty)
347         {
348           fprintf_filtered (stream, "\n");
349           print_spaces_filtered (2 * recurse, stream);
350         }
351     }                           /* if there are data fields */
352
353   fprintf_filtered (stream, "}");
354 }
355
356 /* Like cp_print_value_fields, but find the runtime type of the object
357    and pass it as the `real_type' argument to cp_print_value_fields.
358    This function is a hack to work around the fact that
359    common_val_print passes the embedded offset to val_print, but not
360    the enclosing type.  */
361
362 void
363 cp_print_value_fields_rtti (struct type *type,
364                             const gdb_byte *valaddr, int offset,
365                             CORE_ADDR address,
366                             struct ui_file *stream, int recurse,
367                             const struct value_print_options *options,
368                             struct type **dont_print_vb, int dont_print_statmem)
369 {
370   struct value *value;
371   int full, top, using_enc;
372   struct type *real_type;
373
374   /* Ugh, we have to convert back to a value here.  */
375   value = value_from_contents_and_address (type, valaddr + offset,
376                                            address + offset);
377   /* We don't actually care about most of the result here -- just the
378      type.  We already have the correct offset, due to how val_print
379      was initially called.  */
380   real_type = value_rtti_type (value, &full, &top, &using_enc);
381   if (!real_type)
382     real_type = type;
383
384   cp_print_value_fields (type, real_type, valaddr, offset,
385                          address, stream, recurse, options,
386                          dont_print_vb, dont_print_statmem);
387 }
388
389 /* Special val_print routine to avoid printing multiple copies of virtual
390    baseclasses.  */
391
392 static void
393 cp_print_value (struct type *type, struct type *real_type,
394                 const gdb_byte *valaddr, int offset, CORE_ADDR address,
395                 struct ui_file *stream, int recurse,
396                 const struct value_print_options *options,
397                 struct type **dont_print_vb)
398 {
399   struct type **last_dont_print
400     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
401   struct obstack tmp_obstack = dont_print_vb_obstack;
402   int i, n_baseclasses = TYPE_N_BASECLASSES (type);
403   int thisoffset;
404   struct type *thistype;
405
406   if (dont_print_vb == 0)
407     {
408       /* If we're at top level, carve out a completely fresh
409          chunk of the obstack and use that until this particular
410          invocation returns.  */
411       /* Bump up the high-water mark.  Now alpha is omega.  */
412       obstack_finish (&dont_print_vb_obstack);
413     }
414
415   for (i = 0; i < n_baseclasses; i++)
416     {
417       int boffset;
418       int skip;
419       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
420       char *basename = TYPE_NAME (baseclass);
421       const gdb_byte *base_valaddr;
422
423       if (BASETYPE_VIA_VIRTUAL (type, i))
424         {
425           struct type **first_dont_print
426             = (struct type **) obstack_base (&dont_print_vb_obstack);
427
428           int j = (struct type **) obstack_next_free (&dont_print_vb_obstack)
429             - first_dont_print;
430
431           while (--j >= 0)
432             if (baseclass == first_dont_print[j])
433               goto flush_it;
434
435           obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
436         }
437
438       thisoffset = offset;
439       thistype = real_type;
440
441       boffset = baseclass_offset (type, i, valaddr + offset, address + offset);
442       skip = ((boffset == -1) || (boffset + offset) < 0) ? 1 : -1;
443
444       if (BASETYPE_VIA_VIRTUAL (type, i))
445         {
446           /* The virtual base class pointer might have been
447              clobbered by the user program. Make sure that it
448              still points to a valid memory location.  */
449
450           if (boffset != -1
451               && ((boffset + offset) < 0
452                   || (boffset + offset) >= TYPE_LENGTH (real_type)))
453             {
454               /* FIXME (alloca): unsafe if baseclass is really really large. */
455               gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
456               base_valaddr = buf;
457               if (target_read_memory (address + boffset, buf,
458                                       TYPE_LENGTH (baseclass)) != 0)
459                 skip = 1;
460               address = address + boffset;
461               thisoffset = 0;
462               boffset = 0;
463               thistype = baseclass;
464             }
465           else
466             base_valaddr = valaddr;
467         }
468       else
469         base_valaddr = valaddr;
470
471       /* now do the printing */
472       if (options->pretty)
473         {
474           fprintf_filtered (stream, "\n");
475           print_spaces_filtered (2 * recurse, stream);
476         }
477       fputs_filtered ("<", stream);
478       /* Not sure what the best notation is in the case where there is no
479          baseclass name.  */
480       fputs_filtered (basename ? basename : "", stream);
481       fputs_filtered ("> = ", stream);
482
483
484       if (skip >= 1)
485         fprintf_filtered (stream, "<invalid address>");
486       else
487         {
488           int result = 0;
489
490           /* Attempt to run the Python pretty-printers on the
491              baseclass if possible.  */
492           if (!options->raw)
493             result = apply_val_pretty_printer (baseclass, base_valaddr,
494                                                thisoffset + boffset,
495                                                address,
496                                                stream, recurse,
497                                                options,
498                                                current_language);
499                   
500           if (!result)
501             cp_print_value_fields (baseclass, thistype, base_valaddr,
502                                    thisoffset + boffset, address,
503                                    stream, recurse, options,
504                                    ((struct type **)
505                                     obstack_base (&dont_print_vb_obstack)),
506                                    0);
507         }
508       fputs_filtered (", ", stream);
509
510     flush_it:
511       ;
512     }
513
514   if (dont_print_vb == 0)
515     {
516       /* Free the space used to deal with the printing
517          of this type from top level.  */
518       obstack_free (&dont_print_vb_obstack, last_dont_print);
519       /* Reset watermark so that we can continue protecting
520          ourselves from whatever we were protecting ourselves.  */
521       dont_print_vb_obstack = tmp_obstack;
522     }
523 }
524
525 /* Print value of a static member.
526    To avoid infinite recursion when printing a class that contains
527    a static instance of the class, we keep the addresses of all printed
528    static member classes in an obstack and refuse to print them more
529    than once.
530
531    VAL contains the value to print, TYPE, STREAM, RECURSE, and OPTIONS
532    have the same meanings as in c_val_print.  */
533
534 static void
535 cp_print_static_field (struct type *type,
536                        struct value *val,
537                        struct ui_file *stream,
538                        int recurse,
539                        const struct value_print_options *options)
540 {
541   struct value_print_options opts;
542   
543   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
544     {
545       CORE_ADDR *first_dont_print;
546       CORE_ADDR addr;
547       int i;
548
549       first_dont_print
550         = (CORE_ADDR *) obstack_base (&dont_print_statmem_obstack);
551       i = obstack_object_size (&dont_print_statmem_obstack)
552         / sizeof (CORE_ADDR);
553
554       while (--i >= 0)
555         {
556           if (value_address (val) == first_dont_print[i])
557             {
558               fputs_filtered ("<same as static member of an already"
559                               " seen type>",
560                               stream);
561               return;
562             }
563         }
564
565       addr = value_address (val);
566       obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
567                     sizeof (CORE_ADDR));
568       CHECK_TYPEDEF (type);
569       cp_print_value_fields (type, value_enclosing_type (val),
570                              value_contents_all (val),
571                              value_embedded_offset (val), addr,
572                              stream, recurse, options, NULL, 1);
573       return;
574     }
575
576   if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
577     {
578       struct type **first_dont_print;
579       int i;
580       struct type *target_type = TYPE_TARGET_TYPE (type);
581
582       first_dont_print
583         = (struct type **) obstack_base (&dont_print_stat_array_obstack);
584       i = obstack_object_size (&dont_print_stat_array_obstack)
585         / sizeof (CORE_ADDR);
586
587       while (--i >= 0)
588         {
589           if (target_type == first_dont_print[i])
590             {
591               fputs_filtered ("<same as static member of an already"
592                               " seen type>",
593                               stream);
594               return;
595             }
596         }
597
598       obstack_grow (&dont_print_stat_array_obstack, (char *) &target_type,
599                     sizeof (struct type *));
600     }
601
602   opts = *options;
603   opts.deref_ref = 0;
604   val_print (type, value_contents_all (val), 
605              value_embedded_offset (val), value_address (val),
606              stream, recurse, &opts, current_language);
607 }
608
609
610 /* Find the field in *DOMAIN, or its non-virtual base classes, with bit offset
611    OFFSET.  Set *DOMAIN to the containing type and *FIELDNO to the containing
612    field number.  If OFFSET is not exactly at the start of some field, set
613    *DOMAIN to NULL.  */
614
615 static void
616 cp_find_class_member (struct type **domain_p, int *fieldno,
617                       LONGEST offset)
618 {
619   struct type *domain;
620   unsigned int i;
621   unsigned len;
622
623   *domain_p = check_typedef (*domain_p);
624   domain = *domain_p;
625   len = TYPE_NFIELDS (domain);
626
627   for (i = TYPE_N_BASECLASSES (domain); i < len; i++)
628     {
629       LONGEST bitpos = TYPE_FIELD_BITPOS (domain, i);
630
631       QUIT;
632       if (offset == bitpos)
633         {
634           *fieldno = i;
635           return;
636         }
637     }
638
639   for (i = 0; i < TYPE_N_BASECLASSES (domain); i++)
640     {
641       LONGEST bitpos = TYPE_FIELD_BITPOS (domain, i);
642       LONGEST bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (domain, i));
643
644       if (offset >= bitpos && offset < bitpos + bitsize)
645         {
646           *domain_p = TYPE_FIELD_TYPE (domain, i);
647           cp_find_class_member (domain_p, fieldno, offset - bitpos);
648           return;
649         }
650     }
651
652   *domain_p = NULL;
653 }
654
655 void
656 cp_print_class_member (const gdb_byte *valaddr, struct type *type,
657                        struct ui_file *stream, char *prefix)
658 {
659   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
660
661   /* VAL is a byte offset into the structure type DOMAIN.
662      Find the name of the field for that offset and
663      print it.  */
664   struct type *domain = TYPE_DOMAIN_TYPE (type);
665   LONGEST val;
666   unsigned int fieldno;
667
668   val = extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
669
670   /* Pointers to data members are usually byte offsets into an object.
671      Because a data member can have offset zero, and a NULL pointer to
672      member must be distinct from any valid non-NULL pointer to
673      member, either the value is biased or the NULL value has a
674      special representation; both are permitted by ISO C++.  HP aCC
675      used a bias of 0x20000000; HP cfront used a bias of 1; g++ 3.x
676      and other compilers which use the Itanium ABI use -1 as the NULL
677      value.  GDB only supports that last form; to add support for
678      another form, make this into a cp-abi hook.  */
679
680   if (val == -1)
681     {
682       fprintf_filtered (stream, "NULL");
683       return;
684     }
685
686   cp_find_class_member (&domain, &fieldno, val << 3);
687
688   if (domain != NULL)
689     {
690       char *name;
691       fputs_filtered (prefix, stream);
692       name = type_name_no_tag (domain);
693       if (name)
694         fputs_filtered (name, stream);
695       else
696         c_type_print_base (domain, stream, 0, 0);
697       fprintf_filtered (stream, "::");
698       fputs_filtered (TYPE_FIELD_NAME (domain, fieldno), stream);
699     }
700   else
701     fprintf_filtered (stream, "%ld", (long) val);
702 }
703
704
705 void
706 _initialize_cp_valprint (void)
707 {
708   add_setshow_boolean_cmd ("static-members", class_support,
709                            &user_print_options.static_field_print, _("\
710 Set printing of C++ static members."), _("\
711 Show printing of C++ static members."), NULL,
712                            NULL,
713                            show_static_field_print,
714                            &setprintlist, &showprintlist);
715
716   add_setshow_boolean_cmd ("vtbl", class_support,
717                            &user_print_options.vtblprint, _("\
718 Set printing of C++ virtual function tables."), _("\
719 Show printing of C++ virtual function tables."), NULL,
720                            NULL,
721                            show_vtblprint,
722                            &setprintlist, &showprintlist);
723
724   add_setshow_boolean_cmd ("object", class_support,
725                            &user_print_options.objectprint, _("\
726 Set printing of object's derived type based on vtable info."), _("\
727 Show printing of object's derived type based on vtable info."), NULL,
728                            NULL,
729                            show_objectprint,
730                            &setprintlist, &showprintlist);
731
732   obstack_begin (&dont_print_stat_array_obstack, 32 * sizeof (CORE_ADDR));
733   obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR));
734   obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
735 }