1 /* Support for printing Pascal values for GDB, the GNU debugger.
3 Copyright (C) 2000, 2001, 2003, 2005, 2006, 2007, 2008
4 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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/>. */
21 /* This file is derived from c-valprint.c */
24 #include "gdb_obstack.h"
27 #include "expression.h"
34 #include "typeprint.h"
40 #include "cp-support.h"
45 /* Print data of type TYPE located at VALADDR (within GDB), which came from
46 the inferior at address ADDRESS, onto stdio stream STREAM according to
47 FORMAT (a letter or 0 for natural format). The data at VALADDR is in
50 If the data are a string pointer, returns the number of string characters
53 If DEREF_REF is nonzero, then dereference references, otherwise just print
56 The PRETTY parameter controls prettyprinting. */
60 pascal_val_print (struct type *type, const gdb_byte *valaddr,
61 int embedded_offset, CORE_ADDR address,
62 struct ui_file *stream, int format, int deref_ref,
63 int recurse, enum val_prettyprint pretty)
65 unsigned int i = 0; /* Number of characters printed */
69 int length_pos, length_size, string_pos;
75 switch (TYPE_CODE (type))
78 if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
80 elttype = check_typedef (TYPE_TARGET_TYPE (type));
81 eltlen = TYPE_LENGTH (elttype);
82 len = TYPE_LENGTH (type) / eltlen;
83 if (prettyprint_arrays)
85 print_spaces_filtered (2 + 2 * recurse, stream);
87 /* For an array of chars, print with string syntax. */
89 && ((TYPE_CODE (elttype) == TYPE_CODE_INT)
90 || ((current_language->la_language == language_pascal)
91 && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
92 && (format == 0 || format == 's'))
94 /* If requested, look for the first null char and only print
96 if (stop_print_at_null)
98 unsigned int temp_len;
100 /* Look for a NULL char. */
102 (valaddr + embedded_offset)[temp_len]
103 && temp_len < len && temp_len < print_max;
108 LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
113 fprintf_filtered (stream, "{");
114 /* If this is a virtual function table, print the 0th
115 entry specially, and the rest of the members normally. */
116 if (pascal_object_is_vtbl_ptr_type (elttype))
119 fprintf_filtered (stream, "%d vtable entries", len - 1);
125 val_print_array_elements (type, valaddr + embedded_offset, address, stream,
126 format, deref_ref, recurse, pretty, i);
127 fprintf_filtered (stream, "}");
131 /* Array of unspecified length: treat like pointer to first elt. */
133 goto print_unpacked_pointer;
136 if (format && format != 's')
138 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
141 if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
143 /* Print the unmangled name if desired. */
144 /* Print vtable entry - we only get here if we ARE using
145 -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
146 /* Extract the address, assume that it is unsigned. */
147 print_address_demangle (extract_unsigned_integer (valaddr + embedded_offset, TYPE_LENGTH (type)),
151 elttype = check_typedef (TYPE_TARGET_TYPE (type));
153 addr = unpack_pointer (type, valaddr + embedded_offset);
154 print_unpacked_pointer:
155 elttype = check_typedef (TYPE_TARGET_TYPE (type));
157 if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
159 /* Try to print what function it points to. */
160 print_address_demangle (addr, stream, demangle);
161 /* Return value is irrelevant except for string pointers. */
165 if (addressprint && format != 's')
167 fputs_filtered (paddress (addr), stream);
170 /* For a pointer to char or unsigned char, also print the string
171 pointed to, unless pointer is null. */
172 if (TYPE_LENGTH (elttype) == 1
173 && (TYPE_CODE (elttype) == TYPE_CODE_INT
174 || TYPE_CODE(elttype) == TYPE_CODE_CHAR)
175 && (format == 0 || format == 's')
178 /* no wide string yet */
179 i = val_print_string (addr, -1, 1, stream);
181 /* also for pointers to pascal strings */
182 /* Note: this is Free Pascal specific:
183 as GDB does not recognize stabs pascal strings
184 Pascal strings are mapped to records
185 with lowercase names PM */
186 if (is_pascal_string_type (elttype, &length_pos, &length_size,
187 &string_pos, &char_size, NULL)
190 ULONGEST string_length;
192 buffer = xmalloc (length_size);
193 read_memory (addr + length_pos, buffer, length_size);
194 string_length = extract_unsigned_integer (buffer, length_size);
196 i = val_print_string (addr + string_pos, string_length, char_size, stream);
198 else if (pascal_object_is_vtbl_member (type))
200 /* print vtbl's nicely */
201 CORE_ADDR vt_address = unpack_pointer (type, valaddr + embedded_offset);
203 struct minimal_symbol *msymbol =
204 lookup_minimal_symbol_by_pc (vt_address);
205 if ((msymbol != NULL)
206 && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
208 fputs_filtered (" <", stream);
209 fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
210 fputs_filtered (">", stream);
212 if (vt_address && vtblprint)
214 struct value *vt_val;
215 struct symbol *wsym = (struct symbol *) NULL;
217 struct block *block = (struct block *) NULL;
221 wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol), block,
222 VAR_DOMAIN, &is_this_fld, NULL);
226 wtype = SYMBOL_TYPE (wsym);
230 wtype = TYPE_TARGET_TYPE (type);
232 vt_val = value_at (wtype, vt_address);
233 common_val_print (vt_val, stream, format, deref_ref,
234 recurse + 1, pretty);
237 fprintf_filtered (stream, "\n");
238 print_spaces_filtered (2 + 2 * recurse, stream);
243 /* Return number of characters printed, including the terminating
244 '\0' if we reached the end. val_print_string takes care including
245 the terminating '\0' if necessary. */
251 elttype = check_typedef (TYPE_TARGET_TYPE (type));
254 fprintf_filtered (stream, "@");
255 /* Extract the address, assume that it is unsigned. */
256 fputs_filtered (paddress (
257 extract_unsigned_integer (valaddr + embedded_offset,
258 gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream);
260 fputs_filtered (": ", stream);
262 /* De-reference the reference. */
265 if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
267 struct value *deref_val =
269 (TYPE_TARGET_TYPE (type),
270 unpack_pointer (lookup_pointer_type (builtin_type_void),
271 valaddr + embedded_offset));
272 common_val_print (deref_val, stream, format, deref_ref,
273 recurse + 1, pretty);
276 fputs_filtered ("???", stream);
280 case TYPE_CODE_UNION:
281 if (recurse && !unionprint)
283 fprintf_filtered (stream, "{...}");
287 case TYPE_CODE_STRUCT:
288 if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
290 /* Print the unmangled name if desired. */
291 /* Print vtable entry - we only get here if NOT using
292 -fvtable_thunks. (Otherwise, look under TYPE_CODE_PTR.) */
293 /* Extract the address, assume that it is unsigned. */
294 print_address_demangle
295 (extract_unsigned_integer (valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
296 TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET))),
301 if (is_pascal_string_type (type, &length_pos, &length_size,
302 &string_pos, &char_size, NULL))
304 len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
305 LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
308 pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format,
309 recurse, pretty, NULL, 0);
316 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
319 len = TYPE_NFIELDS (type);
320 val = unpack_long (type, valaddr + embedded_offset);
321 for (i = 0; i < len; i++)
324 if (val == TYPE_FIELD_BITPOS (type, i))
331 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
335 print_longest (stream, 'd', 0, val);
339 case TYPE_CODE_FLAGS:
341 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
343 val_print_type_code_flags (type, valaddr + embedded_offset, stream);
349 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
352 /* FIXME, we should consider, at least for ANSI C language, eliminating
353 the distinction made between FUNCs and POINTERs to FUNCs. */
354 fprintf_filtered (stream, "{");
355 type_print (type, "", stream, -1);
356 fprintf_filtered (stream, "} ");
357 /* Try to print what function it points to, and its address. */
358 print_address_demangle (address, stream, demangle);
362 format = format ? format : output_format;
364 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
367 val = unpack_long (type, valaddr + embedded_offset);
369 fputs_filtered ("false", stream);
371 fputs_filtered ("true", stream);
374 fputs_filtered ("true (", stream);
375 fprintf_filtered (stream, "%ld)", (long int) val);
380 case TYPE_CODE_RANGE:
381 /* FIXME: create_range_type does not set the unsigned bit in a
382 range type (I think it probably should copy it from the target
383 type), so we won't print values which are too large to
384 fit in a signed integer correctly. */
385 /* FIXME: Doesn't handle ranges of enums correctly. (Can't just
386 print with the target type, though, because the size of our type
387 and the target type might differ). */
391 format = format ? format : output_format;
394 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
398 val_print_type_code_int (type, valaddr + embedded_offset, stream);
403 format = format ? format : output_format;
406 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
410 val = unpack_long (type, valaddr + embedded_offset);
411 if (TYPE_UNSIGNED (type))
412 fprintf_filtered (stream, "%u", (unsigned int) val);
414 fprintf_filtered (stream, "%d", (int) val);
415 fputs_filtered (" ", stream);
416 LA_PRINT_CHAR ((unsigned char) val, stream);
423 print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
427 print_floating (valaddr + embedded_offset, type, stream);
431 case TYPE_CODE_BITSTRING:
433 elttype = TYPE_INDEX_TYPE (type);
434 CHECK_TYPEDEF (elttype);
435 if (TYPE_STUB (elttype))
437 fprintf_filtered (stream, "<incomplete type>");
443 struct type *range = elttype;
444 LONGEST low_bound, high_bound;
446 int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING;
450 fputs_filtered ("B'", stream);
452 fputs_filtered ("[", stream);
454 i = get_discrete_bounds (range, &low_bound, &high_bound);
458 fputs_filtered ("<error value>", stream);
462 for (i = low_bound; i <= high_bound; i++)
464 int element = value_bit_index (type, valaddr + embedded_offset, i);
468 goto maybe_bad_bstring;
471 fprintf_filtered (stream, "%d", element);
475 fputs_filtered (", ", stream);
476 print_type_scalar (range, i, stream);
479 if (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i))
482 fputs_filtered ("..", stream);
483 while (i + 1 <= high_bound
484 && value_bit_index (type, valaddr + embedded_offset, ++i))
486 print_type_scalar (range, j, stream);
492 fputs_filtered ("'", stream);
494 fputs_filtered ("]", stream);
499 fprintf_filtered (stream, "void");
502 case TYPE_CODE_ERROR:
503 fprintf_filtered (stream, "<error type>");
506 case TYPE_CODE_UNDEF:
507 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
508 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
509 and no complete type for struct foo in that file. */
510 fprintf_filtered (stream, "<incomplete type>");
514 error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type));
521 pascal_value_print (struct value *val, struct ui_file *stream, int format,
522 enum val_prettyprint pretty)
524 struct type *type = value_type (val);
526 /* If it is a pointer, indicate what it points to.
528 Print type also if it is a reference.
530 Object pascal: if it is a member pointer, we will take care
531 of that when we print it. */
532 if (TYPE_CODE (type) == TYPE_CODE_PTR
533 || TYPE_CODE (type) == TYPE_CODE_REF)
535 /* Hack: remove (char *) for char strings. Their
536 type is indicated by the quoted string anyway. */
537 if (TYPE_CODE (type) == TYPE_CODE_PTR
538 && TYPE_NAME (type) == NULL
539 && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
540 && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
546 fprintf_filtered (stream, "(");
547 type_print (type, "", stream, -1);
548 fprintf_filtered (stream, ") ");
551 return common_val_print (val, stream, format, 1, 0, pretty);
555 /******************************************************************************
556 Inserted from cp-valprint
557 ******************************************************************************/
559 extern int vtblprint; /* Controls printing of vtbl's */
560 extern int objectprint; /* Controls looking up an object's derived type
561 using what we find in its vtables. */
562 static int pascal_static_field_print; /* Controls printing of static fields. */
564 show_pascal_static_field_print (struct ui_file *file, int from_tty,
565 struct cmd_list_element *c, const char *value)
567 fprintf_filtered (file, _("Printing of pascal static members is %s.\n"),
571 static struct obstack dont_print_vb_obstack;
572 static struct obstack dont_print_statmem_obstack;
574 static void pascal_object_print_static_field (struct value *,
575 struct ui_file *, int, int,
576 enum val_prettyprint);
578 static void pascal_object_print_value (struct type *, const gdb_byte *,
579 CORE_ADDR, struct ui_file *,
580 int, int, enum val_prettyprint,
583 /* It was changed to this after 2.4.5. */
584 const char pascal_vtbl_ptr_name[] =
585 {'_', '_', 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 't', 'y', 'p', 'e', 0};
587 /* Return truth value for assertion that TYPE is of the type
588 "pointer to virtual function". */
591 pascal_object_is_vtbl_ptr_type (struct type *type)
593 char *typename = type_name_no_tag (type);
595 return (typename != NULL
596 && strcmp (typename, pascal_vtbl_ptr_name) == 0);
599 /* Return truth value for the assertion that TYPE is of the type
600 "pointer to virtual function table". */
603 pascal_object_is_vtbl_member (struct type *type)
605 if (TYPE_CODE (type) == TYPE_CODE_PTR)
607 type = TYPE_TARGET_TYPE (type);
608 if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
610 type = TYPE_TARGET_TYPE (type);
611 if (TYPE_CODE (type) == TYPE_CODE_STRUCT /* if not using thunks */
612 || TYPE_CODE (type) == TYPE_CODE_PTR) /* if using thunks */
614 /* Virtual functions tables are full of pointers
615 to virtual functions. */
616 return pascal_object_is_vtbl_ptr_type (type);
623 /* Mutually recursive subroutines of pascal_object_print_value and
624 c_val_print to print out a structure's fields:
625 pascal_object_print_value_fields and pascal_object_print_value.
627 TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
628 same meanings as in pascal_object_print_value and c_val_print.
630 DONT_PRINT is an array of baseclass types that we
631 should not print, or zero if called from top level. */
634 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
635 CORE_ADDR address, struct ui_file *stream,
636 int format, int recurse,
637 enum val_prettyprint pretty,
638 struct type **dont_print_vb,
639 int dont_print_statmem)
641 int i, len, n_baseclasses;
642 char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
644 CHECK_TYPEDEF (type);
646 fprintf_filtered (stream, "{");
647 len = TYPE_NFIELDS (type);
648 n_baseclasses = TYPE_N_BASECLASSES (type);
650 /* Print out baseclasses such that we don't print
651 duplicates of virtual baseclasses. */
652 if (n_baseclasses > 0)
653 pascal_object_print_value (type, valaddr, address, stream,
654 format, recurse + 1, pretty, dont_print_vb);
656 if (!len && n_baseclasses == 1)
657 fprintf_filtered (stream, "<No data fields>");
660 struct obstack tmp_obstack = dont_print_statmem_obstack;
663 if (dont_print_statmem == 0)
665 /* If we're at top level, carve out a completely fresh
666 chunk of the obstack and use that until this particular
667 invocation returns. */
668 obstack_finish (&dont_print_statmem_obstack);
671 for (i = n_baseclasses; i < len; i++)
673 /* If requested, skip printing of static fields. */
674 if (!pascal_static_field_print && TYPE_FIELD_STATIC (type, i))
677 fprintf_filtered (stream, ", ");
678 else if (n_baseclasses > 0)
682 fprintf_filtered (stream, "\n");
683 print_spaces_filtered (2 + 2 * recurse, stream);
684 fputs_filtered ("members of ", stream);
685 fputs_filtered (type_name_no_tag (type), stream);
686 fputs_filtered (": ", stream);
693 fprintf_filtered (stream, "\n");
694 print_spaces_filtered (2 + 2 * recurse, stream);
698 wrap_here (n_spaces (2 + 2 * recurse));
702 if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
703 fputs_filtered ("\"( ptr \"", stream);
705 fputs_filtered ("\"( nodef \"", stream);
706 if (TYPE_FIELD_STATIC (type, i))
707 fputs_filtered ("static ", stream);
708 fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
710 DMGL_PARAMS | DMGL_ANSI);
711 fputs_filtered ("\" \"", stream);
712 fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
714 DMGL_PARAMS | DMGL_ANSI);
715 fputs_filtered ("\") \"", stream);
719 annotate_field_begin (TYPE_FIELD_TYPE (type, i));
721 if (TYPE_FIELD_STATIC (type, i))
722 fputs_filtered ("static ", stream);
723 fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
725 DMGL_PARAMS | DMGL_ANSI);
726 annotate_field_name_end ();
727 fputs_filtered (" = ", stream);
728 annotate_field_value ();
731 if (!TYPE_FIELD_STATIC (type, i) && TYPE_FIELD_PACKED (type, i))
735 /* Bitfields require special handling, especially due to byte
737 if (TYPE_FIELD_IGNORE (type, i))
739 fputs_filtered ("<optimized out or zero length>", stream);
743 v = value_from_longest (TYPE_FIELD_TYPE (type, i),
744 unpack_field_as_long (type, valaddr, i));
746 common_val_print (v, stream, format, 0, recurse + 1, pretty);
751 if (TYPE_FIELD_IGNORE (type, i))
753 fputs_filtered ("<optimized out or zero length>", stream);
755 else if (TYPE_FIELD_STATIC (type, i))
757 /* struct value *v = value_static_field (type, i); v4.17 specific */
759 v = value_from_longest (TYPE_FIELD_TYPE (type, i),
760 unpack_field_as_long (type, valaddr, i));
763 fputs_filtered ("<optimized out>", stream);
765 pascal_object_print_static_field (v, stream, format,
766 recurse + 1, pretty);
770 /* val_print (TYPE_FIELD_TYPE (type, i),
771 valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
772 address + TYPE_FIELD_BITPOS (type, i) / 8, 0,
773 stream, format, 0, recurse + 1, pretty); */
774 val_print (TYPE_FIELD_TYPE (type, i),
775 valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
776 address + TYPE_FIELD_BITPOS (type, i) / 8,
777 stream, format, 0, recurse + 1, pretty);
780 annotate_field_end ();
783 if (dont_print_statmem == 0)
785 /* Free the space used to deal with the printing
786 of the members from top level. */
787 obstack_free (&dont_print_statmem_obstack, last_dont_print);
788 dont_print_statmem_obstack = tmp_obstack;
793 fprintf_filtered (stream, "\n");
794 print_spaces_filtered (2 * recurse, stream);
797 fprintf_filtered (stream, "}");
800 /* Special val_print routine to avoid printing multiple copies of virtual
804 pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
805 CORE_ADDR address, struct ui_file *stream,
806 int format, int recurse,
807 enum val_prettyprint pretty,
808 struct type **dont_print_vb)
810 struct type **last_dont_print
811 = (struct type **) obstack_next_free (&dont_print_vb_obstack);
812 struct obstack tmp_obstack = dont_print_vb_obstack;
813 int i, n_baseclasses = TYPE_N_BASECLASSES (type);
815 if (dont_print_vb == 0)
817 /* If we're at top level, carve out a completely fresh
818 chunk of the obstack and use that until this particular
819 invocation returns. */
820 /* Bump up the high-water mark. Now alpha is omega. */
821 obstack_finish (&dont_print_vb_obstack);
824 for (i = 0; i < n_baseclasses; i++)
827 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
828 char *basename = type_name_no_tag (baseclass);
829 const gdb_byte *base_valaddr;
831 if (BASETYPE_VIA_VIRTUAL (type, i))
833 struct type **first_dont_print
834 = (struct type **) obstack_base (&dont_print_vb_obstack);
836 int j = (struct type **) obstack_next_free (&dont_print_vb_obstack)
840 if (baseclass == first_dont_print[j])
843 obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
846 boffset = baseclass_offset (type, i, valaddr, address);
850 fprintf_filtered (stream, "\n");
851 print_spaces_filtered (2 * recurse, stream);
853 fputs_filtered ("<", stream);
854 /* Not sure what the best notation is in the case where there is no
857 fputs_filtered (basename ? basename : "", stream);
858 fputs_filtered ("> = ", stream);
860 /* The virtual base class pointer might have been clobbered by the
861 user program. Make sure that it still points to a valid memory
864 if (boffset != -1 && (boffset < 0 || boffset >= TYPE_LENGTH (type)))
866 /* FIXME (alloc): not safe is baseclass is really really big. */
867 gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
869 if (target_read_memory (address + boffset, buf,
870 TYPE_LENGTH (baseclass)) != 0)
874 base_valaddr = valaddr + boffset;
877 fprintf_filtered (stream, "<invalid address>");
879 pascal_object_print_value_fields (baseclass, base_valaddr, address + boffset,
880 stream, format, recurse, pretty,
881 (struct type **) obstack_base (&dont_print_vb_obstack),
883 fputs_filtered (", ", stream);
889 if (dont_print_vb == 0)
891 /* Free the space used to deal with the printing
892 of this type from top level. */
893 obstack_free (&dont_print_vb_obstack, last_dont_print);
894 /* Reset watermark so that we can continue protecting
895 ourselves from whatever we were protecting ourselves. */
896 dont_print_vb_obstack = tmp_obstack;
900 /* Print value of a static member.
901 To avoid infinite recursion when printing a class that contains
902 a static instance of the class, we keep the addresses of all printed
903 static member classes in an obstack and refuse to print them more
906 VAL contains the value to print, STREAM, RECURSE, and PRETTY
907 have the same meanings as in c_val_print. */
910 pascal_object_print_static_field (struct value *val,
911 struct ui_file *stream, int format,
912 int recurse, enum val_prettyprint pretty)
914 struct type *type = value_type (val);
916 if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
918 CORE_ADDR *first_dont_print;
922 = (CORE_ADDR *) obstack_base (&dont_print_statmem_obstack);
923 i = (CORE_ADDR *) obstack_next_free (&dont_print_statmem_obstack)
928 if (VALUE_ADDRESS (val) == first_dont_print[i])
930 fputs_filtered ("<same as static member of an already seen type>",
936 obstack_grow (&dont_print_statmem_obstack, (char *) &VALUE_ADDRESS (val),
939 CHECK_TYPEDEF (type);
940 pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
941 stream, format, recurse, pretty, NULL, 1);
944 common_val_print (val, stream, format, 0, recurse, pretty);
947 extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
950 _initialize_pascal_valprint (void)
952 add_setshow_boolean_cmd ("pascal_static-members", class_support,
953 &pascal_static_field_print, _("\
954 Set printing of pascal static members."), _("\
955 Show printing of pascal static members."), NULL,
957 show_pascal_static_field_print,
958 &setprintlist, &showprintlist);
959 /* Turn on printing of static fields. */
960 pascal_static_field_print = 1;