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
))
509 char *valp
= (char *) & val
;
511 val
= unpack_field_as_long (type
, valaddr
, i
);
513 /* Since we have moved the bitfield into a long,
514 if it is declared with a smaller type, we need to
515 offset its address *in gdb* to match the type we
516 are passing to val_print. */
517 #if HOST_BYTE_ORDER == BIG_ENDIAN
518 valp
+= sizeof val
- TYPE_LENGTH (TYPE_FIELD_TYPE (type
, i
));
520 val_print (TYPE_FIELD_TYPE (type
, i
), valp
, 0,
521 stream
, format
, 0, recurse
+ 1, pretty
);
525 val_print (TYPE_FIELD_TYPE (type
, i
),
526 valaddr
+ TYPE_FIELD_BITPOS (type
, i
) / 8,
527 0, stream
, format
, 0, recurse
+ 1, pretty
);
532 fprintf_filtered (stream
, "\n");
533 print_spaces_filtered (2 * recurse
, stream
);
536 fprintf_filtered (stream
, "}");
539 /* Special val_print routine to avoid printing multiple copies of virtual
543 cplus_val_print (type
, valaddr
, stream
, format
, recurse
, pretty
, dont_print
)
549 enum val_prettyprint pretty
;
550 struct type
**dont_print
;
552 struct obstack tmp_obstack
;
553 struct type
**last_dont_print
554 = (struct type
**)obstack_next_free (&dont_print_obstack
);
555 int i
, n_baseclasses
= TYPE_N_BASECLASSES (type
);
559 /* If we're at top level, carve out a completely fresh
560 chunk of the obstack and use that until this particular
561 invocation returns. */
562 tmp_obstack
= dont_print_obstack
;
563 /* Bump up the high-water mark. Now alpha is omega. */
564 obstack_finish (&dont_print_obstack
);
567 for (i
= 0; i
< n_baseclasses
; i
++)
571 if (BASETYPE_VIA_VIRTUAL (type
, i
))
573 struct type
**first_dont_print
574 = (struct type
**)obstack_base (&dont_print_obstack
);
576 int j
= (struct type
**)obstack_next_free (&dont_print_obstack
)
580 if (TYPE_BASECLASS (type
, i
) == first_dont_print
[j
])
583 obstack_ptr_grow (&dont_print_obstack
, TYPE_BASECLASS (type
, i
));
586 baddr
= baseclass_addr (type
, i
, valaddr
, 0);
588 error ("could not find virtual baseclass `%s'\n",
589 type_name_no_tag (TYPE_BASECLASS (type
, i
)));
591 fprintf_filtered (stream
, "\n");
593 print_spaces_filtered (2 + 2 * recurse
, stream
);
594 fputs_filtered ("<", stream
);
595 fputs_filtered (type_name_no_tag (TYPE_BASECLASS (type
, i
)), stream
);
596 fputs_filtered ("> = ", stream
);
597 val_print_fields (TYPE_BASECLASS (type
, i
), baddr
, stream
, format
,
599 (struct type
**)obstack_base (&dont_print_obstack
));
606 /* Free the space used to deal with the printing
607 of this type from top level. */
608 obstack_free (&dont_print_obstack
, last_dont_print
);
609 /* Reset watermark so that we can continue protecting
610 ourselves from whatever we were protecting ourselves. */
611 dont_print_obstack
= tmp_obstack
;
615 /* Print data of type TYPE located at VALADDR (within GDB),
616 which came from the inferior at address ADDRESS,
617 onto stdio stream STREAM according to FORMAT
618 (a letter or 0 for natural format). The data at VALADDR
619 is in target byte order.
621 If the data are a string pointer, returns the number of
622 sting characters printed.
624 if DEREF_REF is nonzero, then dereference references,
625 otherwise just print them like pointers.
627 The PRETTY parameter controls prettyprinting. */
630 val_print (type
, valaddr
, address
, stream
, format
,
631 deref_ref
, recurse
, pretty
)
639 enum val_prettyprint pretty
;
641 register unsigned int i
;
643 struct type
*elttype
;
648 if (pretty
== Val_pretty_default
)
650 pretty
= prettyprint
? Val_prettyprint
: Val_no_prettyprint
;
655 check_stub_type (type
);
657 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
659 fprintf_filtered (stream
, "<unknown struct>");
664 switch (TYPE_CODE (type
))
666 case TYPE_CODE_ARRAY
:
667 if (TYPE_LENGTH (type
) >= 0
668 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
670 elttype
= TYPE_TARGET_TYPE (type
);
671 eltlen
= TYPE_LENGTH (elttype
);
672 len
= TYPE_LENGTH (type
) / eltlen
;
674 print_spaces_filtered (2 + 2 * recurse
, stream
);
675 fprintf_filtered (stream
, "{");
676 /* For an array of chars, print with string syntax. */
677 if (eltlen
== 1 && TYPE_CODE (elttype
) == TYPE_CODE_INT
678 && (format
== 0 || format
== 's') )
679 print_string (stream
, valaddr
, len
, 0);
682 unsigned int things_printed
= 0;
684 for (i
= 0; i
< len
&& things_printed
< print_max
; i
++)
686 /* Position of the array element we are examining to see
687 whether it is repeated. */
689 /* Number of repetitions we have detected so far. */
695 fprintf_filtered (stream
, ",\n");
696 print_spaces_filtered (2 + 2 * recurse
, stream
);
699 fprintf_filtered (stream
, ", ");
700 wrap_here (n_spaces (2 + 2 * recurse
));
705 && !bcmp (valaddr
+ i
* eltlen
,
706 valaddr
+ rep1
* eltlen
, eltlen
))
712 if (reps
> REPEAT_COUNT_THRESHOLD
)
714 val_print (elttype
, valaddr
+ i
* eltlen
,
715 0, stream
, format
, deref_ref
,
716 recurse
+ 1, pretty
);
717 fprintf_filtered (stream
, " <repeats %u times>", reps
);
719 things_printed
+= REPEAT_COUNT_THRESHOLD
;
723 val_print (elttype
, valaddr
+ i
* eltlen
,
724 0, stream
, format
, deref_ref
,
725 recurse
+ 1, pretty
);
730 fprintf_filtered (stream
, "...");
732 fprintf_filtered (stream
, "}");
735 /* Array of unspecified length: treat like pointer to first elt. */
736 valaddr
= (char *) &address
;
739 if (format
&& format
!= 's')
741 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
744 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_METHOD
)
746 struct type
*domain
= TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type
));
751 val
= unpack_long (builtin_type_int
, valaddr
);
754 len
= TYPE_NFN_FIELDS (domain
);
755 for (i
= 0; i
< len
; i
++)
757 f
= TYPE_FN_FIELDLIST1 (domain
, i
);
758 len2
= TYPE_FN_FIELDLIST_LENGTH (domain
, i
);
760 for (j
= 0; j
< len2
; j
++)
763 if (TYPE_FN_FIELD_VOFFSET (f
, j
) == val
)
773 struct symbol
*sym
= find_pc_function ((CORE_ADDR
) val
);
775 error ("invalid pointer to member function");
776 len
= TYPE_NFN_FIELDS (domain
);
777 for (i
= 0; i
< len
; i
++)
779 f
= TYPE_FN_FIELDLIST1 (domain
, i
);
780 len2
= TYPE_FN_FIELDLIST_LENGTH (domain
, i
);
782 for (j
= 0; j
< len2
; j
++)
785 if (!strcmp (SYMBOL_NAME (sym
), TYPE_FN_FIELD_PHYSNAME (f
, j
)))
793 fprintf_filtered (stream
, "&");
794 type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f
, j
), stream
, 0, 0);
795 fprintf (stream
, kind
);
796 if (TYPE_FN_FIELD_PHYSNAME (f
, j
)[0] == '_'
797 && TYPE_FN_FIELD_PHYSNAME (f
, j
)[1] == CPLUS_MARKER
)
798 type_print_method_args
799 (TYPE_FN_FIELD_ARGS (f
, j
) + 1, "~",
800 TYPE_FN_FIELDLIST_NAME (domain
, i
), 0, stream
);
802 type_print_method_args
803 (TYPE_FN_FIELD_ARGS (f
, j
), "",
804 TYPE_FN_FIELDLIST_NAME (domain
, i
), 0, stream
);
807 fprintf_filtered (stream
, "(");
808 type_print (type
, "", stream
, -1);
809 fprintf_filtered (stream
, ") %d", (int) val
>> 3);
811 else if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_MEMBER
)
813 struct type
*domain
= TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type
));
815 /* VAL is a byte offset into the structure type DOMAIN.
816 Find the name of the field for that offset and
820 len
= TYPE_NFIELDS (domain
);
821 /* @@ Make VAL into bit offset */
822 val
= unpack_long (builtin_type_int
, valaddr
) << 3;
823 for (i
= TYPE_N_BASECLASSES (domain
); i
< len
; i
++)
825 int bitpos
= TYPE_FIELD_BITPOS (domain
, i
);
829 if (val
< bitpos
&& i
!= 0)
831 /* Somehow pointing into a field. */
833 extra
= (val
- TYPE_FIELD_BITPOS (domain
, i
));
843 fprintf_filtered (stream
, "&");
844 type_print_base (domain
, stream
, 0, 0);
845 fprintf_filtered (stream
, "::");
846 fputs_filtered (TYPE_FIELD_NAME (domain
, i
), stream
);
848 fprintf_filtered (stream
, " + %d bytes", extra
);
850 fprintf_filtered (stream
, " (offset in bits)");
853 fprintf_filtered (stream
, "%d", val
>> 3);
857 CORE_ADDR addr
= (CORE_ADDR
) unpack_long (type
, valaddr
);
858 elttype
= TYPE_TARGET_TYPE (type
);
860 if (TYPE_CODE (elttype
) == TYPE_CODE_FUNC
)
862 /* Try to print what function it points to. */
863 print_address_demangle (addr
, stream
, demangle
);
864 /* Return value is irrelevant except for string pointers. */
868 if (addressprint
&& format
!= 's')
869 fprintf_filtered (stream
, "0x%x", addr
);
871 /* For a pointer to char or unsigned char,
872 also print the string pointed to, unless pointer is null. */
873 i
= 0; /* Number of characters printed. */
874 if (TYPE_LENGTH (elttype
) == 1
875 && TYPE_CODE (elttype
) == TYPE_CODE_INT
876 && (format
== 0 || format
== 's')
878 /* If print_max is UINT_MAX, the alloca below will fail.
879 In that case don't try to print the string. */
880 && print_max
< UINT_MAX
)
882 int first_addr_err
= 0;
885 /* Get first character. */
886 errcode
= target_read_memory (addr
, (char *)&c
, 1);
889 /* First address out of bounds. */
895 char *string
= (char *) alloca (print_max
);
897 /* If the loop ends by us hitting print_max characters,
898 we need to have elipses at the end. */
899 int force_ellipses
= 1;
901 /* This loop always fetches print_max characters, even
902 though print_string might want to print more or fewer
903 (with repeated characters). This is so that
904 we don't spend forever fetching if we print
905 a long string consisting of the same character
906 repeated. Also so we can do it all in one memory
907 operation, which is faster. However, this will be
908 slower if print_max is set high, e.g. if you set
909 print_max to 1000, not only will it take a long
910 time to fetch short strings, but if you are near
911 the end of the address space, it might not work.
914 errcode
= target_read_memory (addr
, string
, print_max
);
918 for (i
= 0; i
< print_max
; i
++)
919 if (string
[i
] == '\0')
927 fputs_filtered (" ", stream
);
928 print_string (stream
, string
, i
, force_ellipses
);
935 fprintf_filtered (stream
,
936 (" <Address 0x%x out of bounds>"
942 if (errcode
>= sys_nerr
|| errcode
< 0)
943 error ("Error reading memory address 0x%x: unknown error (%d).",
946 error ("Error reading memory address 0x%x: %s.",
947 addr
+ i
, sys_errlist
[errcode
]);
953 else /* print vtbl's nicely */
954 if (is_vtbl_member(type
))
956 CORE_ADDR vt_address
= (CORE_ADDR
) unpack_long (type
, valaddr
);
958 int vt_index
= find_pc_misc_function (vt_address
);
960 && vt_address
== misc_function_vector
[vt_index
].address
)
962 fputs_filtered (" <", stream
);
963 fputs_demangled (misc_function_vector
[vt_index
].name
,
965 fputs_filtered (">", stream
);
971 val
= value_at (TYPE_TARGET_TYPE (type
), vt_address
);
972 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
),
973 VALUE_ADDRESS (val
), stream
, format
,
974 deref_ref
, recurse
+ 1, pretty
);
977 fprintf_filtered (stream
, "\n");
978 print_spaces_filtered (2 + 2 * recurse
, stream
);
983 /* Return number of characters printed, plus one for the
984 terminating null if we have "reached the end". */
985 return i
+ (print_max
&& i
!= print_max
);
989 case TYPE_CODE_MEMBER
:
990 error ("not implemented: member type in val_print");
996 fprintf_filtered (stream
, "@0x%lx",
997 unpack_long (builtin_type_int
, valaddr
));
999 fputs_filtered (": ", stream
);
1001 /* De-reference the reference. */
1004 if (TYPE_CODE (TYPE_TARGET_TYPE (type
)) != TYPE_CODE_UNDEF
)
1006 value val
= value_at (TYPE_TARGET_TYPE (type
),
1007 (CORE_ADDR
) unpack_long (builtin_type_int
,
1009 val_print (VALUE_TYPE (val
), VALUE_CONTENTS (val
),
1010 VALUE_ADDRESS (val
), stream
, format
,
1011 deref_ref
, recurse
+ 1, pretty
);
1014 fputs_filtered ("???", stream
);
1018 case TYPE_CODE_UNION
:
1019 if (recurse
&& !unionprint
)
1021 fprintf_filtered (stream
, "{...}");
1025 case TYPE_CODE_STRUCT
:
1026 if (vtblprint
&& is_vtbl_ptr_type(type
))
1028 /* Print the unmangled name if desired. */
1029 print_address_demangle(*((int *) (valaddr
+ /* FIXME bytesex */
1030 TYPE_FIELD_BITPOS (type
, VTBL_FNADDR_OFFSET
) / 8)),
1034 val_print_fields (type
, valaddr
, stream
, format
, recurse
, pretty
, 0);
1037 case TYPE_CODE_ENUM
:
1040 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
1043 len
= TYPE_NFIELDS (type
);
1044 val
= unpack_long (builtin_type_int
, valaddr
);
1045 for (i
= 0; i
< len
; i
++)
1048 if (val
== TYPE_FIELD_BITPOS (type
, i
))
1052 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
1054 fprintf_filtered (stream
, "%d", (int) val
);
1057 case TYPE_CODE_FUNC
:
1060 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
1063 fprintf_filtered (stream
, "{");
1064 type_print (type
, "", stream
, -1);
1065 fprintf_filtered (stream
, "} ");
1067 fprintf_filtered (stream
, "0x%x", address
);
1071 if (format
|| output_format
)
1073 print_scalar_formatted (valaddr
, type
,
1074 format
? format
: output_format
,
1078 if (TYPE_LENGTH (type
) > sizeof (LONGEST
))
1080 if (TYPE_UNSIGNED (type
))
1082 /* First figure out whether the number in fact has zeros
1083 in all its bytes more significant than least significant
1084 sizeof (LONGEST) ones. */
1086 /* Pointer to first (i.e. lowest address) nonzero character. */
1088 unsigned len
= TYPE_LENGTH (type
);
1090 #if TARGET_BYTE_ORDER == BIG_ENDIAN
1092 len
> sizeof (LONGEST
)
1093 && p
< valaddr
+ TYPE_LENGTH (type
);
1095 #else /* Little endian. */
1096 first_addr
= valaddr
;
1097 for (p
= valaddr
+ TYPE_LENGTH (type
);
1098 len
> sizeof (LONGEST
) && p
>= valaddr
;
1100 #endif /* Little endian. */
1107 #if TARGET_BYTE_ORDER == BIG_ENDIAN
1111 if (len
<= sizeof (LONGEST
))
1113 /* We can print it in decimal. */
1116 #if defined (LONG_LONG)
1121 unpack_long (BUILTIN_TYPE_LONGEST
, first_addr
));
1125 /* It is big, so print it in hex. */
1126 print_hex_chars (stream
, (unsigned char *)first_addr
, len
);
1131 /* Signed. One could assume two's complement (a reasonable
1132 assumption, I think) and do better than this. */
1133 print_hex_chars (stream
, (unsigned char *)valaddr
,
1134 TYPE_LENGTH (type
));
1138 #ifdef PRINT_TYPELESS_INTEGER
1139 PRINT_TYPELESS_INTEGER (stream
, type
, unpack_long (type
, valaddr
));
1142 fprintf_filtered (stream
,
1143 TYPE_UNSIGNED (type
) ? "%u" : "%d",
1144 unpack_long (type
, valaddr
));
1146 fprintf_filtered (stream
,
1147 TYPE_UNSIGNED (type
) ? "%llu" : "%lld",
1148 unpack_long (type
, valaddr
));
1152 if (TYPE_LENGTH (type
) == 1)
1154 fprintf_filtered (stream
, " '");
1155 printchar ((unsigned char) unpack_long (type
, valaddr
),
1157 fprintf_filtered (stream
, "'");
1163 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
1165 print_floating (valaddr
, type
, stream
);
1168 case TYPE_CODE_VOID
:
1169 fprintf_filtered (stream
, "void");
1172 case TYPE_CODE_UNDEF
:
1173 /* This happens (without TYPE_FLAG_STUB set) on systems which don't use
1174 dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
1175 and no complete type for struct foo in that file. */
1176 fprintf_filtered (stream
, "<unknown struct>");
1179 case TYPE_CODE_ERROR
:
1180 fprintf_filtered (stream
, "?");
1184 error ("Invalid type code in symbol table.");
1190 /* Print a description of a type TYPE
1191 in the form of a declaration of a variable named VARSTRING.
1192 (VARSTRING is demangled if necessary.)
1193 Output goes to STREAM (via stdio).
1194 If SHOW is positive, we show the contents of the outermost level
1195 of structure even if there is a type name that could be used instead.
1196 If SHOW is negative, we never show the details of elements' types. */
1199 type_print (type
, varstring
, stream
, show
)
1205 type_print_1 (type
, varstring
, stream
, show
, 0);
1208 /* LEVEL is the depth to indent lines by. */
1211 type_print_1 (type
, varstring
, stream
, show
, level
)
1218 register enum type_code code
;
1219 type_print_base (type
, stream
, show
, level
);
1220 code
= TYPE_CODE (type
);
1221 if ((varstring
&& *varstring
)
1223 /* Need a space if going to print stars or brackets;
1224 but not if we will print just a type name. */
1225 ((show
> 0 || TYPE_NAME (type
) == 0)
1227 (code
== TYPE_CODE_PTR
|| code
== TYPE_CODE_FUNC
1228 || code
== TYPE_CODE_METHOD
1229 || code
== TYPE_CODE_ARRAY
1230 || code
== TYPE_CODE_MEMBER
1231 || code
== TYPE_CODE_REF
)))
1232 fprintf_filtered (stream
, " ");
1233 type_print_varspec_prefix (type
, stream
, show
, 0);
1234 fputs_demangled (varstring
, stream
, -1); /* Print demangled name
1235 without arguments */
1236 type_print_varspec_suffix (type
, stream
, show
, 0);
1239 /* Print the method arguments ARGS to the file STREAM. */
1241 type_print_method_args (args
, prefix
, varstring
, staticp
, stream
)
1243 char *prefix
, *varstring
;
1249 fputs_filtered (" ", stream
);
1250 fputs_demangled (prefix
, stream
, 1);
1251 fputs_demangled (varstring
, stream
, 1);
1252 fputs_filtered (" (", stream
);
1253 if (args
&& args
[!staticp
] && args
[!staticp
]->code
!= TYPE_CODE_VOID
)
1255 i
= !staticp
; /* skip the class variable */
1258 type_print (args
[i
++], "", stream
, 0);
1261 fprintf_filtered (stream
, " ...");
1264 else if (args
[i
]->code
!= TYPE_CODE_VOID
)
1266 fprintf_filtered (stream
, ", ");
1271 fprintf_filtered (stream
, ")");
1274 /* If TYPE is a derived type, then print out derivation
1275 information. Print out all layers of the type heirarchy
1276 until we encounter one with multiple inheritance.
1277 At that point, print out that ply, and return. */
1279 type_print_derivation_info (stream
, type
)
1284 int i
, n_baseclasses
= TYPE_N_BASECLASSES (type
);
1285 struct type
*basetype
= 0;
1287 while (type
&& n_baseclasses
> 0)
1289 /* Not actually sure about this one -- Bryan. */
1290 check_stub_type (type
);
1292 fprintf_filtered (stream
, ": ");
1295 basetype
= TYPE_BASECLASS (type
, i
);
1296 if (name
= type_name_no_tag (basetype
))
1298 fprintf_filtered (stream
, "%s%s ",
1299 BASETYPE_VIA_PUBLIC(type
, i
) ? "public" : "private",
1300 BASETYPE_VIA_VIRTUAL(type
, i
) ? " virtual" : "");
1301 fputs_filtered (name
, stream
);
1304 if (i
>= n_baseclasses
)
1306 fprintf_filtered (stream
, ", ");
1309 fprintf_filtered (stream
, " ");
1310 if (n_baseclasses
!= 1)
1312 n_baseclasses
= TYPE_N_BASECLASSES (basetype
);
1317 /* Print any asterisks or open-parentheses needed before the
1318 variable name (to describe its type).
1320 On outermost call, pass 0 for PASSED_A_PTR.
1321 On outermost call, SHOW > 0 means should ignore
1322 any typename for TYPE and show its details.
1323 SHOW is always zero on recursive calls. */
1326 type_print_varspec_prefix (type
, stream
, show
, passed_a_ptr
)
1335 if (TYPE_NAME (type
) && show
<= 0)
1340 switch (TYPE_CODE (type
))
1343 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0, 1);
1344 fprintf_filtered (stream
, "*");
1347 case TYPE_CODE_MEMBER
:
1349 fprintf_filtered (stream
, "(");
1350 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1352 fprintf_filtered (stream
, " ");
1353 type_print_base (TYPE_DOMAIN_TYPE (type
), stream
, 0,
1355 fprintf_filtered (stream
, "::");
1358 case TYPE_CODE_METHOD
:
1360 fprintf (stream
, "(");
1361 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1363 fprintf_filtered (stream
, " ");
1364 type_print_base (TYPE_DOMAIN_TYPE (type
), stream
, 0,
1366 fprintf_filtered (stream
, "::");
1370 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0, 1);
1371 fprintf_filtered (stream
, "&");
1374 case TYPE_CODE_FUNC
:
1375 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1378 fprintf_filtered (stream
, "(");
1381 case TYPE_CODE_ARRAY
:
1382 type_print_varspec_prefix (TYPE_TARGET_TYPE (type
), stream
, 0,
1385 fprintf_filtered (stream
, "(");
1387 case TYPE_CODE_UNDEF
:
1388 case TYPE_CODE_STRUCT
:
1389 case TYPE_CODE_UNION
:
1390 case TYPE_CODE_ENUM
:
1393 case TYPE_CODE_VOID
:
1394 case TYPE_CODE_ERROR
:
1395 /* These types need no prefix. They are listed here so that
1396 gcc -Wall will reveal any types that haven't been handled. */
1401 /* Print any array sizes, function arguments or close parentheses
1402 needed after the variable name (to describe its type).
1403 Args work like type_print_varspec_prefix. */
1406 type_print_varspec_suffix (type
, stream
, show
, passed_a_ptr
)
1415 if (TYPE_NAME (type
) && show
<= 0)
1420 switch (TYPE_CODE (type
))
1422 case TYPE_CODE_ARRAY
:
1424 fprintf_filtered (stream
, ")");
1426 fprintf_filtered (stream
, "[");
1427 if (TYPE_LENGTH (type
) >= 0
1428 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
1429 fprintf_filtered (stream
, "%d",
1431 / TYPE_LENGTH (TYPE_TARGET_TYPE (type
))));
1432 fprintf_filtered (stream
, "]");
1434 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0,
1438 case TYPE_CODE_MEMBER
:
1440 fprintf_filtered (stream
, ")");
1441 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0, 0);
1444 case TYPE_CODE_METHOD
:
1446 fprintf_filtered (stream
, ")");
1447 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0, 0);
1451 struct type
**args
= TYPE_ARG_TYPES (type
);
1453 fprintf_filtered (stream
, "(");
1455 fprintf_filtered (stream
, "...");
1456 else for (i
= 1; args
[i
] != 0 && args
[i
]->code
!= TYPE_CODE_VOID
; i
++)
1458 type_print_1 (args
[i
], "", stream
, -1, 0);
1460 fprintf_filtered (stream
, "...");
1461 else if (args
[i
+1]->code
!= TYPE_CODE_VOID
)
1462 fprintf_filtered (stream
, ",");
1464 fprintf_filtered (stream
, ")");
1470 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0, 1);
1473 case TYPE_CODE_FUNC
:
1474 type_print_varspec_suffix (TYPE_TARGET_TYPE (type
), stream
, 0,
1477 fprintf_filtered (stream
, ")");
1478 fprintf_filtered (stream
, "()");
1481 case TYPE_CODE_UNDEF
:
1482 case TYPE_CODE_STRUCT
:
1483 case TYPE_CODE_UNION
:
1484 case TYPE_CODE_ENUM
:
1487 case TYPE_CODE_VOID
:
1488 case TYPE_CODE_ERROR
:
1489 /* These types do not need a suffix. They are listed so that
1490 gcc -Wall will report types that may not have been considered. */
1495 /* Print the name of the type (or the ultimate pointer target,
1496 function value or array element), or the description of a
1499 SHOW nonzero means don't print this type as just its name;
1500 show its real definition even if it has a name.
1501 SHOW zero means print just typename or struct tag if there is one
1502 SHOW negative means abbreviate structure elements.
1503 SHOW is decremented for printing of structure elements.
1505 LEVEL is the depth to indent by.
1506 We increase it for some recursive calls. */
1509 type_print_base (type
, stream
, show
, level
)
1518 register int lastval
;
1524 fprintf_filtered (stream
, "type unknown");
1528 if (TYPE_NAME (type
) && show
<= 0)
1530 fputs_filtered (TYPE_NAME (type
), stream
);
1534 switch (TYPE_CODE (type
))
1536 case TYPE_CODE_ARRAY
:
1538 case TYPE_CODE_MEMBER
:
1540 case TYPE_CODE_FUNC
:
1541 case TYPE_CODE_METHOD
:
1542 type_print_base (TYPE_TARGET_TYPE (type
), stream
, show
, level
);
1545 case TYPE_CODE_STRUCT
:
1546 fprintf_filtered (stream
, "struct ");
1549 case TYPE_CODE_UNION
:
1550 fprintf_filtered (stream
, "union ");
1552 if (name
= type_name_no_tag (type
))
1554 fputs_filtered (name
, stream
);
1555 fputs_filtered (" ", stream
);
1558 fprintf_filtered (stream
, "{...}");
1561 check_stub_type (type
);
1563 type_print_derivation_info (stream
, type
);
1565 fprintf_filtered (stream
, "{");
1566 len
= TYPE_NFIELDS (type
);
1568 fprintf_filtered (stream
, "\n");
1571 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
1572 fprintf_filtered (stream
, "<incomplete type>\n");
1574 fprintf_filtered (stream
, "<no data fields>\n");
1577 /* If there is a base class for this type,
1578 do not print the field that it occupies. */
1579 for (i
= TYPE_N_BASECLASSES (type
); i
< len
; i
++)
1582 /* Don't print out virtual function table. */
1583 if ((TYPE_FIELD_NAME (type
, i
))[5] == CPLUS_MARKER
&&
1584 !strncmp (TYPE_FIELD_NAME (type
, i
), "_vptr", 5))
1587 print_spaces_filtered (level
+ 4, stream
);
1588 if (TYPE_FIELD_STATIC (type
, i
))
1590 fprintf_filtered (stream
, "static ");
1592 type_print_1 (TYPE_FIELD_TYPE (type
, i
),
1593 TYPE_FIELD_NAME (type
, i
),
1594 stream
, show
- 1, level
+ 4);
1595 if (!TYPE_FIELD_STATIC (type
, i
)
1596 && TYPE_FIELD_PACKED (type
, i
))
1598 /* It is a bitfield. This code does not attempt
1599 to look at the bitpos and reconstruct filler,
1600 unnamed fields. This would lead to misleading
1601 results if the compiler does not put out fields
1602 for such things (I don't know what it does). */
1603 fprintf_filtered (stream
, " : %d",
1604 TYPE_FIELD_BITSIZE (type
, i
));
1606 fprintf_filtered (stream
, ";\n");
1609 /* C++: print out the methods */
1610 len
= TYPE_NFN_FIELDS (type
);
1611 if (len
) fprintf_filtered (stream
, "\n");
1612 for (i
= 0; i
< len
; i
++)
1614 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (type
, i
);
1615 int j
, len2
= TYPE_FN_FIELDLIST_LENGTH (type
, i
);
1617 for (j
= 0; j
< len2
; j
++)
1620 print_spaces_filtered (level
+ 4, stream
);
1621 if (TYPE_FN_FIELD_VIRTUAL_P (f
, j
))
1622 fprintf_filtered (stream
, "virtual ");
1623 else if (TYPE_FN_FIELD_STATIC_P (f
, j
))
1624 fprintf_filtered (stream
, "static ");
1625 type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f
, j
)), "", stream
, 0);
1626 if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f
, j
)) & TYPE_FLAG_STUB
)
1628 /* Build something we can demangle. */
1629 char *strchr (), *gdb_mangle_typename ();
1630 char *inner_name
= gdb_mangle_typename (type
);
1632 = (char *)xmalloc (strlen (TYPE_FN_FIELDLIST_NAME (type
, i
))
1633 + strlen (inner_name
)
1634 + strlen (TYPE_FN_FIELD_PHYSNAME (f
, j
))
1636 char *demangled_name
, *cplus_demangle ();
1637 strcpy (mangled_name
, TYPE_FN_FIELDLIST_NAME (type
, i
));
1638 strcat (mangled_name
, inner_name
);
1639 strcat (mangled_name
, TYPE_FN_FIELD_PHYSNAME (f
, j
));
1640 demangled_name
= cplus_demangle (mangled_name
, 1);
1641 if (demangled_name
== 0)
1642 fprintf_filtered (stream
, " <badly mangled name %s>",
1646 fprintf_filtered (stream
, " %s",
1647 strchr (demangled_name
, ':') + 2);
1648 free (demangled_name
);
1650 free (mangled_name
);
1652 else if (TYPE_FN_FIELD_PHYSNAME (f
, j
)[0] == '_'
1653 && TYPE_FN_FIELD_PHYSNAME (f
, j
)[1] == CPLUS_MARKER
)
1654 type_print_method_args
1655 (TYPE_FN_FIELD_ARGS (f
, j
) + 1, "~",
1656 TYPE_FN_FIELDLIST_NAME (type
, i
), 0, stream
);
1658 type_print_method_args
1659 (TYPE_FN_FIELD_ARGS (f
, j
), "",
1660 TYPE_FN_FIELDLIST_NAME (type
, i
),
1661 TYPE_FN_FIELD_STATIC_P (f
, j
), stream
);
1663 fprintf_filtered (stream
, ";\n");
1667 print_spaces_filtered (level
, stream
);
1668 fprintf_filtered (stream
, "}");
1672 case TYPE_CODE_ENUM
:
1673 fprintf_filtered (stream
, "enum ");
1674 if (name
= type_name_no_tag (type
))
1676 fputs_filtered (name
, stream
);
1677 fputs_filtered (" ", stream
);
1680 fprintf_filtered (stream
, "{...}");
1683 fprintf_filtered (stream
, "{");
1684 len
= TYPE_NFIELDS (type
);
1686 for (i
= 0; i
< len
; i
++)
1689 if (i
) fprintf_filtered (stream
, ", ");
1690 fputs_filtered (TYPE_FIELD_NAME (type
, i
), stream
);
1691 if (lastval
!= TYPE_FIELD_BITPOS (type
, i
))
1693 fprintf_filtered (stream
, " = %d", TYPE_FIELD_BITPOS (type
, i
));
1694 lastval
= TYPE_FIELD_BITPOS (type
, i
);
1698 fprintf_filtered (stream
, "}");
1703 if (TYPE_LENGTH (type
) > sizeof (LONGEST
))
1705 fprintf_filtered (stream
, "<%d bit integer>",
1706 TYPE_LENGTH (type
) * TARGET_CHAR_BIT
);
1710 if (TYPE_UNSIGNED (type
))
1711 name
= unsigned_type_table
[TYPE_LENGTH (type
)];
1713 name
= signed_type_table
[TYPE_LENGTH (type
)];
1715 fputs_filtered (name
, stream
);
1719 name
= float_type_table
[TYPE_LENGTH (type
)];
1720 fputs_filtered (name
, stream
);
1723 case TYPE_CODE_VOID
:
1724 fprintf_filtered (stream
, "void");
1728 fprintf_filtered (stream
, "struct unknown");
1731 case TYPE_CODE_ERROR
:
1732 fprintf_filtered (stream
, "<unknown type>");
1736 error ("Invalid type code in symbol table.");
1740 /* Validate an input or output radix setting, and make sure the user
1741 knows what they really did here. Radix setting is confusing, e.g.
1742 setting the input radix to "10" never changes it! */
1745 set_input_radix (args
, from_tty
, c
)
1748 struct cmd_list_element
*c
;
1750 unsigned radix
= *(unsigned *)c
->var
;
1753 printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n",
1754 radix
, radix
, radix
);
1758 set_output_radix (args
, from_tty
, c
)
1761 struct cmd_list_element
*c
;
1763 unsigned radix
= *(unsigned *)c
->var
;
1766 printf_filtered ("Output radix set to decimal %d, hex %x, octal %o\n",
1767 radix
, radix
, radix
);
1769 /* FIXME, we really should be able to validate the setting BEFORE
1774 output_format
= 'x';
1780 output_format
= 'o'; /* octal */
1784 error ("Unsupported radix ``decimal %d''; using decimal output",
1791 set_radix (arg
, from_tty
, c
)
1794 struct cmd_list_element
*c
;
1796 unsigned radix
= *(unsigned *)c
->var
;
1799 printf_filtered ("Radix set to decimal %d, hex %x, octal %o\n",
1800 radix
, radix
, radix
);
1802 input_radix
= radix
;
1803 output_radix
= radix
;
1805 set_output_radix (arg
, 0, c
);
1809 _initialize_valprint ()
1811 struct cmd_list_element
*c
;
1814 (add_set_cmd ("array-max", class_vars
, var_uinteger
, (char *)&print_max
,
1815 "Set limit on string chars or array elements to print.\n\
1816 \"set array-max 0\" causes there to be no limit.",
1821 (add_set_cmd ("prettyprint", class_support
, var_boolean
, (char *)&prettyprint
,
1822 "Set prettyprinting of structures.",
1826 add_alias_cmd ("pp", "prettyprint", class_support
, 1, &setlist
);
1829 (add_set_cmd ("unionprint", class_support
, var_boolean
, (char *)&unionprint
,
1830 "Set printing of unions interior to structures.",
1835 (add_set_cmd ("vtblprint", class_support
, var_boolean
, (char *)&vtblprint
,
1836 "Set printing of C++ virtual function tables.",
1841 (add_set_cmd ("arrayprint", class_support
, var_boolean
, (char *)&arrayprint
,
1842 "Set prettyprinting of arrays.",
1847 (add_set_cmd ("addressprint", class_support
, var_boolean
, (char *)&addressprint
,
1848 "Set printing of addresses.",
1853 /* The "show radix" cmd isn't good enough to show two separate values.
1854 The rest of the code works, but the show part is confusing, so don't
1855 let them be set separately 'til we work out "show". */
1856 c
= add_set_cmd ("input-radix", class_support
, var_uinteger
,
1857 (char *)&input_radix
,
1858 "Set default input radix for entering numbers.",
1860 add_show_from_set (c
, &showlist
);
1861 c
->function
= set_input_radix
;
1863 c
= add_set_cmd ("output-radix", class_support
, var_uinteger
,
1864 (char *)&output_radix
,
1865 "Set default output radix for printing of values.",
1867 add_show_from_set (c
, &showlist
);
1868 c
->function
= set_output_radix
;
1871 c
= add_set_cmd ("radix", class_support
, var_uinteger
,
1872 (char *)&output_radix
,
1873 "Set default input and output number radix.",
1875 add_show_from_set (c
, &showlist
);
1876 c
->function
= set_radix
;
1878 /* Give people the defaults which they are used to. */
1888 = (char **) xmalloc ((1 + sizeof (unsigned LONGEST
)) * sizeof (char *));
1889 bzero (unsigned_type_table
, (1 + sizeof (unsigned LONGEST
)));
1890 unsigned_type_table
[sizeof (unsigned char)] = "unsigned char";
1891 unsigned_type_table
[sizeof (unsigned short)] = "unsigned short";
1892 unsigned_type_table
[sizeof (unsigned long)] = "unsigned long";
1893 unsigned_type_table
[sizeof (unsigned int)] = "unsigned int";
1895 unsigned_type_table
[sizeof (unsigned long long)] = "unsigned long long";
1899 = (char **) xmalloc ((1 + sizeof (LONGEST
)) * sizeof (char *));
1900 bzero (signed_type_table
, (1 + sizeof (LONGEST
)));
1901 signed_type_table
[sizeof (char)] = "char";
1902 signed_type_table
[sizeof (short)] = "short";
1903 signed_type_table
[sizeof (long)] = "long";
1904 signed_type_table
[sizeof (int)] = "int";
1906 signed_type_table
[sizeof (long long)] = "long long";
1910 = (char **) xmalloc ((1 + sizeof (double)) * sizeof (char *));
1911 bzero (float_type_table
, (1 + sizeof (double)));
1912 float_type_table
[sizeof (float)] = "float";
1913 float_type_table
[sizeof (double)] = "double";
1914 obstack_begin (&dont_print_obstack
, 32 * sizeof (struct type
*));