* valprint.c (val_print): Update.
[external/binutils.git] / gdb / c-valprint.c
1 /* Support for printing C values for GDB, the GNU debugger.
2
3    Copyright (C) 1986, 1988-1989, 1991-2001, 2003, 2005-2012 Free
4    Software Foundation, Inc.
5
6    This file is part of GDB.
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21 #include "defs.h"
22 #include "gdb_string.h"
23 #include "symtab.h"
24 #include "gdbtypes.h"
25 #include "expression.h"
26 #include "value.h"
27 #include "valprint.h"
28 #include "language.h"
29 #include "c-lang.h"
30 #include "cp-abi.h"
31 #include "target.h"
32 \f
33
34 /* A helper for c_textual_element_type.  This checks the name of the
35    typedef.  This is bogus but it isn't apparent that the compiler
36    provides us the help we may need.  */
37
38 static int
39 textual_name (const char *name)
40 {
41   return (!strcmp (name, "wchar_t")
42           || !strcmp (name, "char16_t")
43           || !strcmp (name, "char32_t"));
44 }
45
46 /* Apply a heuristic to decide whether an array of TYPE or a pointer
47    to TYPE should be printed as a textual string.  Return non-zero if
48    it should, or zero if it should be treated as an array of integers
49    or pointer to integers.  FORMAT is the current format letter, or 0
50    if none.
51
52    We guess that "char" is a character.  Explicitly signed and
53    unsigned character types are also characters.  Integer data from
54    vector types is not.  The user can override this by using the /s
55    format letter.  */
56
57 int
58 c_textual_element_type (struct type *type, char format)
59 {
60   struct type *true_type, *iter_type;
61
62   if (format != 0 && format != 's')
63     return 0;
64
65   /* We also rely on this for its side effect of setting up all the
66      typedef pointers.  */
67   true_type = check_typedef (type);
68
69   /* TYPE_CODE_CHAR is always textual.  */
70   if (TYPE_CODE (true_type) == TYPE_CODE_CHAR)
71     return 1;
72
73   /* Any other character-like types must be integral.  */
74   if (TYPE_CODE (true_type) != TYPE_CODE_INT)
75     return 0;
76
77   /* We peel typedefs one by one, looking for a match.  */
78   iter_type = type;
79   while (iter_type)
80     {
81       /* Check the name of the type.  */
82       if (TYPE_NAME (iter_type) && textual_name (TYPE_NAME (iter_type)))
83         return 1;
84
85       if (TYPE_CODE (iter_type) != TYPE_CODE_TYPEDEF)
86         break;
87
88       /* Peel a single typedef.  If the typedef doesn't have a target
89          type, we use check_typedef and hope the result is ok -- it
90          might be for C++, where wchar_t is a built-in type.  */
91       if (TYPE_TARGET_TYPE (iter_type))
92         iter_type = TYPE_TARGET_TYPE (iter_type);
93       else
94         iter_type = check_typedef (iter_type);
95     }
96
97   if (format == 's')
98     {
99       /* Print this as a string if we can manage it.  For now, no wide
100          character support.  */
101       if (TYPE_CODE (true_type) == TYPE_CODE_INT
102           && TYPE_LENGTH (true_type) == 1)
103         return 1;
104     }
105   else
106     {
107       /* If a one-byte TYPE_CODE_INT is missing the not-a-character
108          flag, then we treat it as text; otherwise, we assume it's
109          being used as data.  */
110       if (TYPE_CODE (true_type) == TYPE_CODE_INT
111           && TYPE_LENGTH (true_type) == 1
112           && !TYPE_NOTTEXT (true_type))
113         return 1;
114     }
115
116   return 0;
117 }
118
119 /* See val_print for a description of the various parameters of this
120    function; they are identical.  */
121
122 void
123 c_val_print (struct type *type, const gdb_byte *valaddr,
124              int embedded_offset, CORE_ADDR address,
125              struct ui_file *stream, int recurse,
126              const struct value *original_value,
127              const struct value_print_options *options)
128 {
129   struct gdbarch *gdbarch = get_type_arch (type);
130   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
131   unsigned int i = 0;   /* Number of characters printed.  */
132   unsigned len;
133   struct type *elttype, *unresolved_elttype;
134   struct type *unresolved_type = type;
135   unsigned eltlen;
136   LONGEST val;
137   CORE_ADDR addr;
138
139   CHECK_TYPEDEF (type);
140   switch (TYPE_CODE (type))
141     {
142     case TYPE_CODE_ARRAY:
143       unresolved_elttype = TYPE_TARGET_TYPE (type);
144       elttype = check_typedef (unresolved_elttype);
145       if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
146         {
147           LONGEST low_bound, high_bound;
148
149           if (!get_array_bounds (type, &low_bound, &high_bound))
150             error (_("Could not determine the array high bound"));
151
152           eltlen = TYPE_LENGTH (elttype);
153           len = high_bound - low_bound + 1;
154           if (options->prettyprint_arrays)
155             {
156               print_spaces_filtered (2 + 2 * recurse, stream);
157             }
158
159           /* Print arrays of textual chars with a string syntax, as
160              long as the entire array is valid.  */
161           if (c_textual_element_type (unresolved_elttype,
162                                       options->format)
163               && value_bytes_available (original_value, embedded_offset,
164                                         TYPE_LENGTH (type))
165               && value_bits_valid (original_value,
166                                    TARGET_CHAR_BIT * embedded_offset,
167                                    TARGET_CHAR_BIT * TYPE_LENGTH (type)))
168             {
169               /* If requested, look for the first null char and only
170                  print elements up to it.  */
171               if (options->stop_print_at_null)
172                 {
173                   unsigned int temp_len;
174
175                   for (temp_len = 0;
176                        (temp_len < len
177                         && temp_len < options->print_max
178                         && extract_unsigned_integer (valaddr + embedded_offset
179                                                      + temp_len * eltlen,
180                                                      eltlen, byte_order) != 0);
181                        ++temp_len)
182                     ;
183                   len = temp_len;
184                 }
185
186               LA_PRINT_STRING (stream, unresolved_elttype,
187                                valaddr + embedded_offset, len,
188                                NULL, 0, options);
189               i = len;
190             }
191           else
192             {
193               fprintf_filtered (stream, "{");
194               /* If this is a virtual function table, print the 0th
195                  entry specially, and the rest of the members
196                  normally.  */
197               if (cp_is_vtbl_ptr_type (elttype))
198                 {
199                   i = 1;
200                   fprintf_filtered (stream, _("%d vtable entries"),
201                                     len - 1);
202                 }
203               else
204                 {
205                   i = 0;
206                 }
207               val_print_array_elements (type, valaddr, embedded_offset,
208                                         address, stream,
209                                         recurse, original_value, options, i);
210               fprintf_filtered (stream, "}");
211             }
212           break;
213         }
214       /* Array of unspecified length: treat like pointer to first
215          elt.  */
216       addr = address + embedded_offset;
217       goto print_unpacked_pointer;
218
219     case TYPE_CODE_MEMBERPTR:
220       if (options->format)
221         {
222           val_print_scalar_formatted (type, valaddr, embedded_offset,
223                                       original_value, options, 0, stream);
224           break;
225         }
226       cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
227       break;
228
229     case TYPE_CODE_METHODPTR:
230       cplus_print_method_ptr (valaddr + embedded_offset, type, stream);
231       break;
232
233     case TYPE_CODE_PTR:
234       if (options->format && options->format != 's')
235         {
236           val_print_scalar_formatted (type, valaddr, embedded_offset,
237                                       original_value, options, 0, stream);
238           break;
239         }
240       if (options->vtblprint && cp_is_vtbl_ptr_type (type))
241         {
242           /* Print the unmangled name if desired.  */
243           /* Print vtable entry - we only get here if we ARE using
244              -fvtable_thunks.  (Otherwise, look under
245              TYPE_CODE_STRUCT.)  */
246           CORE_ADDR addr
247             = extract_typed_address (valaddr + embedded_offset, type);
248
249           print_function_pointer_address (gdbarch, addr, stream,
250                                           options->addressprint);
251           break;
252         }
253       unresolved_elttype = TYPE_TARGET_TYPE (type);
254       elttype = check_typedef (unresolved_elttype);
255         {
256           addr = unpack_pointer (type, valaddr + embedded_offset);
257         print_unpacked_pointer:
258
259           if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
260             {
261               /* Try to print what function it points to.  */
262               print_function_pointer_address (gdbarch, addr, stream,
263                                               options->addressprint);
264               return;
265             }
266
267           if (options->addressprint)
268             fputs_filtered (paddress (gdbarch, addr), stream);
269
270           /* For a pointer to a textual type, also print the string
271              pointed to, unless pointer is null.  */
272
273           if (c_textual_element_type (unresolved_elttype,
274                                       options->format)
275               && addr != 0)
276             {
277               i = val_print_string (unresolved_elttype, NULL,
278                                     addr, -1,
279                                     stream, options);
280             }
281           else if (cp_is_vtbl_member (type))
282             {
283               /* Print vtbl's nicely.  */
284               CORE_ADDR vt_address = unpack_pointer (type,
285                                                      valaddr
286                                                      + embedded_offset);
287
288               struct minimal_symbol *msymbol =
289               lookup_minimal_symbol_by_pc (vt_address);
290               if ((msymbol != NULL)
291                   && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
292                 {
293                   fputs_filtered (" <", stream);
294                   fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
295                   fputs_filtered (">", stream);
296                 }
297               if (vt_address && options->vtblprint)
298                 {
299                   struct value *vt_val;
300                   struct symbol *wsym = (struct symbol *) NULL;
301                   struct type *wtype;
302                   struct block *block = (struct block *) NULL;
303                   int is_this_fld;
304
305                   if (msymbol != NULL)
306                     wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol),
307                                           block, VAR_DOMAIN,
308                                           &is_this_fld);
309
310                   if (wsym)
311                     {
312                       wtype = SYMBOL_TYPE (wsym);
313                     }
314                   else
315                     {
316                       wtype = unresolved_elttype;
317                     }
318                   vt_val = value_at (wtype, vt_address);
319                   common_val_print (vt_val, stream, recurse + 1,
320                                     options, current_language);
321                   if (options->pretty)
322                     {
323                       fprintf_filtered (stream, "\n");
324                       print_spaces_filtered (2 + 2 * recurse, stream);
325                     }
326                 }
327             }
328           return;
329         }
330       break;
331
332     case TYPE_CODE_REF:
333       elttype = check_typedef (TYPE_TARGET_TYPE (type));
334       if (options->addressprint)
335         {
336           CORE_ADDR addr
337             = extract_typed_address (valaddr + embedded_offset, type);
338
339           fprintf_filtered (stream, "@");
340           fputs_filtered (paddress (gdbarch, addr), stream);
341           if (options->deref_ref)
342             fputs_filtered (": ", stream);
343         }
344       /* De-reference the reference.  */
345       if (options->deref_ref)
346         {
347           if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
348             {
349               struct value *deref_val;
350
351               deref_val = coerce_ref_if_computed (original_value);
352               if (deref_val != NULL)
353                 {
354                   /* More complicated computed references are not supported.  */
355                   gdb_assert (embedded_offset == 0);
356                 }
357               else
358                 deref_val = value_at (TYPE_TARGET_TYPE (type),
359                                       unpack_pointer (type,
360                                                       (valaddr
361                                                        + embedded_offset)));
362
363               common_val_print (deref_val, stream, recurse, options,
364                                 current_language);
365             }
366           else
367             fputs_filtered ("???", stream);
368         }
369       break;
370
371     case TYPE_CODE_UNION:
372       if (recurse && !options->unionprint)
373         {
374           fprintf_filtered (stream, "{...}");
375           break;
376         }
377       /* Fall through.  */
378     case TYPE_CODE_STRUCT:
379       /*FIXME: Abstract this away.  */
380       if (options->vtblprint && cp_is_vtbl_ptr_type (type))
381         {
382           /* Print the unmangled name if desired.  */
383           /* Print vtable entry - we only get here if NOT using
384              -fvtable_thunks.  (Otherwise, look under
385              TYPE_CODE_PTR.)  */
386           int offset = (embedded_offset
387                         + TYPE_FIELD_BITPOS (type,
388                                              VTBL_FNADDR_OFFSET) / 8);
389           struct type *field_type = TYPE_FIELD_TYPE (type,
390                                                      VTBL_FNADDR_OFFSET);
391           CORE_ADDR addr
392             = extract_typed_address (valaddr + offset, field_type);
393
394           print_function_pointer_address (gdbarch, addr, stream,
395                                           options->addressprint);
396         }
397       else
398         cp_print_value_fields_rtti (type, valaddr,
399                                     embedded_offset, address,
400                                     stream, recurse,
401                                     original_value, options,
402                                     NULL, 0);
403       break;
404
405     case TYPE_CODE_ENUM:
406       if (options->format)
407         {
408           val_print_scalar_formatted (type, valaddr, embedded_offset,
409                                       original_value, options, 0, stream);
410           break;
411         }
412       len = TYPE_NFIELDS (type);
413       val = unpack_long (type, valaddr + embedded_offset);
414       for (i = 0; i < len; i++)
415         {
416           QUIT;
417           if (val == TYPE_FIELD_BITPOS (type, i))
418             {
419               break;
420             }
421         }
422       if (i < len)
423         {
424           fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
425         }
426       else if (TYPE_FLAG_ENUM (type))
427         {
428           int first = 1;
429
430           /* We have a "flag" enum, so we try to decompose it into
431              pieces as appropriate.  A flag enum has disjoint
432              constants by definition.  */
433           fputs_filtered ("(", stream);
434           for (i = 0; i < len; ++i)
435             {
436               QUIT;
437
438               if ((val & TYPE_FIELD_BITPOS (type, i)) != 0)
439                 {
440                   if (!first)
441                     fputs_filtered (" | ", stream);
442                   first = 0;
443
444                   val &= ~TYPE_FIELD_BITPOS (type, i);
445                   fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
446                 }
447             }
448
449           if (first || val != 0)
450             {
451               if (!first)
452                 fputs_filtered (" | ", stream);
453               fputs_filtered ("unknown: ", stream);
454               print_longest (stream, 'd', 0, val);
455             }
456
457           fputs_filtered (")", stream);
458         }
459       else
460         print_longest (stream, 'd', 0, val);
461       break;
462
463     case TYPE_CODE_FLAGS:
464       if (options->format)
465         val_print_scalar_formatted (type, valaddr, embedded_offset,
466                                     original_value, options, 0, stream);
467       else
468         val_print_type_code_flags (type, valaddr + embedded_offset,
469                                    stream);
470       break;
471
472     case TYPE_CODE_FUNC:
473     case TYPE_CODE_METHOD:
474       if (options->format)
475         {
476           val_print_scalar_formatted (type, valaddr, embedded_offset,
477                                       original_value, options, 0, stream);
478           break;
479         }
480       /* FIXME, we should consider, at least for ANSI C language,
481          eliminating the distinction made between FUNCs and POINTERs
482          to FUNCs.  */
483       fprintf_filtered (stream, "{");
484       type_print (type, "", stream, -1);
485       fprintf_filtered (stream, "} ");
486       /* Try to print what function it points to, and its address.  */
487       print_address_demangle (gdbarch, address, stream, demangle);
488       break;
489
490     case TYPE_CODE_BOOL:
491       if (options->format || options->output_format)
492         {
493           struct value_print_options opts = *options;
494           opts.format = (options->format ? options->format
495                          : options->output_format);
496           val_print_scalar_formatted (type, valaddr, embedded_offset,
497                                       original_value, &opts, 0, stream);
498         }
499       else
500         {
501           val = unpack_long (type, valaddr + embedded_offset);
502           if (val == 0)
503             fputs_filtered ("false", stream);
504           else if (val == 1)
505             fputs_filtered ("true", stream);
506           else
507             print_longest (stream, 'd', 0, val);
508         }
509       break;
510
511     case TYPE_CODE_RANGE:
512       /* FIXME: create_range_type does not set the unsigned bit in a
513          range type (I think it probably should copy it from the
514          target type), so we won't print values which are too large to
515          fit in a signed integer correctly.  */
516       /* FIXME: Doesn't handle ranges of enums correctly.  (Can't just
517          print with the target type, though, because the size of our
518          type and the target type might differ).  */
519       /* FALLTHROUGH */
520
521     case TYPE_CODE_INT:
522       if (options->format || options->output_format)
523         {
524           struct value_print_options opts = *options;
525
526           opts.format = (options->format ? options->format
527                          : options->output_format);
528           val_print_scalar_formatted (type, valaddr, embedded_offset,
529                                       original_value, &opts, 0, stream);
530         }
531       else
532         {
533           val_print_type_code_int (type, valaddr + embedded_offset,
534                                    stream);
535           /* C and C++ has no single byte int type, char is used
536              instead.  Since we don't know whether the value is really
537              intended to be used as an integer or a character, print
538              the character equivalent as well.  */
539           if (c_textual_element_type (unresolved_type, options->format))
540             {
541               fputs_filtered (" ", stream);
542               LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset),
543                              unresolved_type, stream);
544             }
545         }
546       break;
547
548     case TYPE_CODE_CHAR:
549       if (options->format || options->output_format)
550         {
551           struct value_print_options opts = *options;
552           opts.format = (options->format ? options->format
553                          : options->output_format);
554           val_print_scalar_formatted (type, valaddr, embedded_offset,
555                                       original_value, &opts, 0, stream);
556         }
557       else
558         {
559           val = unpack_long (type, valaddr + embedded_offset);
560           if (TYPE_UNSIGNED (type))
561             fprintf_filtered (stream, "%u", (unsigned int) val);
562           else
563             fprintf_filtered (stream, "%d", (int) val);
564           fputs_filtered (" ", stream);
565           LA_PRINT_CHAR (val, unresolved_type, stream);
566         }
567       break;
568
569     case TYPE_CODE_FLT:
570       if (options->format)
571         {
572           val_print_scalar_formatted (type, valaddr, embedded_offset,
573                                       original_value, options, 0, stream);
574         }
575       else
576         {
577           print_floating (valaddr + embedded_offset, type, stream);
578         }
579       break;
580
581     case TYPE_CODE_DECFLOAT:
582       if (options->format)
583         val_print_scalar_formatted (type, valaddr, embedded_offset,
584                                     original_value, options, 0, stream);
585       else
586         print_decimal_floating (valaddr + embedded_offset,
587                                 type, stream);
588       break;
589
590     case TYPE_CODE_VOID:
591       fprintf_filtered (stream, "void");
592       break;
593
594     case TYPE_CODE_ERROR:
595       fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
596       break;
597
598     case TYPE_CODE_UNDEF:
599       /* This happens (without TYPE_FLAG_STUB set) on systems which
600          don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a
601          "struct foo *bar" and no complete type for struct foo in that
602          file.  */
603       fprintf_filtered (stream, _("<incomplete type>"));
604       break;
605
606     case TYPE_CODE_COMPLEX:
607       if (options->format)
608         val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
609                                     valaddr, embedded_offset,
610                                     original_value, options, 0, stream);
611       else
612         print_floating (valaddr + embedded_offset,
613                         TYPE_TARGET_TYPE (type),
614                         stream);
615       fprintf_filtered (stream, " + ");
616       if (options->format)
617         val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
618                                     valaddr,
619                                     embedded_offset
620                                     + TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
621                                     original_value,
622                                     options, 0, stream);
623       else
624         print_floating (valaddr + embedded_offset
625                         + TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
626                         TYPE_TARGET_TYPE (type),
627                         stream);
628       fprintf_filtered (stream, " * I");
629       break;
630
631     default:
632       error (_("Invalid C/C++ type code %d in symbol table."),
633              TYPE_CODE (type));
634     }
635   gdb_flush (stream);
636 }
637 \f
638 void
639 c_value_print (struct value *val, struct ui_file *stream, 
640                const struct value_print_options *options)
641 {
642   struct type *type, *real_type, *val_type;
643   int full, top, using_enc;
644   struct value_print_options opts = *options;
645
646   opts.deref_ref = 1;
647
648   /* If it is a pointer, indicate what it points to.
649
650      Print type also if it is a reference.
651
652      C++: if it is a member pointer, we will take care
653      of that when we print it.  */
654
655   /* Preserve the original type before stripping typedefs.  We prefer
656      to pass down the original type when possible, but for local
657      checks it is better to look past the typedefs.  */
658   val_type = value_type (val);
659   type = check_typedef (val_type);
660
661   if (TYPE_CODE (type) == TYPE_CODE_PTR
662       || TYPE_CODE (type) == TYPE_CODE_REF)
663     {
664       /* Hack:  remove (char *) for char strings.  Their
665          type is indicated by the quoted string anyway.
666          (Don't use c_textual_element_type here; quoted strings
667          are always exactly (char *), (wchar_t *), or the like.  */
668       if (TYPE_CODE (val_type) == TYPE_CODE_PTR
669           && TYPE_NAME (val_type) == NULL
670           && TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL
671           && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)),
672                       "char") == 0
673               || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))
674         {
675           /* Print nothing.  */
676         }
677       else if (options->objectprint
678                && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
679         {
680
681           if (TYPE_CODE(type) == TYPE_CODE_REF)
682             {
683               /* Copy value, change to pointer, so we don't get an
684                  error about a non-pointer type in
685                  value_rtti_target_type.  */
686               struct value *temparg;
687               temparg=value_copy(val);
688               deprecated_set_value_type
689                 (temparg, lookup_pointer_type (TYPE_TARGET_TYPE (type)));
690               val = temparg;
691             }
692           /* Pointer to class, check real type of object.  */
693           fprintf_filtered (stream, "(");
694
695           if (value_entirely_available (val))
696             {
697               real_type = value_rtti_indirect_type (val, &full, &top,
698                                                     &using_enc);
699               if (real_type)
700                 {
701                   /* RTTI entry found.  */
702                   type = real_type;
703
704                   /* Need to adjust pointer value.  */
705                   val = value_from_pointer (type, value_as_address (val) - top);
706
707                   /* Note: When we look up RTTI entries, we don't get
708                      any information on const or volatile
709                      attributes.  */
710                 }
711             }
712           type_print (type, "", stream, -1);
713           fprintf_filtered (stream, ") ");
714           val_type = type;
715         }
716       else
717         {
718           /* normal case */
719           fprintf_filtered (stream, "(");
720           type_print (value_type (val), "", stream, -1);
721           fprintf_filtered (stream, ") ");
722         }
723     }
724
725   if (!value_initialized (val))
726     fprintf_filtered (stream, " [uninitialized] ");
727
728   if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
729     {
730       /* Attempt to determine real type of object.  */
731       real_type = value_rtti_type (val, &full, &top, &using_enc);
732       if (real_type)
733         {
734           /* We have RTTI information, so use it.  */
735           val = value_full_object (val, real_type, 
736                                    full, top, using_enc);
737           fprintf_filtered (stream, "(%s%s) ",
738                             TYPE_NAME (real_type),
739                             full ? "" : _(" [incomplete object]"));
740           /* Print out object: enclosing type is same as real_type if
741              full.  */
742           val_print (value_enclosing_type (val),
743                      value_contents_for_printing (val), 0,
744                      value_address (val), stream, 0,
745                      val, &opts, current_language);
746           return;
747           /* Note: When we look up RTTI entries, we don't get any
748              information on const or volatile attributes.  */
749         }
750       else if (type != check_typedef (value_enclosing_type (val)))
751         {
752           /* No RTTI information, so let's do our best.  */
753           fprintf_filtered (stream, "(%s ?) ",
754                             TYPE_NAME (value_enclosing_type (val)));
755           val_print (value_enclosing_type (val),
756                      value_contents_for_printing (val), 0,
757                      value_address (val), stream, 0,
758                      val, &opts, current_language);
759           return;
760         }
761       /* Otherwise, we end up at the return outside this "if".  */
762     }
763
764   val_print (val_type, value_contents_for_printing (val),
765              value_embedded_offset (val),
766              value_address (val),
767              stream, 0,
768              val, &opts, current_language);
769 }