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 GDB 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 1, or (at your option)
11 GDB 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 GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
33 extern char *sys_errlist
[];
35 extern void print_scalar_formatted(); /* printcmd.c */
36 extern void print_address_demangle(); /* printcmd.c */
37 extern int demangle
; /* whether to print C++ syms raw or source-form */
39 /* Maximum number of chars to print for a string pointer value
40 or vector contents, or UINT_MAX for no limit. */
42 static unsigned int print_max
;
44 static void type_print_varspec_suffix ();
45 static void type_print_varspec_prefix ();
46 static void type_print_base ();
47 static void type_print_method_args ();
49 /* Default input and output radixes, and output format letter. */
51 unsigned input_radix
= 10;
52 unsigned output_radix
= 10;
53 int output_format
= 0;
56 char **unsigned_type_table
;
57 char **signed_type_table
;
58 char **float_type_table
;
61 /* Print repeat counts if there are more than this
62 many repetitions of an element in an array. */
63 #define REPEAT_COUNT_THRESHOLD 10
65 /* Print the character string STRING, printing at most LENGTH characters.
66 Printing stops early if the number hits print_max; repeat counts
67 are printed as appropriate. Print ellipses at the end if we
68 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
71 print_string (stream
, string
, length
, force_ellipses
)
77 register unsigned int i
;
78 unsigned int things_printed
= 0;
81 extern int inspect_it
;
85 fputs_filtered ("\"\"", stdout
);
89 for (i
= 0; i
< length
&& things_printed
< print_max
; ++i
)
91 /* Position of the character we are examining
92 to see whether it is repeated. */
94 /* Number of repetitions we have detected so far. */
101 fputs_filtered (", ", stream
);
107 while (rep1
< length
&& string
[rep1
] == string
[i
])
113 if (reps
> REPEAT_COUNT_THRESHOLD
)
118 fputs_filtered ("\\\", ", stream
);
120 fputs_filtered ("\", ", stream
);
123 fputs_filtered ("'", stream
);
124 printchar (string
[i
], stream
, '\'');
125 fprintf_filtered (stream
, "' <repeats %u times>", reps
);
127 things_printed
+= REPEAT_COUNT_THRESHOLD
;
135 fputs_filtered ("\\\"", stream
);
137 fputs_filtered ("\"", stream
);
140 printchar (string
[i
], stream
, '"');
145 /* Terminate the quotes if necessary. */
149 fputs_filtered ("\\\"", stream
);
151 fputs_filtered ("\"", stream
);
154 if (force_ellipses
|| i
< length
)
155 fputs_filtered ("...", stream
);
158 /* Print a floating point value of type TYPE, pointed to in GDB by VALADDR,
162 print_floating (valaddr
, type
, stream
)
169 unsigned len
= TYPE_LENGTH (type
);
171 #if defined (IEEE_FLOAT)
173 /* Check for NaN's. Note that this code does not depend on us being
174 on an IEEE conforming system. It only depends on the target
175 machine using IEEE representation. This means (a)
176 cross-debugging works right, and (2) IEEE_FLOAT can (and should)
177 be defined for systems like the 68881, which uses IEEE
178 representation, but is not IEEE conforming. */
182 /* Is the sign bit 0? */
184 /* Is it is a NaN (i.e. the exponent is all ones and
185 the fraction is nonzero)? */
188 if (len
== sizeof (float))
190 /* It's single precision. */
191 bcopy (valaddr
, &low
, sizeof (low
));
192 /* target -> host. */
193 SWAP_TARGET_AND_HOST (&low
, sizeof (float));
194 nonnegative
= low
>= 0;
195 is_nan
= ((((low
>> 23) & 0xFF) == 0xFF)
196 && 0 != (low
& 0x7FFFFF));
202 /* It's double precision. Get the high and low words. */
204 #if TARGET_BYTE_ORDER == BIG_ENDIAN
205 bcopy (valaddr
+4, &low
, sizeof (low
));
206 bcopy (valaddr
+0, &high
, sizeof (high
));
208 bcopy (valaddr
+0, &low
, sizeof (low
));
209 bcopy (valaddr
+4, &high
, sizeof (high
));
211 SWAP_TARGET_AND_HOST (&low
, sizeof (low
));
212 SWAP_TARGET_AND_HOST (&high
, sizeof (high
));
213 nonnegative
= high
>= 0;
214 is_nan
= (((high
>> 20) & 0x7ff) == 0x7ff
215 && ! ((((high
& 0xfffff) == 0)) && (low
== 0)));
221 /* The meaning of the sign and fraction is not defined by IEEE.
222 But the user might know what they mean. For example, they
223 (in an implementation-defined manner) distinguish between
224 signaling and quiet NaN's. */
226 fprintf_filtered (stream
, "-NaN(0x%lx%.8lx)" + nonnegative
,
229 fprintf_filtered (stream
, "-NaN(0x%lx)" + nonnegative
, low
);
233 #endif /* IEEE_FLOAT. */
235 doub
= unpack_double (type
, valaddr
, &inv
);
237 fprintf_filtered (stream
, "<invalid float value>");
239 fprintf_filtered (stream
, len
<= sizeof(float) ? "%.6g" : "%.17g", doub
);
242 /* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */
244 print_hex_chars (stream
, valaddr
, len
)
246 unsigned char *valaddr
;
251 fprintf_filtered (stream
, "0x");
252 #if TARGET_BYTE_ORDER == BIG_ENDIAN
256 #else /* Little endian. */
257 for (p
= valaddr
+ len
- 1;
262 fprintf_filtered (stream
, "%02x", *p
);
266 /* Print the value VAL in C-ish syntax on stream STREAM.
267 FORMAT is a format-letter, or 0 for print in natural format of data type.
268 If the object printed is a string pointer, returns
269 the number of string bytes printed. */
272 value_print (val
, stream
, format
, pretty
)
276 enum val_prettyprint pretty
;
278 register unsigned int i
, n
, typelen
;
282 printf_filtered ("<address of value unknown>");
285 if (VALUE_OPTIMIZED_OUT (val
))
287 printf_filtered ("<value optimized out>");
291 /* A "repeated" value really contains several values in a row.
292 They are made by the @ operator.
293 Print such values as if they were arrays. */
295 else if (VALUE_REPEATED (val
))
297 n
= VALUE_REPETITIONS (val
);
298 typelen
= TYPE_LENGTH (VALUE_TYPE (val
));
299 fprintf_filtered (stream
, "{");
300 /* Print arrays of characters using string syntax. */
301 if (typelen
== 1 && TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_INT
303 print_string (stream
, VALUE_CONTENTS (val
), n
, 0);
306 unsigned int things_printed
= 0;
308 for (i
= 0; i
< n
&& things_printed
< print_max
; i
++)
310 /* Position of the array element we are examining to see
311 whether it is repeated. */
313 /* Number of repetitions we have detected so far. */
317 fprintf_filtered (stream
, ", ");
323 && !bcmp (VALUE_CONTENTS (val
) + typelen
* i
,
324 VALUE_CONTENTS (val
) + typelen
* rep1
, typelen
))
330 if (reps
> REPEAT_COUNT_THRESHOLD
)
332 val_print (VALUE_TYPE (val
),
333 VALUE_CONTENTS (val
) + typelen
* i
,
334 VALUE_ADDRESS (val
) + typelen
* i
,
335 stream
, format
, 1, 0, pretty
);
336 fprintf (stream
, " <repeats %u times>", reps
);
338 things_printed
+= REPEAT_COUNT_THRESHOLD
;
342 val_print (VALUE_TYPE (val
),
343 VALUE_CONTENTS (val
) + typelen
* i
,
344 VALUE_ADDRESS (val
) + typelen
* i
,
345 stream
, format
, 1, 0, pretty
);
350 fprintf_filtered (stream
, "...");
352 fprintf_filtered (stream
, "}");
357 /* If it is a pointer, indicate what it points to.
359 Print type also if it is a reference.
361 C++: if it is a member pointer, we will take care
362 of that when we print it. */
363 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_PTR
364 || TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_REF
)
366 /* Hack: remove (char *) for char strings. Their
367 type is indicated by the quoted string anyway. */
368 if (TYPE_CODE (VALUE_TYPE (val
)) == TYPE_CODE_PTR
369 && TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (val
)))
371 && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (val
)))
373 && !TYPE_UNSIGNED (TYPE_TARGET_TYPE (VALUE_TYPE (val
))))
379 fprintf_filtered (stream
, "(");
380 type_print (VALUE_TYPE (val
), "", stream
, -1);
381 fprintf_filtered (stream
, ") ");
384 return val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
),
385 VALUE_ADDRESS (val
), stream
, format
, 1, 0, pretty
);
389 /* Return truth value for assertion that TYPE is of the type
390 "pointer to virtual function". */
392 is_vtbl_ptr_type(type
)
395 char *typename
= TYPE_NAME(type
);
396 static const char vtbl_ptr_name
[] =
397 { CPLUS_MARKER
,'v','t','b','l','_','p','t','r','_','t','y','p','e' };
399 return (typename
!= NULL
&& !strcmp(typename
, vtbl_ptr_name
));
402 /* Return truth value for the assertion that TYPE is of the type
403 "pointer to virtual function table". */
408 if (TYPE_CODE (type
) == TYPE_CODE_PTR
409 && TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_ARRAY
410 && TYPE_CODE (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type
))) == TYPE_CODE_STRUCT
)
411 /* Virtual functions tables are full of pointers to virtual functions. */
412 return is_vtbl_ptr_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type
)));
416 /* Define a mess of print controls. */
418 int prettyprint
; /* Controls pretty printing of structures */
419 int vtblprint
; /* Controls printing of vtbl's */
420 int unionprint
; /* Controls printing of nested unions. */
421 int arrayprint
; /* Controls pretty printing of arrays. */
422 int addressprint
; /* Controls pretty printing of addresses. */
424 struct obstack dont_print_obstack
;
426 static void cplus_val_print ();
428 /* Mutually recursive subroutines of cplus_val_print and val_print to print out
429 a structure's fields: val_print_fields and cplus_val_print.
431 TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the
432 same meanings as in cplus_val_print and val_print.
434 DONT_PRINT is an array of baseclass types that we
435 should not print, or zero if called from top level. */
437 val_print_fields (type
, valaddr
, stream
, format
, recurse
, pretty
, dont_print
)
443 enum val_prettyprint pretty
;
444 struct type
**dont_print
;
446 int i
, len
, n_baseclasses
;
448 fprintf_filtered (stream
, "{");
449 len
= TYPE_NFIELDS (type
);
450 n_baseclasses
= TYPE_N_BASECLASSES (type
);
452 /* Print out baseclasses such that we don't print
453 duplicates of virtual baseclasses. */
454 if (n_baseclasses
> 0)
455 cplus_val_print (type
, valaddr
, stream
, format
, recurse
+1, pretty
, dont_print
);
457 if (!len
&& n_baseclasses
== 1)
458 fprintf_filtered (stream
, "<No data fields>");
461 extern int inspect_it
;
464 for (i
= n_baseclasses
; i
< len
; i
++)
466 /* Check if static field */
467 if (TYPE_FIELD_STATIC (type
, i
))
470 fprintf_filtered (stream
, ", ");
471 else if (n_baseclasses
> 0)
473 fprintf_filtered (stream
, "\n");
474 print_spaces_filtered (2 + 2 * recurse
, stream
);
475 fputs_filtered ("members of ", stream
);
476 fputs_filtered (type_name_no_tag (type
), stream
);
477 fputs_filtered (": ", stream
);
483 fprintf_filtered (stream
, "\n");
484 print_spaces_filtered (2 + 2 * recurse
, stream
);
488 wrap_here (n_spaces (2 + 2 * recurse
));
492 if (TYPE_CODE (TYPE_FIELD_TYPE (type
, i
)) == TYPE_CODE_PTR
)
493 fputs_filtered ("\"( ptr \"", stream
);
495 fputs_filtered ("\"( nodef \"", stream
);
496 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
497 fputs_filtered ("\" \"", stream
);
498 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
499 fputs_filtered ("\") \"", stream
);
503 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
504 fputs_filtered (" = ", stream
);
506 if (TYPE_FIELD_PACKED (type
, i
))
510 /* Bitfields require special handling, especially due to byte
512 v
= value_from_long (TYPE_FIELD_TYPE (type
, i
),
513 unpack_field_as_long (type
, valaddr
, i
));
515 val_print (TYPE_FIELD_TYPE (type
, i
), VALUE_CONTENTS (v
), 0,
516 stream
, format
, 0, recurse
+ 1, pretty
);
520 val_print (TYPE_FIELD_TYPE (type
, i
),
521 valaddr
+ TYPE_FIELD_BITPOS (type
, i
) / 8,
522 0, stream
, format
, 0, recurse
+ 1, pretty
);
527 fprintf_filtered (stream
, "\n");
528 print_spaces_filtered (2 * recurse
, stream
);
531 fprintf_filtered (stream
, "}");
534 /* Special val_print routine to avoid printing multiple copies of virtual
538 cplus_val_print (type
, valaddr
, stream
, format
, recurse
, pretty
, dont_print
)
544 enum val_prettyprint pretty
;
545 struct type
**dont_print
;
547 struct obstack tmp_obstack
;
548 struct type
**last_dont_print
549 = (struct type
**)obstack_next_free (&dont_print_obstack
);
550 int i
, n_baseclasses
= TYPE_N_BASECLASSES (type
);
554 /* If we're at top level, carve out a completely fresh
555 chunk of the obstack and use that until this particular
556 invocation returns. */
557 tmp_obstack
= dont_print_obstack
;
558 /* Bump up the high-water mark. Now alpha is omega. */
559 obstack_finish (&dont_print_obstack
);
562 for (i
= 0; i
< n_baseclasses
; i
++)
566 if (BASETYPE_VIA_VIRTUAL (type
, i
))
568 struct type
**first_dont_print
569 = (struct type
**)obstack_base (&dont_print_obstack
);
571 int j
= (struct type
**)obstack_next_free (&dont_print_obstack
)
575 if (TYPE_BASECLASS (type
, i
) == first_dont_print
[j
])
578 obstack_ptr_grow (&dont_print_obstack
, TYPE_BASECLASS (type
, i
));
581 baddr
= baseclass_addr (type
, i
, valaddr
, 0);
583 error ("could not find virtual baseclass `%s'\n",
584 type_name_no_tag (TYPE_BASECLASS (type
, i
)));
586 fprintf_filtered (stream
, "\n");
588 print_spaces_filtered (2 + 2 * recurse
, stream
);
589 fputs_filtered ("<", stream
);
590 fputs_filtered (type_name_no_tag (TYPE_BASECLASS (type
, i
)), stream
);
591 fputs_filtered ("> = ", stream
);
592 val_print_fields (TYPE_BASECLASS (type
, i
), baddr
, stream
, format
,
594 (struct type
**)obstack_base (&dont_print_obstack
));
601 /* Free the space used to deal with the printing
602 of this type from top level. */
603 obstack_free (&dont_print_obstack
, last_dont_print
);
604 /* Reset watermark so that we can continue protecting
605 ourselves from whatever we were protecting ourselves. */
606 dont_print_obstack
= tmp_obstack
;
610 /* Print data of type TYPE located at VALADDR (within GDB),
611 which came from the inferior at address ADDRESS,
612 onto stdio stream STREAM according to FORMAT
613 (a letter or 0 for natural format). The data at VALADDR
614 is in target byte order.
616 If the data are a string pointer, returns the number of
617 sting characters printed.
619 if DEREF_REF is nonzero, then dereference references,
620 otherwise just print them like pointers.
622 The PRETTY parameter controls prettyprinting. */
625 val_print (type
, valaddr
, address
, stream
, format
,
626 deref_ref
, recurse
, pretty
)
634 enum val_prettyprint pretty
;
636 register unsigned int i
;
638 struct type
*elttype
;
643 if (pretty
== Val_pretty_default
)
645 pretty
= prettyprint
? Val_prettyprint
: Val_no_prettyprint
;
650 check_stub_type (type
);
652 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
654 fprintf_filtered (stream
, "<unknown struct>");
659 switch (TYPE_CODE (type
))
661 case TYPE_CODE_ARRAY
:
662 if (TYPE_LENGTH (type
) >= 0
663 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
665 elttype
= TYPE_TARGET_TYPE (type
);
666 eltlen
= TYPE_LENGTH (elttype
);
667 len
= TYPE_LENGTH (type
) / eltlen
;
669 print_spaces_filtered (2 + 2 * recurse
, stream
);
670 fprintf_filtered (stream
, "{");
671 /* For an array of chars, print with string syntax. */
672 if (eltlen
== 1 && TYPE_CODE (elttype
) == TYPE_CODE_INT
673 && (format
== 0 || format
== 's') )
674 print_string (stream
, valaddr
, len
, 0);
677 unsigned int things_printed
= 0;
679 for (i
= 0; i
< len
&& things_printed
< print_max
; i
++)
681 /* Position of the array element we are examining to see
682 whether it is repeated. */
684 /* Number of repetitions we have detected so far. */
690 fprintf_filtered (stream
, ",\n");
691 print_spaces_filtered (2 + 2 * recurse
, stream
);
694 fprintf_filtered (stream
, ", ");
695 wrap_here (n_spaces (2 + 2 * recurse
));
700 && !bcmp (valaddr
+ i
* eltlen
,
701 valaddr
+ rep1
* eltlen
, eltlen
))
707 if (reps
> REPEAT_COUNT_THRESHOLD
)
709 val_print (elttype
, valaddr
+ i
* eltlen
,
710 0, stream
, format
, deref_ref
,
711 recurse
+ 1, pretty
);
712 fprintf_filtered (stream
, " <repeats %u times>", reps
);
714 things_printed
+= REPEAT_COUNT_THRESHOLD
;
718 val_print (elttype
, valaddr
+ i
* eltlen
,
719 0, stream
, format
, deref_ref
,
720 recurse
+ 1, pretty
);
725 fprintf_filtered (stream
, "...");
727 fprintf_filtered (stream
, "}");
730 /* Array of unspecified length: treat like pointer to first elt. */
731 valaddr
= (char *) &address
;
734 if (format
&& format
!= 's')
736 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
739 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_METHOD
)
741 struct type
*domain
= TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type
));
746 val
= unpack_long (builtin_type_int
, valaddr
);
749 len
= TYPE_NFN_FIELDS (domain
);
750 for (i
= 0; i
< len
; i
++)
752 f
= TYPE_FN_FIELDLIST1 (domain
, i
);
753 len2
= TYPE_FN_FIELDLIST_LENGTH (domain
, i
);
755 for (j
= 0; j
< len2
; j
++)
758 if (TYPE_FN_FIELD_VOFFSET (f
, j
) == val
)
768 struct symbol
*sym
= find_pc_function ((CORE_ADDR
) val
);
770 error ("invalid pointer to member function");
771 len
= TYPE_NFN_FIELDS (domain
);
772 for (i
= 0; i
< len
; i
++)
774 f
= TYPE_FN_FIELDLIST1 (domain
, i
);
775 len2
= TYPE_FN_FIELDLIST_LENGTH (domain
, i
);
777 for (j
= 0; j
< len2
; j
++)
780 if (!strcmp (SYMBOL_NAME (sym
), TYPE_FN_FIELD_PHYSNAME (f
, j
)))
788 fprintf_filtered (stream
, "&");
789 type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f
, j
), stream
, 0, 0);
790 fprintf (stream
, kind
);
791 if (TYPE_FN_FIELD_PHYSNAME (f
, j
)[0] == '_'
792 && TYPE_FN_FIELD_PHYSNAME (f
, j
)[1] == CPLUS_MARKER
)
793 type_print_method_args
794 (TYPE_FN_FIELD_ARGS (f
, j
) + 1, "~",
795 TYPE_FN_FIELDLIST_NAME (domain
, i
), 0, stream
);
797 type_print_method_args
798 (TYPE_FN_FIELD_ARGS (f
, j
), "",
799 TYPE_FN_FIELDLIST_NAME (domain
, i
), 0, stream
);
802 fprintf_filtered (stream
, "(");
803 type_print (type
, "", stream
, -1);
804 fprintf_filtered (stream
, ") %d", (int) val
>> 3);
806 else if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_MEMBER
)
808 struct type
*domain
= TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type
));
810 /* VAL is a byte offset into the structure type DOMAIN.
811 Find the name of the field for that offset and
815 len
= TYPE_NFIELDS (domain
);
816 /* @@ Make VAL into bit offset */
817 val
= unpack_long (builtin_type_int
, valaddr
) << 3;
818 for (i
= TYPE_N_BASECLASSES (domain
); i
< len
; i
++)
820 int bitpos
= TYPE_FIELD_BITPOS (domain
, i
);
824 if (val
< bitpos
&& i
!= 0)
826 /* Somehow pointing into a field. */
828 extra
= (val
- TYPE_FIELD_BITPOS (domain
, i
));
838 fprintf_filtered (stream
, "&");
839 type_print_base (domain
, stream
, 0, 0);
840 fprintf_filtered (stream
, "::");
841 fputs_filtered (TYPE_FIELD_NAME (domain
, i
), stream
);
843 fprintf_filtered (stream
, " + %d bytes", extra
);
845 fprintf_filtered (stream
, " (offset in bits)");
848 fprintf_filtered (stream
, "%d", val
>> 3);
852 CORE_ADDR addr
= (CORE_ADDR
) unpack_long (type
, valaddr
);
853 elttype
= TYPE_TARGET_TYPE (type
);
855 if (TYPE_CODE (elttype
) == TYPE_CODE_FUNC
)
857 /* Try to print what function it points to. */
858 print_address_demangle (addr
, stream
, demangle
);
859 /* Return value is irrelevant except for string pointers. */
863 if (addressprint
&& format
!= 's')
864 fprintf_filtered (stream
, "0x%x", addr
);
866 /* For a pointer to char or unsigned char,
867 also print the string pointed to, unless pointer is null. */
868 i
= 0; /* Number of characters printed. */
869 if (TYPE_LENGTH (elttype
) == 1
870 && TYPE_CODE (elttype
) == TYPE_CODE_INT
871 && (format
== 0 || format
== 's')
873 /* If print_max is UINT_MAX, the alloca below will fail.
874 In that case don't try to print the string. */
875 && print_max
< UINT_MAX
)
877 int first_addr_err
= 0;
880 /* Get first character. */
881 errcode
= target_read_memory (addr
, (char *)&c
, 1);
884 /* First address out of bounds. */
890 char *string
= (char *) alloca (print_max
);
892 /* If the loop ends by us hitting print_max characters,
893 we need to have elipses at the end. */
894 int force_ellipses
= 1;
896 /* This loop always fetches print_max characters, even
897 though print_string might want to print more or fewer
898 (with repeated characters). This is so that
899 we don't spend forever fetching if we print
900 a long string consisting of the same character
901 repeated. Also so we can do it all in one memory
902 operation, which is faster. However, this will be
903 slower if print_max is set high, e.g. if you set
904 print_max to 1000, not only will it take a long
905 time to fetch short strings, but if you are near
906 the end of the address space, it might not work.
909 errcode
= target_read_memory (addr
, string
, print_max
);
913 for (i
= 0; i
< print_max
; i
++)
914 if (string
[i
] == '\0')
922 fputs_filtered (" ", stream
);
923 print_string (stream
, string
, i
, force_ellipses
);
930 fprintf_filtered (stream
,
931 (" <Address 0x%x out of bounds>"
937 if (errcode
>= sys_nerr
|| errcode
< 0)
938 error ("Error reading memory address 0x%x: unknown error (%d).",
941 error ("Error reading memory address 0x%x: %s.",
942 addr
+ i
, sys_errlist
[errcode
]);
948 else /* print vtbl's nicely */
949 if (is_vtbl_member(type
))
951 CORE_ADDR vt_address
= (CORE_ADDR
) unpack_long (type
, valaddr
);
953 int vt_index
= find_pc_misc_function (vt_address
);
955 && vt_address
== misc_function_vector
[vt_index
].address
)
957 fputs_filtered (" <", stream
);
958 fputs_demangled (misc_function_vector
[vt_index
].name
,
960 fputs_filtered (">", stream
);
966 val
= value_at (TYPE_TARGET_TYPE (type
), vt_address
);
967 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
),
968 VALUE_ADDRESS (val
), stream
, format
,
969 deref_ref
, recurse
+ 1, pretty
);
972 fprintf_filtered (stream
, "\n");
973 print_spaces_filtered (2 + 2 * recurse
, stream
);
978 /* Return number of characters printed, plus one for the
979 terminating null if we have "reached the end". */
980 return i
+ (print_max
&& i
!= print_max
);
984 case TYPE_CODE_MEMBER
:
985 error ("not implemented: member type in val_print");
991 fprintf_filtered (stream
, "@0x%lx",
992 unpack_long (builtin_type_int
, valaddr
));
994 fputs_filtered (": ", stream
);
996 /* De-reference the reference. */
999 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) != TYPE_CODE_UNDEF
)
1001 value val
= value_at (TYPE_TARGET_TYPE (type
),
1002 (CORE_ADDR
) unpack_long (builtin_type_int
,
1004 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
),
1005 VALUE_ADDRESS (val
), stream
, format
,
1006 deref_ref
, recurse
+ 1, pretty
);
1009 fputs_filtered ("???", stream
);
1013 case TYPE_CODE_UNION
:
1014 if (recurse
&& !unionprint
)
1016 fprintf_filtered (stream
, "{...}");
1020 case TYPE_CODE_STRUCT
:
1021 if (vtblprint
&& is_vtbl_ptr_type(type
))
1023 /* Print the unmangled name if desired. */
1024 print_address_demangle(*((int *) (valaddr
+ /* FIXME bytesex */
1025 TYPE_FIELD_BITPOS (type
, VTBL_FNADDR_OFFSET
) / 8)),
1029 val_print_fields (type
, valaddr
, stream
, format
, recurse
, pretty
, 0);
1032 case TYPE_CODE_ENUM
:
1035 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
1038 len
= TYPE_NFIELDS (type
);
1039 val
= unpack_long (builtin_type_int
, valaddr
);
1040 for (i
= 0; i
< len
; i
++)
1043 if (val
== TYPE_FIELD_BITPOS (type
, i
))
1047 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
1049 fprintf_filtered (stream
, "%d", (int) val
);
1052 case TYPE_CODE_FUNC
:
1055 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
1058 fprintf_filtered (stream
, "{");
1059 type_print (type
, "", stream
, -1);
1060 fprintf_filtered (stream
, "} ");
1062 fprintf_filtered (stream
, "0x%x", address
);
1066 if (format
|| output_format
)
1068 print_scalar_formatted (valaddr
, type
,
1069 format
? format
: output_format
,
1073 if (TYPE_LENGTH (type
) > sizeof (LONGEST
))
1075 if (TYPE_UNSIGNED (type
))
1077 /* First figure out whether the number in fact has zeros
1078 in all its bytes more significant than least significant
1079 sizeof (LONGEST) ones. */
1081 /* Pointer to first (i.e. lowest address) nonzero character. */
1083 unsigned len
= TYPE_LENGTH (type
);
1085 #if TARGET_BYTE_ORDER == BIG_ENDIAN
1087 len
> sizeof (LONGEST
)
1088 && p
< valaddr
+ TYPE_LENGTH (type
);
1090 #else /* Little endian. */
1091 first_addr
= valaddr
;
1092 for (p
= valaddr
+ TYPE_LENGTH (type
);
1093 len
> sizeof (LONGEST
) && p
>= valaddr
;
1095 #endif /* Little endian. */
1102 #if TARGET_BYTE_ORDER == BIG_ENDIAN
1106 if (len
<= sizeof (LONGEST
))
1108 /* We can print it in decimal. */
1111 #if defined (LONG_LONG)
1116 unpack_long (BUILTIN_TYPE_LONGEST
, first_addr
));
1120 /* It is big, so print it in hex. */
1121 print_hex_chars (stream
, (unsigned char *)first_addr
, len
);
1126 /* Signed. One could assume two's complement (a reasonable
1127 assumption, I think) and do better than this. */
1128 print_hex_chars (stream
, (unsigned char *)valaddr
,
1129 TYPE_LENGTH (type
));
1133 #ifdef PRINT_TYPELESS_INTEGER
1134 PRINT_TYPELESS_INTEGER (stream
, type
, unpack_long (type
, valaddr
));
1137 fprintf_filtered (stream
,
1138 TYPE_UNSIGNED (type
) ? "%u" : "%d",
1139 unpack_long (type
, valaddr
));
1141 fprintf_filtered (stream
,
1142 TYPE_UNSIGNED (type
) ? "%llu" : "%lld",
1143 unpack_long (type
, valaddr
));
1147 if (TYPE_LENGTH (type
) == 1)
1149 fprintf_filtered (stream
, " '");
1150 printchar ((unsigned char) unpack_long (type
, valaddr
),
1152 fprintf_filtered (stream
, "'");
1158 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
1160 print_floating (valaddr
, type
, stream
);
1163 case TYPE_CODE_VOID
:
1164 fprintf_filtered (stream
, "void");
1167 case TYPE_CODE_UNDEF
:
1168 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
1169 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
1170 and no complete type for struct foo in that file. */
1171 fprintf_filtered (stream
, "<unknown struct>");
1174 case TYPE_CODE_ERROR
:
1175 fprintf_filtered (stream
, "?");
1179 error ("Invalid type code in symbol table.");
1185 /* Print a description of a type TYPE
1186 in the form of a declaration of a variable named VARSTRING.
1187 (VARSTRING is demangled if necessary.)
1188 Output goes to STREAM (via stdio).
1189 If SHOW is positive, we show the contents of the outermost level
1190 of structure even if there is a type name that could be used instead.
1191 If SHOW is negative, we never show the details of elements' types. */
1194 type_print (type
, varstring
, stream
, show
)
1200 type_print_1 (type
, varstring
, stream
, show
, 0);
1203 /* LEVEL is the depth to indent lines by. */
1206 type_print_1 (type
, varstring
, stream
, show
, level
)
1213 register enum type_code code
;
1214 type_print_base (type
, stream
, show
, level
);
1215 code
= TYPE_CODE (type
);
1216 if ((varstring
&& *varstring
)
1218 /* Need a space if going to print stars or brackets;
1219 but not if we will print just a type name. */
1220 ((show
> 0 || TYPE_NAME (type
) == 0)
1222 (code
== TYPE_CODE_PTR
|| code
== TYPE_CODE_FUNC
1223 || code
== TYPE_CODE_METHOD
1224 || code
== TYPE_CODE_ARRAY
1225 || code
== TYPE_CODE_MEMBER
1226 || code
== TYPE_CODE_REF
)))
1227 fprintf_filtered (stream
, " ");
1228 type_print_varspec_prefix (type
, stream
, show
, 0);
1229 fputs_demangled (varstring
, stream
, -1); /* Print demangled name
1230 without arguments */
1231 type_print_varspec_suffix (type
, stream
, show
, 0);
1234 /* Print the method arguments ARGS to the file STREAM. */
1236 type_print_method_args (args
, prefix
, varstring
, staticp
, stream
)
1238 char *prefix
, *varstring
;
1244 fputs_filtered (" ", stream
);
1245 fputs_demangled (prefix
, stream
, 1);
1246 fputs_demangled (varstring
, stream
, 1);
1247 fputs_filtered (" (", stream
);
1248 if (args
&& args
[!staticp
] && args
[!staticp
]->code
!= TYPE_CODE_VOID
)
1250 i
= !staticp
; /* skip the class variable */
1253 type_print (args
[i
++], "", stream
, 0);
1256 fprintf_filtered (stream
, " ...");
1259 else if (args
[i
]->code
!= TYPE_CODE_VOID
)
1261 fprintf_filtered (stream
, ", ");
1266 fprintf_filtered (stream
, ")");
1269 /* If TYPE is a derived type, then print out derivation
1270 information. Print out all layers of the type heirarchy
1271 until we encounter one with multiple inheritance.
1272 At that point, print out that ply, and return. */
1274 type_print_derivation_info (stream
, type
)
1279 int i
, n_baseclasses
= TYPE_N_BASECLASSES (type
);
1280 struct type
*basetype
= 0;
1282 while (type
&& n_baseclasses
> 0)
1284 /* Not actually sure about this one -- Bryan. */
1285 check_stub_type (type
);
1287 fprintf_filtered (stream
, ": ");
1290 basetype
= TYPE_BASECLASS (type
, i
);
1291 if (name
= type_name_no_tag (basetype
))
1293 fprintf_filtered (stream
, "%s%s ",
1294 BASETYPE_VIA_PUBLIC(type
, i
) ? "public" : "private",
1295 BASETYPE_VIA_VIRTUAL(type
, i
) ? " virtual" : "");
1296 fputs_filtered (name
, stream
);
1299 if (i
>= n_baseclasses
)
1301 fprintf_filtered (stream
, ", ");
1304 fprintf_filtered (stream
, " ");
1305 if (n_baseclasses
!= 1)
1307 n_baseclasses
= TYPE_N_BASECLASSES (basetype
);
1312 /* Print any asterisks or open-parentheses needed before the
1313 variable name (to describe its type).
1315 On outermost call, pass 0 for PASSED_A_PTR.
1316 On outermost call, SHOW > 0 means should ignore
1317 any typename for TYPE and show its details.
1318 SHOW is always zero on recursive calls. */
1321 type_print_varspec_prefix (type
, stream
, show
, passed_a_ptr
)
1330 if (TYPE_NAME (type
) && show
<= 0)
1335 switch (TYPE_CODE (type
))
1338 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0, 1);
1339 fprintf_filtered (stream
, "*");
1342 case TYPE_CODE_MEMBER
:
1344 fprintf_filtered (stream
, "(");
1345 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1347 fprintf_filtered (stream
, " ");
1348 type_print_base (TYPE_DOMAIN_TYPE (type
), stream
, 0,
1350 fprintf_filtered (stream
, "::");
1353 case TYPE_CODE_METHOD
:
1355 fprintf (stream
, "(");
1356 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1358 fprintf_filtered (stream
, " ");
1359 type_print_base (TYPE_DOMAIN_TYPE (type
), stream
, 0,
1361 fprintf_filtered (stream
, "::");
1365 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0, 1);
1366 fprintf_filtered (stream
, "&");
1369 case TYPE_CODE_FUNC
:
1370 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1373 fprintf_filtered (stream
, "(");
1376 case TYPE_CODE_ARRAY
:
1377 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1380 fprintf_filtered (stream
, "(");
1382 case TYPE_CODE_UNDEF
:
1383 case TYPE_CODE_STRUCT
:
1384 case TYPE_CODE_UNION
:
1385 case TYPE_CODE_ENUM
:
1388 case TYPE_CODE_VOID
:
1389 case TYPE_CODE_ERROR
:
1390 /* These types need no prefix. They are listed here so that
1391 gcc -Wall will reveal any types that haven't been handled. */
1396 /* Print any array sizes, function arguments or close parentheses
1397 needed after the variable name (to describe its type).
1398 Args work like type_print_varspec_prefix. */
1401 type_print_varspec_suffix (type
, stream
, show
, passed_a_ptr
)
1410 if (TYPE_NAME (type
) && show
<= 0)
1415 switch (TYPE_CODE (type
))
1417 case TYPE_CODE_ARRAY
:
1419 fprintf_filtered (stream
, ")");
1421 fprintf_filtered (stream
, "[");
1422 if (TYPE_LENGTH (type
) >= 0
1423 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
1424 fprintf_filtered (stream
, "%d",
1426 / TYPE_LENGTH (TYPE_TARGET_TYPE (type
))));
1427 fprintf_filtered (stream
, "]");
1429 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0,
1433 case TYPE_CODE_MEMBER
:
1435 fprintf_filtered (stream
, ")");
1436 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0, 0);
1439 case TYPE_CODE_METHOD
:
1441 fprintf_filtered (stream
, ")");
1442 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0, 0);
1446 struct type
**args
= TYPE_ARG_TYPES (type
);
1448 fprintf_filtered (stream
, "(");
1450 fprintf_filtered (stream
, "...");
1451 else for (i
= 1; args
[i
] != 0 && args
[i
]->code
!= TYPE_CODE_VOID
; i
++)
1453 type_print_1 (args
[i
], "", stream
, -1, 0);
1455 fprintf_filtered (stream
, "...");
1456 else if (args
[i
+1]->code
!= TYPE_CODE_VOID
)
1457 fprintf_filtered (stream
, ",");
1459 fprintf_filtered (stream
, ")");
1465 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0, 1);
1468 case TYPE_CODE_FUNC
:
1469 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0,
1472 fprintf_filtered (stream
, ")");
1473 fprintf_filtered (stream
, "()");
1476 case TYPE_CODE_UNDEF
:
1477 case TYPE_CODE_STRUCT
:
1478 case TYPE_CODE_UNION
:
1479 case TYPE_CODE_ENUM
:
1482 case TYPE_CODE_VOID
:
1483 case TYPE_CODE_ERROR
:
1484 /* These types do not need a suffix. They are listed so that
1485 gcc -Wall will report types that may not have been considered. */
1490 /* Print the name of the type (or the ultimate pointer target,
1491 function value or array element), or the description of a
1494 SHOW nonzero means don't print this type as just its name;
1495 show its real definition even if it has a name.
1496 SHOW zero means print just typename or struct tag if there is one
1497 SHOW negative means abbreviate structure elements.
1498 SHOW is decremented for printing of structure elements.
1500 LEVEL is the depth to indent by.
1501 We increase it for some recursive calls. */
1504 type_print_base (type
, stream
, show
, level
)
1513 register int lastval
;
1519 fprintf_filtered (stream
, "type unknown");
1523 if (TYPE_NAME (type
) && show
<= 0)
1525 fputs_filtered (TYPE_NAME (type
), stream
);
1529 switch (TYPE_CODE (type
))
1531 case TYPE_CODE_ARRAY
:
1533 case TYPE_CODE_MEMBER
:
1535 case TYPE_CODE_FUNC
:
1536 case TYPE_CODE_METHOD
:
1537 type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
1540 case TYPE_CODE_STRUCT
:
1541 fprintf_filtered (stream
, "struct ");
1544 case TYPE_CODE_UNION
:
1545 fprintf_filtered (stream
, "union ");
1547 if (name
= type_name_no_tag (type
))
1549 fputs_filtered (name
, stream
);
1550 fputs_filtered (" ", stream
);
1553 fprintf_filtered (stream
, "{...}");
1556 check_stub_type (type
);
1558 type_print_derivation_info (stream
, type
);
1560 fprintf_filtered (stream
, "{");
1561 len
= TYPE_NFIELDS (type
);
1563 fprintf_filtered (stream
, "\n");
1566 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
1567 fprintf_filtered (stream
, "<incomplete type>\n");
1569 fprintf_filtered (stream
, "<no data fields>\n");
1572 /* If there is a base class for this type,
1573 do not print the field that it occupies. */
1574 for (i
= TYPE_N_BASECLASSES (type
); i
< len
; i
++)
1577 /* Don't print out virtual function table. */
1578 if ((TYPE_FIELD_NAME (type
, i
))[5] == CPLUS_MARKER
&&
1579 !strncmp (TYPE_FIELD_NAME (type
, i
), "_vptr", 5))
1582 print_spaces_filtered (level
+ 4, stream
);
1583 if (TYPE_FIELD_STATIC (type
, i
))
1585 fprintf_filtered (stream
, "static ");
1587 type_print_1 (TYPE_FIELD_TYPE (type
, i
),
1588 TYPE_FIELD_NAME (type
, i
),
1589 stream
, show
- 1, level
+ 4);
1590 if (!TYPE_FIELD_STATIC (type
, i
)
1591 && TYPE_FIELD_PACKED (type
, i
))
1593 /* It is a bitfield. This code does not attempt
1594 to look at the bitpos and reconstruct filler,
1595 unnamed fields. This would lead to misleading
1596 results if the compiler does not put out fields
1597 for such things (I don't know what it does). */
1598 fprintf_filtered (stream
, " : %d",
1599 TYPE_FIELD_BITSIZE (type
, i
));
1601 fprintf_filtered (stream
, ";\n");
1604 /* C++: print out the methods */
1605 len
= TYPE_NFN_FIELDS (type
);
1606 if (len
) fprintf_filtered (stream
, "\n");
1607 for (i
= 0; i
< len
; i
++)
1609 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (type
, i
);
1610 int j
, len2
= TYPE_FN_FIELDLIST_LENGTH (type
, i
);
1612 for (j
= 0; j
< len2
; j
++)
1615 print_spaces_filtered (level
+ 4, stream
);
1616 if (TYPE_FN_FIELD_VIRTUAL_P (f
, j
))
1617 fprintf_filtered (stream
, "virtual ");
1618 else if (TYPE_FN_FIELD_STATIC_P (f
, j
))
1619 fprintf_filtered (stream
, "static ");
1620 type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f
, j
)), "", stream
, 0);
1621 if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f
, j
)) & TYPE_FLAG_STUB
)
1623 /* Build something we can demangle. */
1624 char *strchr (), *gdb_mangle_typename ();
1625 char *inner_name
= gdb_mangle_typename (type
);
1627 = (char *)xmalloc (strlen (TYPE_FN_FIELDLIST_NAME (type
, i
))
1628 + strlen (inner_name
)
1629 + strlen (TYPE_FN_FIELD_PHYSNAME (f
, j
))
1631 char *demangled_name
, *cplus_demangle ();
1632 strcpy (mangled_name
, TYPE_FN_FIELDLIST_NAME (type
, i
));
1633 strcat (mangled_name
, inner_name
);
1634 strcat (mangled_name
, TYPE_FN_FIELD_PHYSNAME (f
, j
));
1635 demangled_name
= cplus_demangle (mangled_name
, 1);
1636 if (demangled_name
== 0)
1637 fprintf_filtered (stream
, " <badly mangled name %s>",
1641 fprintf_filtered (stream
, " %s",
1642 strchr (demangled_name
, ':') + 2);
1643 free (demangled_name
);
1645 free (mangled_name
);
1647 else if (TYPE_FN_FIELD_PHYSNAME (f
, j
)[0] == '_'
1648 && TYPE_FN_FIELD_PHYSNAME (f
, j
)[1] == CPLUS_MARKER
)
1649 type_print_method_args
1650 (TYPE_FN_FIELD_ARGS (f
, j
) + 1, "~",
1651 TYPE_FN_FIELDLIST_NAME (type
, i
), 0, stream
);
1653 type_print_method_args
1654 (TYPE_FN_FIELD_ARGS (f
, j
), "",
1655 TYPE_FN_FIELDLIST_NAME (type
, i
),
1656 TYPE_FN_FIELD_STATIC_P (f
, j
), stream
);
1658 fprintf_filtered (stream
, ";\n");
1662 print_spaces_filtered (level
, stream
);
1663 fprintf_filtered (stream
, "}");
1667 case TYPE_CODE_ENUM
:
1668 fprintf_filtered (stream
, "enum ");
1669 if (name
= type_name_no_tag (type
))
1671 fputs_filtered (name
, stream
);
1672 fputs_filtered (" ", stream
);
1675 fprintf_filtered (stream
, "{...}");
1678 fprintf_filtered (stream
, "{");
1679 len
= TYPE_NFIELDS (type
);
1681 for (i
= 0; i
< len
; i
++)
1684 if (i
) fprintf_filtered (stream
, ", ");
1685 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
1686 if (lastval
!= TYPE_FIELD_BITPOS (type
, i
))
1688 fprintf_filtered (stream
, " = %d", TYPE_FIELD_BITPOS (type
, i
));
1689 lastval
= TYPE_FIELD_BITPOS (type
, i
);
1693 fprintf_filtered (stream
, "}");
1698 if (TYPE_LENGTH (type
) > sizeof (LONGEST
))
1700 fprintf_filtered (stream
, "<%d bit integer>",
1701 TYPE_LENGTH (type
) * TARGET_CHAR_BIT
);
1705 if (TYPE_UNSIGNED (type
))
1706 name
= unsigned_type_table
[TYPE_LENGTH (type
)];
1708 name
= signed_type_table
[TYPE_LENGTH (type
)];
1710 fputs_filtered (name
, stream
);
1714 name
= float_type_table
[TYPE_LENGTH (type
)];
1715 fputs_filtered (name
, stream
);
1718 case TYPE_CODE_VOID
:
1719 fprintf_filtered (stream
, "void");
1723 fprintf_filtered (stream
, "struct unknown");
1726 case TYPE_CODE_ERROR
:
1727 fprintf_filtered (stream
, "<unknown type>");
1731 error ("Invalid type code in symbol table.");
1735 /* Validate an input or output radix setting, and make sure the user
1736 knows what they really did here. Radix setting is confusing, e.g.
1737 setting the input radix to "10" never changes it! */
1740 set_input_radix (args
, from_tty
, c
)
1743 struct cmd_list_element
*c
;
1745 unsigned radix
= *(unsigned *)c
->var
;
1748 printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n",
1749 radix
, radix
, radix
);
1753 set_output_radix (args
, from_tty
, c
)
1756 struct cmd_list_element
*c
;
1758 unsigned radix
= *(unsigned *)c
->var
;
1761 printf_filtered ("Output radix set to decimal %d, hex %x, octal %o\n",
1762 radix
, radix
, radix
);
1764 /* FIXME, we really should be able to validate the setting BEFORE
1769 output_format
= 'x';
1775 output_format
= 'o'; /* octal */
1779 error ("Unsupported radix ``decimal %d''; using decimal output",
1786 set_radix (arg
, from_tty
, c
)
1789 struct cmd_list_element
*c
;
1791 unsigned radix
= *(unsigned *)c
->var
;
1794 printf_filtered ("Radix set to decimal %d, hex %x, octal %o\n",
1795 radix
, radix
, radix
);
1797 input_radix
= radix
;
1798 output_radix
= radix
;
1800 set_output_radix (arg
, 0, c
);
1803 struct cmd_list_element
*setprintlist
= NULL
;
1804 struct cmd_list_element
*showprintlist
= NULL
;
1808 set_print (arg
, from_tty
)
1813 "\"set print\" must be followed by the name of a print subcommand.\n");
1814 help_list (setprintlist
, "set print ", -1, stdout
);
1819 show_print (args
, from_tty
)
1823 cmd_show_list (showprintlist
, from_tty
, "");
1827 _initialize_valprint ()
1829 struct cmd_list_element
*c
;
1831 add_prefix_cmd ("print", no_class
, set_print
,
1832 "Generic command for setting how things print.",
1833 &setprintlist
, "set print ", 0, &setlist
);
1834 add_prefix_cmd ("print", no_class
, show_print
,
1835 "Generic command for showing print settings.",
1836 &showprintlist
, "show print ", 0, &showlist
);
1839 (add_set_cmd ("elements", no_class
, var_uinteger
, (char *)&print_max
,
1840 "Set limit on string chars or array elements to print.\n\
1841 \"set print elements 0\" causes there to be no limit.",
1846 (add_set_cmd ("pretty", class_support
, var_boolean
, (char *)&prettyprint
,
1847 "Set prettyprinting of structures.",
1852 (add_set_cmd ("union", class_support
, var_boolean
, (char *)&unionprint
,
1853 "Set printing of unions interior to structures.",
1858 (add_set_cmd ("vtbl", class_support
, var_boolean
, (char *)&vtblprint
,
1859 "Set printing of C++ virtual function tables.",
1864 (add_set_cmd ("array", class_support
, var_boolean
, (char *)&arrayprint
,
1865 "Set prettyprinting of arrays.",
1870 (add_set_cmd ("address", class_support
, var_boolean
, (char *)&addressprint
,
1871 "Set printing of addresses.",
1876 /* The "show radix" cmd isn't good enough to show two separate values.
1877 The rest of the code works, but the show part is confusing, so don't
1878 let them be set separately 'til we work out "show". */
1879 c
= add_set_cmd ("input-radix", class_support
, var_uinteger
,
1880 (char *)&input_radix
,
1881 "Set default input radix for entering numbers.",
1883 add_show_from_set (c
, &showlist
);
1884 c
->function
= set_input_radix
;
1886 c
= add_set_cmd ("output-radix", class_support
, var_uinteger
,
1887 (char *)&output_radix
,
1888 "Set default output radix for printing of values.",
1890 add_show_from_set (c
, &showlist
);
1891 c
->function
= set_output_radix
;
1894 c
= add_set_cmd ("radix", class_support
, var_uinteger
,
1895 (char *)&output_radix
,
1896 "Set default input and output number radix.",
1898 add_show_from_set (c
, &showlist
);
1899 c
->function
= set_radix
;
1901 /* Give people the defaults which they are used to. */
1911 = (char **) xmalloc ((1 + sizeof (unsigned LONGEST
)) * sizeof (char *));
1912 bzero (unsigned_type_table
, (1 + sizeof (unsigned LONGEST
)));
1913 unsigned_type_table
[sizeof (unsigned char)] = "unsigned char";
1914 unsigned_type_table
[sizeof (unsigned short)] = "unsigned short";
1915 unsigned_type_table
[sizeof (unsigned long)] = "unsigned long";
1916 unsigned_type_table
[sizeof (unsigned int)] = "unsigned int";
1918 unsigned_type_table
[sizeof (unsigned long long)] = "unsigned long long";
1922 = (char **) xmalloc ((1 + sizeof (LONGEST
)) * sizeof (char *));
1923 bzero (signed_type_table
, (1 + sizeof (LONGEST
)));
1924 signed_type_table
[sizeof (char)] = "char";
1925 signed_type_table
[sizeof (short)] = "short";
1926 signed_type_table
[sizeof (long)] = "long";
1927 signed_type_table
[sizeof (int)] = "int";
1929 signed_type_table
[sizeof (long long)] = "long long";
1933 = (char **) xmalloc ((1 + sizeof (double)) * sizeof (char *));
1934 bzero (float_type_table
, (1 + sizeof (double)));
1935 float_type_table
[sizeof (float)] = "float";
1936 float_type_table
[sizeof (double)] = "double";
1937 obstack_begin (&dont_print_obstack
, 32 * sizeof (struct type
*));