1 /* Print values for GNU debugger gdb.
2 Copyright (C) 1986, 1988, 1989 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
34 extern char *sys_errlist[];
36 extern void print_scalar_formatted(); /* printcmd.c */
37 extern void print_address_demangle(); /* printcmd.c */
38 extern int demangle; /* whether to print C++ syms raw or source-form */
40 /* Maximum number of chars to print for a string pointer value
41 or vector contents, or UINT_MAX for no limit. */
43 static unsigned int print_max;
45 static void type_print_varspec_suffix ();
46 static void type_print_varspec_prefix ();
47 static void type_print_base ();
48 static void type_print_method_args ();
50 /* Default input and output radixes, and output format letter. */
52 unsigned input_radix = 10;
53 unsigned output_radix = 10;
54 int output_format = 0;
57 char **unsigned_type_table;
58 char **signed_type_table;
59 char **float_type_table;
62 /* Print repeat counts if there are more than this
63 many repetitions of an element in an array. */
64 #define REPEAT_COUNT_THRESHOLD 10
66 /* Define a mess of print controls. */
68 int prettyprint; /* Controls pretty printing of structures */
69 int vtblprint; /* Controls printing of vtbl's */
70 int unionprint; /* Controls printing of nested unions. */
71 int arrayprint; /* Controls pretty printing of arrays. */
72 int addressprint; /* Controls pretty printing of addresses. */
73 int objectprint; /* Controls looking up an object's derived type
74 using what we find in its vtables. */
76 struct obstack dont_print_obstack;
78 static void cplus_val_print ();
80 /* Print the character string STRING, printing at most LENGTH characters.
81 Printing stops early if the number hits print_max; repeat counts
82 are printed as appropriate. Print ellipses at the end if we
83 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
86 print_string (stream, string, length, force_ellipses)
92 register unsigned int i;
93 unsigned int things_printed = 0;
96 extern int inspect_it;
100 fputs_filtered ("\"\"", stdout);
104 for (i = 0; i < length && things_printed < print_max; ++i)
106 /* Position of the character we are examining
107 to see whether it is repeated. */
109 /* Number of repetitions we have detected so far. */
116 fputs_filtered (", ", stream);
122 while (rep1 < length && string[rep1] == string[i])
128 if (reps > REPEAT_COUNT_THRESHOLD)
133 fputs_filtered ("\\\", ", stream);
135 fputs_filtered ("\", ", stream);
138 fputs_filtered ("'", stream);
139 printchar (string[i], stream, '\'');
140 fprintf_filtered (stream, "' <repeats %u times>", reps);
142 things_printed += REPEAT_COUNT_THRESHOLD;
150 fputs_filtered ("\\\"", stream);
152 fputs_filtered ("\"", stream);
155 printchar (string[i], stream, '"');
160 /* Terminate the quotes if necessary. */
164 fputs_filtered ("\\\"", stream);
166 fputs_filtered ("\"", stream);
169 if (force_ellipses || i < length)
170 fputs_filtered ("...", stream);
173 /* Print a floating point value of type TYPE, pointed to in GDB by VALADDR,
177 print_floating (valaddr, type, stream)
184 unsigned len = TYPE_LENGTH (type);
186 #if defined (IEEE_FLOAT)
188 /* Check for NaN's. Note that this code does not depend on us being
189 on an IEEE conforming system. It only depends on the target
190 machine using IEEE representation. This means (a)
191 cross-debugging works right, and (2) IEEE_FLOAT can (and should)
192 be defined for systems like the 68881, which uses IEEE
193 representation, but is not IEEE conforming. */
197 /* Is the sign bit 0? */
199 /* Is it is a NaN (i.e. the exponent is all ones and
200 the fraction is nonzero)? */
203 if (len == sizeof (float))
205 /* It's single precision. */
206 bcopy (valaddr, &low, sizeof (low));
207 /* target -> host. */
208 SWAP_TARGET_AND_HOST (&low, sizeof (float));
209 nonnegative = low >= 0;
210 is_nan = ((((low >> 23) & 0xFF) == 0xFF)
211 && 0 != (low & 0x7FFFFF));
217 /* It's double precision. Get the high and low words. */
219 #if TARGET_BYTE_ORDER == BIG_ENDIAN
220 bcopy (valaddr+4, &low, sizeof (low));
221 bcopy (valaddr+0, &high, sizeof (high));
223 bcopy (valaddr+0, &low, sizeof (low));
224 bcopy (valaddr+4, &high, sizeof (high));
226 SWAP_TARGET_AND_HOST (&low, sizeof (low));
227 SWAP_TARGET_AND_HOST (&high, sizeof (high));
228 nonnegative = high >= 0;
229 is_nan = (((high >> 20) & 0x7ff) == 0x7ff
230 && ! ((((high & 0xfffff) == 0)) && (low == 0)));
236 /* The meaning of the sign and fraction is not defined by IEEE.
237 But the user might know what they mean. For example, they
238 (in an implementation-defined manner) distinguish between
239 signaling and quiet NaN's. */
241 fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + nonnegative,
244 fprintf_filtered (stream, "-NaN(0x%lx)" + nonnegative, low);
248 #endif /* IEEE_FLOAT. */
250 doub = unpack_double (type, valaddr, &inv);
252 fprintf_filtered (stream, "<invalid float value>");
254 fprintf_filtered (stream, len <= sizeof(float) ? "%.9g" : "%.17g", doub);
257 /* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */
259 print_hex_chars (stream, valaddr, len)
261 unsigned char *valaddr;
266 fprintf_filtered (stream, "0x");
267 #if TARGET_BYTE_ORDER == BIG_ENDIAN
271 #else /* Little endian. */
272 for (p = valaddr + len - 1;
277 fprintf_filtered (stream, "%02x", *p);
281 /* Print the value VAL in C-ish syntax on stream STREAM.
282 FORMAT is a format-letter, or 0 for print in natural format of data type.
283 If the object printed is a string pointer, returns
284 the number of string bytes printed. */
287 value_print (val, stream, format, pretty)
291 enum val_prettyprint pretty;
293 register unsigned int i, n, typelen;
297 printf_filtered ("<address of value unknown>");
300 if (VALUE_OPTIMIZED_OUT (val))
302 printf_filtered ("<value optimized out>");
306 /* A "repeated" value really contains several values in a row.
307 They are made by the @ operator.
308 Print such values as if they were arrays. */
310 else if (VALUE_REPEATED (val))
312 n = VALUE_REPETITIONS (val);
313 typelen = TYPE_LENGTH (VALUE_TYPE (val));
314 fprintf_filtered (stream, "{");
315 /* Print arrays of characters using string syntax. */
316 if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT
318 print_string (stream, VALUE_CONTENTS (val), n, 0);
321 unsigned int things_printed = 0;
323 for (i = 0; i < n && things_printed < print_max; i++)
325 /* Position of the array element we are examining to see
326 whether it is repeated. */
328 /* Number of repetitions we have detected so far. */
332 fprintf_filtered (stream, ", ");
338 && !bcmp (VALUE_CONTENTS (val) + typelen * i,
339 VALUE_CONTENTS (val) + typelen * rep1, typelen))
345 if (reps > REPEAT_COUNT_THRESHOLD)
347 val_print (VALUE_TYPE (val),
348 VALUE_CONTENTS (val) + typelen * i,
349 VALUE_ADDRESS (val) + typelen * i,
350 stream, format, 1, 0, pretty);
351 fprintf (stream, " <repeats %u times>", reps);
353 things_printed += REPEAT_COUNT_THRESHOLD;
357 val_print (VALUE_TYPE (val),
358 VALUE_CONTENTS (val) + typelen * i,
359 VALUE_ADDRESS (val) + typelen * i,
360 stream, format, 1, 0, pretty);
365 fprintf_filtered (stream, "...");
367 fprintf_filtered (stream, "}");
372 struct type *type = VALUE_TYPE (val);
374 /* If it is a pointer, indicate what it points to.
376 Print type also if it is a reference.
378 C++: if it is a member pointer, we will take care
379 of that when we print it. */
380 if (TYPE_CODE (type) == TYPE_CODE_PTR
381 || TYPE_CODE (type) == TYPE_CODE_REF)
383 /* Hack: remove (char *) for char strings. Their
384 type is indicated by the quoted string anyway. */
385 if (TYPE_CODE (type) == TYPE_CODE_PTR
386 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof(char)
387 && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT
388 && !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type)))
394 fprintf_filtered (stream, "(");
395 type_print (type, "", stream, -1);
396 fprintf_filtered (stream, ") ");
399 return val_print (type, VALUE_CONTENTS (val),
400 VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
404 /* Return truth value for assertion that TYPE is of the type
405 "pointer to virtual function". */
407 is_vtbl_ptr_type(type)
410 char *typename = type_name_no_tag (type);
411 static const char vtbl_ptr_name[] =
412 { CPLUS_MARKER,'v','t','b','l','_','p','t','r','_','t','y','p','e', 0 };
414 return (typename != NULL && !strcmp(typename, vtbl_ptr_name));
417 /* Return truth value for the assertion that TYPE is of the type
418 "pointer to virtual function table". */
423 if (TYPE_CODE (type) == TYPE_CODE_PTR)
424 type = TYPE_TARGET_TYPE (type);
428 if (TYPE_CODE (type) == TYPE_CODE_ARRAY
429 && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT)
430 /* Virtual functions tables are full of pointers to virtual functions. */
431 return is_vtbl_ptr_type (TYPE_TARGET_TYPE (type));
435 /* Mutually recursive subroutines of cplus_val_print and val_print to print out
436 a structure's fields: val_print_fields and cplus_val_print.
438 TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the
439 same meanings as in cplus_val_print and val_print.
441 DONT_PRINT is an array of baseclass types that we
442 should not print, or zero if called from top level. */
444 val_print_fields (type, valaddr, stream, format, recurse, pretty, dont_print)
450 enum val_prettyprint pretty;
451 struct type **dont_print;
453 int i, len, n_baseclasses;
455 check_stub_type (type);
457 fprintf_filtered (stream, "{");
458 len = TYPE_NFIELDS (type);
459 n_baseclasses = TYPE_N_BASECLASSES (type);
461 /* Print out baseclasses such that we don't print
462 duplicates of virtual baseclasses. */
463 if (n_baseclasses > 0)
464 cplus_val_print (type, valaddr, stream, format, recurse+1, pretty, dont_print);
466 if (!len && n_baseclasses == 1)
467 fprintf_filtered (stream, "<No data fields>");
470 extern int inspect_it;
473 for (i = n_baseclasses; i < len; i++)
475 /* Check if static field */
476 if (TYPE_FIELD_STATIC (type, i))
479 fprintf_filtered (stream, ", ");
480 else if (n_baseclasses > 0)
482 fprintf_filtered (stream, "\n");
483 print_spaces_filtered (2 + 2 * recurse, stream);
484 fputs_filtered ("members of ", stream);
485 fputs_filtered (type_name_no_tag (type), stream);
486 fputs_filtered (": ", stream);
492 fprintf_filtered (stream, "\n");
493 print_spaces_filtered (2 + 2 * recurse, stream);
497 wrap_here (n_spaces (2 + 2 * recurse));
501 if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
502 fputs_filtered ("\"( ptr \"", stream);
504 fputs_filtered ("\"( nodef \"", stream);
505 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
506 fputs_filtered ("\" \"", stream);
507 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
508 fputs_filtered ("\") \"", stream);
512 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
513 fputs_filtered (" = ", stream);
515 if (TYPE_FIELD_PACKED (type, i))
519 /* Bitfields require special handling, especially due to byte
521 v = value_from_longest (TYPE_FIELD_TYPE (type, i),
522 unpack_field_as_long (type, valaddr, i));
524 val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0,
525 stream, format, 0, recurse + 1, pretty);
529 val_print (TYPE_FIELD_TYPE (type, i),
530 valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
531 0, stream, format, 0, recurse + 1, pretty);
536 fprintf_filtered (stream, "\n");
537 print_spaces_filtered (2 * recurse, stream);
540 fprintf_filtered (stream, "}");
543 /* Special val_print routine to avoid printing multiple copies of virtual
547 cplus_val_print (type, valaddr, stream, format, recurse, pretty, dont_print)
553 enum val_prettyprint pretty;
554 struct type **dont_print;
556 struct obstack tmp_obstack;
557 struct type **last_dont_print
558 = (struct type **)obstack_next_free (&dont_print_obstack);
559 int i, n_baseclasses = TYPE_N_BASECLASSES (type);
563 /* If we're at top level, carve out a completely fresh
564 chunk of the obstack and use that until this particular
565 invocation returns. */
566 tmp_obstack = dont_print_obstack;
567 /* Bump up the high-water mark. Now alpha is omega. */
568 obstack_finish (&dont_print_obstack);
571 for (i = 0; i < n_baseclasses; i++)
576 if (BASETYPE_VIA_VIRTUAL (type, i))
578 struct type **first_dont_print
579 = (struct type **)obstack_base (&dont_print_obstack);
581 int j = (struct type **)obstack_next_free (&dont_print_obstack)
585 if (TYPE_BASECLASS (type, i) == first_dont_print[j])
588 obstack_ptr_grow (&dont_print_obstack, TYPE_BASECLASS (type, i));
591 baddr = baseclass_addr (type, i, valaddr, 0, &err);
592 if (err == 0 && baddr == 0)
593 error ("could not find virtual baseclass `%s'\n",
594 type_name_no_tag (TYPE_BASECLASS (type, i)));
596 fprintf_filtered (stream, "\n");
598 print_spaces_filtered (2 + 2 * recurse, stream);
599 fputs_filtered ("<", stream);
600 fputs_filtered (type_name_no_tag (TYPE_BASECLASS (type, i)), stream);
601 fputs_filtered ("> = ", stream);
603 fprintf_filtered (stream, "<invalid address 0x%x>", baddr);
605 val_print_fields (TYPE_BASECLASS (type, i), baddr, stream, format,
607 (struct type **)obstack_base (&dont_print_obstack));
614 /* Free the space used to deal with the printing
615 of this type from top level. */
616 obstack_free (&dont_print_obstack, last_dont_print);
617 /* Reset watermark so that we can continue protecting
618 ourselves from whatever we were protecting ourselves. */
619 dont_print_obstack = tmp_obstack;
623 /* Print data of type TYPE located at VALADDR (within GDB),
624 which came from the inferior at address ADDRESS,
625 onto stdio stream STREAM according to FORMAT
626 (a letter or 0 for natural format). The data at VALADDR
627 is in target byte order.
629 If the data are a string pointer, returns the number of
630 sting characters printed.
632 if DEREF_REF is nonzero, then dereference references,
633 otherwise just print them like pointers.
635 The PRETTY parameter controls prettyprinting. */
638 val_print (type, valaddr, address, stream, format,
639 deref_ref, recurse, pretty)
647 enum val_prettyprint pretty;
649 register unsigned int i;
651 struct type *elttype;
656 if (pretty == Val_pretty_default)
658 pretty = prettyprint ? Val_prettyprint : Val_no_prettyprint;
663 check_stub_type (type);
665 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
667 fprintf_filtered (stream, "<unknown struct>");
672 switch (TYPE_CODE (type))
674 case TYPE_CODE_ARRAY:
675 /* FIXME: TYPE_LENGTH (type) is unsigned and therefore always
676 >= 0. Is "> 0" meant? I'm not sure what an "array of
677 unspecified length" (mentioned in the comment for the else-part
679 if (TYPE_LENGTH (type) >= 0
680 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
682 elttype = TYPE_TARGET_TYPE (type);
683 eltlen = TYPE_LENGTH (elttype);
684 len = TYPE_LENGTH (type) / eltlen;
686 print_spaces_filtered (2 + 2 * recurse, stream);
687 fprintf_filtered (stream, "{");
688 /* For an array of chars, print with string syntax. */
689 if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT
690 && (format == 0 || format == 's') )
691 print_string (stream, valaddr, len, 0);
694 unsigned int things_printed = 0;
696 /* If this is a virtual function table, print the 0th
697 entry specially, and the rest of the members normally. */
698 if (is_vtbl_ptr_type (elttype))
700 fprintf_filtered (stream, "%d vtable entries", len-1);
706 for (; i < len && things_printed < print_max; i++)
708 /* Position of the array element we are examining to see
709 whether it is repeated. */
711 /* Number of repetitions we have detected so far. */
717 fprintf_filtered (stream, ",\n");
718 print_spaces_filtered (2 + 2 * recurse, stream);
721 fprintf_filtered (stream, ", ");
722 wrap_here (n_spaces (2 + 2 * recurse));
727 && !bcmp (valaddr + i * eltlen,
728 valaddr + rep1 * eltlen, eltlen))
734 if (reps > REPEAT_COUNT_THRESHOLD)
736 val_print (elttype, valaddr + i * eltlen,
737 0, stream, format, deref_ref,
738 recurse + 1, pretty);
739 fprintf_filtered (stream, " <repeats %u times>", reps);
741 things_printed += REPEAT_COUNT_THRESHOLD;
745 val_print (elttype, valaddr + i * eltlen,
746 0, stream, format, deref_ref,
747 recurse + 1, pretty);
752 fprintf_filtered (stream, "...");
754 fprintf_filtered (stream, "}");
757 /* Array of unspecified length: treat like pointer to first elt. */
758 valaddr = (char *) &address;
761 if (format && format != 's')
763 print_scalar_formatted (valaddr, type, format, 0, stream);
766 if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD)
768 struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type));
774 addr = unpack_pointer (lookup_pointer_type (builtin_type_void),
778 len = TYPE_NFN_FIELDS (domain);
779 for (i = 0; i < len; i++)
781 f = TYPE_FN_FIELDLIST1 (domain, i);
782 len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
784 for (j = 0; j < len2; j++)
787 if (TYPE_FN_FIELD_VOFFSET (f, j) == addr)
797 struct symbol *sym = find_pc_function (addr);
799 error ("invalid pointer to member function");
800 len = TYPE_NFN_FIELDS (domain);
801 for (i = 0; i < len; i++)
803 f = TYPE_FN_FIELDLIST1 (domain, i);
804 len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
806 for (j = 0; j < len2; j++)
809 if (!strcmp (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j)))
817 fprintf_filtered (stream, "&");
818 type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0);
819 fprintf (stream, kind);
820 if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
821 && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
822 type_print_method_args
823 (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
824 TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream);
826 type_print_method_args
827 (TYPE_FN_FIELD_ARGS (f, j), "",
828 TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream);
831 fprintf_filtered (stream, "(");
832 type_print (type, "", stream, -1);
833 fprintf_filtered (stream, ") %d", (int) addr >> 3);
835 else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER)
837 struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type));
839 /* VAL is a byte offset into the structure type DOMAIN.
840 Find the name of the field for that offset and
844 len = TYPE_NFIELDS (domain);
845 /* @@ Make VAL into bit offset */
846 val = unpack_long (builtin_type_int, valaddr) << 3;
847 for (i = TYPE_N_BASECLASSES (domain); i < len; i++)
849 int bitpos = TYPE_FIELD_BITPOS (domain, i);
853 if (val < bitpos && i != 0)
855 /* Somehow pointing into a field. */
857 extra = (val - TYPE_FIELD_BITPOS (domain, i));
867 fprintf_filtered (stream, "&");
868 type_print_base (domain, stream, 0, 0);
869 fprintf_filtered (stream, "::");
870 fputs_filtered (TYPE_FIELD_NAME (domain, i), stream);
872 fprintf_filtered (stream, " + %d bytes", extra);
874 fprintf_filtered (stream, " (offset in bits)");
877 fprintf_filtered (stream, "%d", val >> 3);
881 CORE_ADDR addr = unpack_pointer (type, valaddr);
882 elttype = TYPE_TARGET_TYPE (type);
884 if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
886 /* Try to print what function it points to. */
887 print_address_demangle (addr, stream, demangle);
888 /* Return value is irrelevant except for string pointers. */
892 if (addressprint && format != 's')
893 fprintf_filtered (stream, "0x%x", addr);
895 /* For a pointer to char or unsigned char,
896 also print the string pointed to, unless pointer is null. */
897 i = 0; /* Number of characters printed. */
898 if (TYPE_LENGTH (elttype) == 1
899 && TYPE_CODE (elttype) == TYPE_CODE_INT
900 && (format == 0 || format == 's')
902 /* If print_max is UINT_MAX, the alloca below will fail.
903 In that case don't try to print the string. */
904 && print_max < UINT_MAX)
906 int first_addr_err = 0;
909 /* Get first character. */
910 errcode = target_read_memory (addr, (char *)&c, 1);
913 /* First address out of bounds. */
919 char *string = (char *) alloca (print_max);
921 /* If the loop ends by us hitting print_max characters,
922 we need to have elipses at the end. */
923 int force_ellipses = 1;
925 /* This loop always fetches print_max characters, even
926 though print_string might want to print more or fewer
927 (with repeated characters). This is so that
928 we don't spend forever fetching if we print
929 a long string consisting of the same character
930 repeated. Also so we can do it all in one memory
931 operation, which is faster. However, this will be
932 slower if print_max is set high, e.g. if you set
933 print_max to 1000, not only will it take a long
934 time to fetch short strings, but if you are near
935 the end of the address space, it might not work.
938 errcode = target_read_memory (addr, string, print_max);
942 for (i = 0; i < print_max; i++)
943 if (string[i] == '\0')
951 fputs_filtered (" ", stream);
952 print_string (stream, string, i, force_ellipses);
959 fprintf_filtered (stream,
960 (" <Address 0x%x out of bounds>"
966 if (errcode >= sys_nerr || errcode < 0)
967 error ("Error reading memory address 0x%x: unknown error (%d).",
970 error ("Error reading memory address 0x%x: %s.",
971 addr + i, sys_errlist[errcode]);
977 else /* print vtbl's nicely */
978 if (is_vtbl_member(type))
980 CORE_ADDR vt_address = unpack_pointer (type, valaddr);
982 int vt_index = find_pc_misc_function (vt_address);
984 && vt_address == misc_function_vector[vt_index].address)
986 fputs_filtered (" <", stream);
987 fputs_demangled (misc_function_vector[vt_index].name,
989 fputs_filtered (">", stream);
995 vt_val = value_at (TYPE_TARGET_TYPE (type), vt_address);
996 val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val),
997 VALUE_ADDRESS (vt_val), stream, format,
998 deref_ref, recurse + 1, pretty);
1001 fprintf_filtered (stream, "\n");
1002 print_spaces_filtered (2 + 2 * recurse, stream);
1007 /* Return number of characters printed, plus one for the
1008 terminating null if we have "reached the end". */
1009 return i + (print_max && i != print_max);
1013 case TYPE_CODE_MEMBER:
1014 error ("not implemented: member type in val_print");
1020 fprintf_filtered (stream, "@0x%lx",
1021 unpack_long (builtin_type_int, valaddr));
1023 fputs_filtered (": ", stream);
1025 /* De-reference the reference. */
1028 if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
1032 (TYPE_TARGET_TYPE (type),
1033 unpack_pointer (lookup_pointer_type (builtin_type_void),
1035 val_print (VALUE_TYPE (deref_val), VALUE_CONTENTS (deref_val),
1036 VALUE_ADDRESS (deref_val), stream, format,
1037 deref_ref, recurse + 1, pretty);
1040 fputs_filtered ("???", stream);
1044 case TYPE_CODE_UNION:
1045 if (recurse && !unionprint)
1047 fprintf_filtered (stream, "{...}");
1051 case TYPE_CODE_STRUCT:
1052 if (vtblprint && is_vtbl_ptr_type(type))
1054 /* Print the unmangled name if desired. */
1055 print_address_demangle(*((int *) (valaddr + /* FIXME bytesex */
1056 TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8)),
1060 val_print_fields (type, valaddr, stream, format, recurse, pretty, 0);
1063 case TYPE_CODE_ENUM:
1066 print_scalar_formatted (valaddr, type, format, 0, stream);
1069 len = TYPE_NFIELDS (type);
1070 val = unpack_long (builtin_type_int, valaddr);
1071 for (i = 0; i < len; i++)
1074 if (val == TYPE_FIELD_BITPOS (type, i))
1078 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
1081 fprintf_filtered (stream, "%lld", val);
1083 fprintf_filtered (stream, "%ld", val);
1087 case TYPE_CODE_FUNC:
1090 print_scalar_formatted (valaddr, type, format, 0, stream);
1093 /* FIXME, we should consider, at least for ANSI C language, eliminating
1094 the distinction made between FUNCs and POINTERs to FUNCs. */
1095 fprintf_filtered (stream, "{");
1096 type_print (type, "", stream, -1);
1097 fprintf_filtered (stream, "} ");
1098 /* Try to print what function it points to, and its address. */
1099 print_address_demangle (address, stream, demangle);
1103 if (format || output_format)
1105 print_scalar_formatted (valaddr, type,
1106 format? format: output_format,
1110 if (TYPE_LENGTH (type) > sizeof (LONGEST))
1112 if (TYPE_UNSIGNED (type))
1114 /* First figure out whether the number in fact has zeros
1115 in all its bytes more significant than least significant
1116 sizeof (LONGEST) ones. */
1118 /* Pointer to first (i.e. lowest address) nonzero character. */
1120 len = TYPE_LENGTH (type);
1122 #if TARGET_BYTE_ORDER == BIG_ENDIAN
1124 len > sizeof (LONGEST)
1125 && p < valaddr + TYPE_LENGTH (type);
1127 #else /* Little endian. */
1128 first_addr = valaddr;
1129 for (p = valaddr + TYPE_LENGTH (type);
1130 len > sizeof (LONGEST) && p >= valaddr;
1132 #endif /* Little endian. */
1139 #if TARGET_BYTE_ORDER == BIG_ENDIAN
1143 if (len <= sizeof (LONGEST))
1145 /* We can print it in decimal. */
1148 #if defined (LONG_LONG)
1153 unpack_long (BUILTIN_TYPE_LONGEST, first_addr));
1157 /* It is big, so print it in hex. */
1158 print_hex_chars (stream, (unsigned char *)first_addr, len);
1163 /* Signed. One could assume two's complement (a reasonable
1164 assumption, I think) and do better than this. */
1165 print_hex_chars (stream, (unsigned char *)valaddr,
1166 TYPE_LENGTH (type));
1170 #ifdef PRINT_TYPELESS_INTEGER
1171 PRINT_TYPELESS_INTEGER (stream, type, unpack_long (type, valaddr));
1174 fprintf_filtered (stream,
1175 TYPE_UNSIGNED (type) ? "%u" : "%d",
1176 unpack_long (type, valaddr));
1178 fprintf_filtered (stream,
1179 TYPE_UNSIGNED (type) ? "%llu" : "%lld",
1180 unpack_long (type, valaddr));
1184 if (TYPE_LENGTH (type) == 1)
1186 fprintf_filtered (stream, " '");
1187 printchar ((unsigned char) unpack_long (type, valaddr),
1189 fprintf_filtered (stream, "'");
1195 print_scalar_formatted (valaddr, type, format, 0, stream);
1197 print_floating (valaddr, type, stream);
1200 case TYPE_CODE_VOID:
1201 fprintf_filtered (stream, "void");
1204 case TYPE_CODE_UNDEF:
1205 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
1206 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
1207 and no complete type for struct foo in that file. */
1208 fprintf_filtered (stream, "<unknown struct>");
1211 case TYPE_CODE_ERROR:
1212 fprintf_filtered (stream, "?");
1215 case TYPE_CODE_RANGE:
1216 /* FIXME, we should not ever have to print one of these yet. */
1217 fprintf_filtered (stream, "<range type>");
1221 error ("Invalid type code in symbol table.");
1227 /* Print a description of a type in the format of a
1228 typedef for the current language.
1229 NEW is the new name for a type TYPE. */
1231 typedef_print (type, new, stream)
1236 switch (current_language->la_language)
1240 fprintf_filtered(stream, "typedef ");
1241 type_print(type,"",stream,0);
1242 if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0
1243 || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (new))),
1245 fprintf_filtered(stream, " %s", SYMBOL_NAME(new));
1250 fprintf_filtered(stream, "TYPE ");
1251 if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
1252 strcmp (TYPE_NAME(SYMBOL_TYPE(new)),
1254 fprintf_filtered(stream, "%s = ", SYMBOL_NAME(new));
1256 fprintf_filtered(stream, "<builtin> = ");
1257 type_print(type,"",stream,0);
1261 error("Language not supported.");
1263 fprintf_filtered(stream, ";\n");
1267 /* Print a description of a type TYPE
1268 in the form of a declaration of a variable named VARSTRING.
1269 (VARSTRING is demangled if necessary.)
1270 Output goes to STREAM (via stdio).
1271 If SHOW is positive, we show the contents of the outermost level
1272 of structure even if there is a type name that could be used instead.
1273 If SHOW is negative, we never show the details of elements' types. */
1276 type_print (type, varstring, stream, show)
1282 type_print_1 (type, varstring, stream, show, 0);
1285 /* LEVEL is the depth to indent lines by. */
1288 type_print_1 (type, varstring, stream, show, level)
1295 register enum type_code code;
1296 type_print_base (type, stream, show, level);
1297 code = TYPE_CODE (type);
1298 if ((varstring && *varstring)
1300 /* Need a space if going to print stars or brackets;
1301 but not if we will print just a type name. */
1302 ((show > 0 || TYPE_NAME (type) == 0)
1304 (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
1305 || code == TYPE_CODE_METHOD
1306 || code == TYPE_CODE_ARRAY
1307 || code == TYPE_CODE_MEMBER
1308 || code == TYPE_CODE_REF)))
1309 fprintf_filtered (stream, " ");
1310 type_print_varspec_prefix (type, stream, show, 0);
1311 fputs_demangled (varstring, stream, -1); /* Print demangled name
1312 without arguments */
1313 type_print_varspec_suffix (type, stream, show, 0);
1316 /* Print the method arguments ARGS to the file STREAM. */
1318 type_print_method_args (args, prefix, varstring, staticp, stream)
1320 char *prefix, *varstring;
1326 fputs_filtered (" ", stream);
1327 fputs_demangled (prefix, stream, 1);
1328 fputs_demangled (varstring, stream, 1);
1329 fputs_filtered (" (", stream);
1330 if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
1332 i = !staticp; /* skip the class variable */
1335 type_print (args[i++], "", stream, 0);
1338 fprintf_filtered (stream, " ...");
1341 else if (args[i]->code != TYPE_CODE_VOID)
1343 fprintf_filtered (stream, ", ");
1348 fprintf_filtered (stream, ")");
1351 /* If TYPE is a derived type, then print out derivation
1352 information. Print out all layers of the type heirarchy
1353 until we encounter one with multiple inheritance.
1354 At that point, print out that ply, and return. */
1356 type_print_derivation_info (stream, type)
1361 int i, n_baseclasses = TYPE_N_BASECLASSES (type);
1362 struct type *basetype = 0;
1364 while (type && n_baseclasses > 0)
1366 /* Not actually sure about this one -- Bryan. */
1367 check_stub_type (type);
1369 fprintf_filtered (stream, ": ");
1372 basetype = TYPE_BASECLASS (type, i);
1373 if (name = type_name_no_tag (basetype))
1375 fprintf_filtered (stream, "%s%s ",
1376 BASETYPE_VIA_PUBLIC(type, i) ? "public" : "private",
1377 BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : "");
1378 fputs_filtered (name, stream);
1381 if (i >= n_baseclasses)
1383 fprintf_filtered (stream, ", ");
1386 fprintf_filtered (stream, " ");
1387 if (n_baseclasses != 1)
1389 n_baseclasses = TYPE_N_BASECLASSES (basetype);
1394 /* Print any asterisks or open-parentheses needed before the
1395 variable name (to describe its type).
1397 On outermost call, pass 0 for PASSED_A_PTR.
1398 On outermost call, SHOW > 0 means should ignore
1399 any typename for TYPE and show its details.
1400 SHOW is always zero on recursive calls. */
1403 type_print_varspec_prefix (type, stream, show, passed_a_ptr)
1412 if (TYPE_NAME (type) && show <= 0)
1417 switch (TYPE_CODE (type))
1420 type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
1421 fprintf_filtered (stream, "*");
1424 case TYPE_CODE_MEMBER:
1426 fprintf_filtered (stream, "(");
1427 type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
1429 fprintf_filtered (stream, " ");
1430 type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0,
1432 fprintf_filtered (stream, "::");
1435 case TYPE_CODE_METHOD:
1437 fprintf (stream, "(");
1438 type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
1442 fprintf_filtered (stream, " ");
1443 type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0,
1445 fprintf_filtered (stream, "::");
1450 type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
1451 fprintf_filtered (stream, "&");
1454 case TYPE_CODE_FUNC:
1455 type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
1458 fprintf_filtered (stream, "(");
1461 case TYPE_CODE_ARRAY:
1462 type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
1465 fprintf_filtered (stream, "(");
1467 case TYPE_CODE_UNDEF:
1468 case TYPE_CODE_STRUCT:
1469 case TYPE_CODE_UNION:
1470 case TYPE_CODE_ENUM:
1473 case TYPE_CODE_VOID:
1474 case TYPE_CODE_ERROR:
1475 /* These types need no prefix. They are listed here so that
1476 gcc -Wall will reveal any types that haven't been handled. */
1481 /* Print any array sizes, function arguments or close parentheses
1482 needed after the variable name (to describe its type).
1483 Args work like type_print_varspec_prefix. */
1486 type_print_varspec_suffix (type, stream, show, passed_a_ptr)
1495 if (TYPE_NAME (type) && show <= 0)
1500 switch (TYPE_CODE (type))
1502 case TYPE_CODE_ARRAY:
1504 fprintf_filtered (stream, ")");
1506 fprintf_filtered (stream, "[");
1507 if (TYPE_LENGTH (type) > 0
1508 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
1509 fprintf_filtered (stream, "%d",
1511 / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
1512 fprintf_filtered (stream, "]");
1514 type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
1518 case TYPE_CODE_MEMBER:
1520 fprintf_filtered (stream, ")");
1521 type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0);
1524 case TYPE_CODE_METHOD:
1526 fprintf_filtered (stream, ")");
1527 type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0);
1531 struct type **args = TYPE_ARG_TYPES (type);
1533 fprintf_filtered (stream, "(");
1535 fprintf_filtered (stream, "...");
1536 else for (i = 1; args[i] != 0 && args[i]->code != TYPE_CODE_VOID; i++)
1538 type_print_1 (args[i], "", stream, -1, 0);
1540 fprintf_filtered (stream, "...");
1541 else if (args[i+1]->code != TYPE_CODE_VOID) {
1542 fprintf_filtered (stream, ",");
1546 fprintf_filtered (stream, ")");
1552 type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1);
1555 case TYPE_CODE_FUNC:
1556 type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
1559 fprintf_filtered (stream, ")");
1560 fprintf_filtered (stream, "()");
1563 case TYPE_CODE_UNDEF:
1564 case TYPE_CODE_STRUCT:
1565 case TYPE_CODE_UNION:
1566 case TYPE_CODE_ENUM:
1569 case TYPE_CODE_VOID:
1570 case TYPE_CODE_ERROR:
1571 /* These types do not need a suffix. They are listed so that
1572 gcc -Wall will report types that may not have been considered. */
1577 /* Print the name of the type (or the ultimate pointer target,
1578 function value or array element), or the description of a
1581 SHOW nonzero means don't print this type as just its name;
1582 show its real definition even if it has a name.
1583 SHOW zero means print just typename or struct tag if there is one
1584 SHOW negative means abbreviate structure elements.
1585 SHOW is decremented for printing of structure elements.
1587 LEVEL is the depth to indent by.
1588 We increase it for some recursive calls. */
1591 type_print_base (type, stream, show, level)
1600 register int lastval;
1607 fprintf_filtered (stream, "<type unknown>");
1611 if (TYPE_NAME (type) && show <= 0)
1613 fputs_filtered (TYPE_NAME (type), stream);
1617 switch (TYPE_CODE (type))
1619 case TYPE_CODE_ARRAY:
1621 case TYPE_CODE_MEMBER:
1623 case TYPE_CODE_FUNC:
1624 case TYPE_CODE_METHOD:
1625 type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
1628 case TYPE_CODE_STRUCT:
1629 fprintf_filtered (stream, "struct ");
1632 case TYPE_CODE_UNION:
1633 fprintf_filtered (stream, "union ");
1635 if (name = type_name_no_tag (type))
1637 fputs_filtered (name, stream);
1638 fputs_filtered (" ", stream);
1642 fprintf_filtered (stream, "{...}");
1645 check_stub_type (type);
1647 type_print_derivation_info (stream, type);
1649 fprintf_filtered (stream, "{");
1650 len = TYPE_NFIELDS (type);
1652 fprintf_filtered (stream, "\n");
1655 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
1656 fprintf_filtered (stream, "<incomplete type>\n");
1658 fprintf_filtered (stream, "<no data fields>\n");
1661 /* If there is a base class for this type,
1662 do not print the field that it occupies. */
1663 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
1666 /* Don't print out virtual function table. */
1667 if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER &&
1668 !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5))
1671 print_spaces_filtered (level + 4, stream);
1672 if (TYPE_FIELD_STATIC (type, i))
1674 fprintf_filtered (stream, "static ");
1676 type_print_1 (TYPE_FIELD_TYPE (type, i),
1677 TYPE_FIELD_NAME (type, i),
1678 stream, show - 1, level + 4);
1679 if (!TYPE_FIELD_STATIC (type, i)
1680 && TYPE_FIELD_PACKED (type, i))
1682 /* It is a bitfield. This code does not attempt
1683 to look at the bitpos and reconstruct filler,
1684 unnamed fields. This would lead to misleading
1685 results if the compiler does not put out fields
1686 for such things (I don't know what it does). */
1687 fprintf_filtered (stream, " : %d",
1688 TYPE_FIELD_BITSIZE (type, i));
1690 fprintf_filtered (stream, ";\n");
1693 /* C++: print out the methods */
1694 len = TYPE_NFN_FIELDS (type);
1695 if (len) fprintf_filtered (stream, "\n");
1696 for (i = 0; i < len; i++)
1698 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
1699 int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
1701 for (j = 0; j < len2; j++)
1704 print_spaces_filtered (level + 4, stream);
1705 if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
1706 fprintf_filtered (stream, "virtual ");
1707 else if (TYPE_FN_FIELD_STATIC_P (f, j))
1708 fprintf_filtered (stream, "static ");
1709 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
1711 /* Keep GDB from crashing here. */
1712 fprintf (stream, "<undefined type> %s;\n",
1713 TYPE_FN_FIELD_PHYSNAME (f, j));
1717 type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), "", stream, 0);
1718 if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f, j)) & TYPE_FLAG_STUB)
1720 /* Build something we can demangle. */
1721 char *strchr (), *gdb_mangle_name (), *cplus_demangle ();
1722 char *mangled_name = gdb_mangle_name (type, i, j);
1723 char *demangled_name = cplus_demangle (mangled_name, 1);
1724 if (demangled_name == 0)
1725 fprintf_filtered (stream, " <badly mangled name %s>",
1729 fprintf_filtered (stream, " %s",
1730 strchr (demangled_name, ':') + 2);
1731 free (demangled_name);
1733 free (mangled_name);
1735 else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
1736 && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
1737 type_print_method_args
1738 (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
1739 TYPE_FN_FIELDLIST_NAME (type, i), 0, stream);
1741 type_print_method_args
1742 (TYPE_FN_FIELD_ARGS (f, j), "",
1743 TYPE_FN_FIELDLIST_NAME (type, i),
1744 TYPE_FN_FIELD_STATIC_P (f, j), stream);
1746 fprintf_filtered (stream, ";\n");
1750 print_spaces_filtered (level, stream);
1751 fprintf_filtered (stream, "}");
1755 case TYPE_CODE_ENUM:
1756 fprintf_filtered (stream, "enum ");
1757 if (name = type_name_no_tag (type))
1759 fputs_filtered (name, stream);
1760 fputs_filtered (" ", stream);
1764 fprintf_filtered (stream, "{...}");
1767 fprintf_filtered (stream, "{");
1768 len = TYPE_NFIELDS (type);
1770 for (i = 0; i < len; i++)
1773 if (i) fprintf_filtered (stream, ", ");
1775 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
1776 if (lastval != TYPE_FIELD_BITPOS (type, i))
1778 fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
1779 lastval = TYPE_FIELD_BITPOS (type, i);
1783 fprintf_filtered (stream, "}");
1789 if (TYPE_LENGTH (type) <= sizeof (LONGEST))
1791 if (TYPE_UNSIGNED (type))
1792 name = unsigned_type_table[TYPE_LENGTH (type)];
1794 name = signed_type_table[TYPE_LENGTH (type)];
1797 fputs_filtered (name, stream);
1799 fprintf_filtered (stream, "<%d bit integer>",
1800 TYPE_LENGTH (type) * TARGET_CHAR_BIT);
1804 name = float_type_table[TYPE_LENGTH (type)];
1805 fputs_filtered (name, stream);
1808 case TYPE_CODE_VOID:
1809 fprintf_filtered (stream, "void");
1812 case TYPE_CODE_UNDEF:
1813 fprintf_filtered (stream, "struct <unknown>");
1816 case TYPE_CODE_ERROR:
1817 fprintf_filtered (stream, "<unknown type>");
1820 case TYPE_CODE_RANGE:
1821 /* This should not occur */
1822 fprintf_filtered (stream, "<range type>");
1826 error ("Invalid type code in symbol table.");
1831 /* Validate an input or output radix setting, and make sure the user
1832 knows what they really did here. Radix setting is confusing, e.g.
1833 setting the input radix to "10" never changes it! */
1837 set_input_radix (args, from_tty, c)
1840 struct cmd_list_element *c;
1842 unsigned radix = *(unsigned *)c->var;
1845 printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n",
1846 radix, radix, radix);
1852 set_output_radix (args, from_tty, c)
1855 struct cmd_list_element *c;
1857 unsigned radix = *(unsigned *)c->var;
1860 printf_filtered ("Output radix set to decimal %d, hex %x, octal %o\n",
1861 radix, radix, radix);
1863 /* FIXME, we really should be able to validate the setting BEFORE
1868 output_format = 'x';
1874 output_format = 'o'; /* octal */
1878 error ("Unsupported radix ``decimal %d''; using decimal output",
1885 set_radix (arg, from_tty, c)
1888 struct cmd_list_element *c;
1890 unsigned radix = *(unsigned *)c->var;
1893 printf_filtered ("Radix set to decimal %d, hex %x, octal %o\n",
1894 radix, radix, radix);
1896 input_radix = radix;
1897 output_radix = radix;
1899 set_output_radix (arg, 0, c);
1902 struct cmd_list_element *setprintlist = NULL;
1903 struct cmd_list_element *showprintlist = NULL;
1907 set_print (arg, from_tty)
1912 "\"set print\" must be followed by the name of a print subcommand.\n");
1913 help_list (setprintlist, "set print ", -1, stdout);
1918 show_print (args, from_tty)
1922 cmd_show_list (showprintlist, from_tty, "");
1926 _initialize_valprint ()
1928 struct cmd_list_element *c;
1930 add_prefix_cmd ("print", no_class, set_print,
1931 "Generic command for setting how things print.",
1932 &setprintlist, "set print ", 0, &setlist);
1933 add_alias_cmd ("p", "print", no_class, 1, &setlist);
1934 add_alias_cmd ("pr", "print", no_class, 1, &setlist); /* prefer set print
1936 add_prefix_cmd ("print", no_class, show_print,
1937 "Generic command for showing print settings.",
1938 &showprintlist, "show print ", 0, &showlist);
1939 add_alias_cmd ("p", "print", no_class, 1, &showlist);
1940 add_alias_cmd ("pr", "print", no_class, 1, &showlist);
1943 (add_set_cmd ("elements", no_class, var_uinteger, (char *)&print_max,
1944 "Set limit on string chars or array elements to print.\n\
1945 \"set print elements 0\" causes there to be no limit.",
1950 (add_set_cmd ("pretty", class_support, var_boolean, (char *)&prettyprint,
1951 "Set prettyprinting of structures.",
1956 (add_set_cmd ("union", class_support, var_boolean, (char *)&unionprint,
1957 "Set printing of unions interior to structures.",
1962 (add_set_cmd ("vtbl", class_support, var_boolean, (char *)&vtblprint,
1963 "Set printing of C++ virtual function tables.",
1968 (add_set_cmd ("array", class_support, var_boolean, (char *)&arrayprint,
1969 "Set prettyprinting of arrays.",
1974 (add_set_cmd ("object", class_support, var_boolean, (char *)&objectprint,
1975 "Set printing of object's derived type based on vtable info.",
1980 (add_set_cmd ("address", class_support, var_boolean, (char *)&addressprint,
1981 "Set printing of addresses.",
1986 /* The "show radix" cmd isn't good enough to show two separate values.
1987 The rest of the code works, but the show part is confusing, so don't
1988 let them be set separately 'til we work out "show". */
1989 c = add_set_cmd ("input-radix", class_support, var_uinteger,
1990 (char *)&input_radix,
1991 "Set default input radix for entering numbers.",
1993 add_show_from_set (c, &showlist);
1994 c->function = set_input_radix;
1996 c = add_set_cmd ("output-radix", class_support, var_uinteger,
1997 (char *)&output_radix,
1998 "Set default output radix for printing of values.",
2000 add_show_from_set (c, &showlist);
2001 c->function = set_output_radix;
2004 c = add_set_cmd ("radix", class_support, var_uinteger,
2005 (char *)&output_radix,
2006 "Set default input and output number radix.",
2008 add_show_from_set (c, &showlist);
2009 c->function = set_radix;
2011 /* Give people the defaults which they are used to. */
2021 /* Initialize the names of the various types based on their lengths on
2022 the target, in bits. Note that ordering is important, so that for example,
2023 if ints and longs are the same size, that size will default to "int". */
2025 unsigned_type_table = (char **)
2026 xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
2027 bzero (unsigned_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)));
2028 unsigned_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "unsigned char";
2029 unsigned_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "unsigned short";
2030 unsigned_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long long";
2031 unsigned_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long";
2032 unsigned_type_table[TARGET_INT_BIT/TARGET_CHAR_BIT] = "unsigned int";
2034 signed_type_table = (char **)
2035 xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
2036 bzero (signed_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)));
2037 signed_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "char";
2038 signed_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "short";
2039 signed_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "long long";
2040 signed_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "long";
2041 signed_type_table[TARGET_INT_BIT/TARGET_CHAR_BIT] = "int";
2043 float_type_table = (char **)
2044 xmalloc ((1 + (TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT)) * sizeof (char *));
2045 bzero (float_type_table, (1 + (TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT)));
2046 float_type_table[TARGET_FLOAT_BIT/TARGET_CHAR_BIT] = "float";
2047 float_type_table[TARGET_DOUBLE_COMPLEX_BIT/TARGET_CHAR_BIT] = "double complex";
2048 float_type_table[TARGET_COMPLEX_BIT/TARGET_CHAR_BIT] = "complex";
2049 float_type_table[TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT] = "long double";
2050 float_type_table[TARGET_DOUBLE_BIT/TARGET_CHAR_BIT] = "double";
2052 obstack_begin (&dont_print_obstack, 32 * sizeof (struct type *));