1 /* Support for printing Ada values for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1997, 2001
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "expression.h"
34 /* Encapsulates arguments to ada_val_print. */
35 struct ada_val_print_args
{
40 struct ui_file
*stream
;
44 enum val_prettyprint pretty
;
47 extern int inspect_it
;
48 extern unsigned int repeat_count_threshold
;
50 static void print_record (struct type
*, char*, struct ui_file
*, int,
51 int, enum val_prettyprint
);
53 static int print_field_values (struct type
*, char*, struct ui_file
*,
54 int, int, enum val_prettyprint
,
55 int, struct type
*, char*);
57 static int print_variant_part (struct type
*, int, char*,
58 struct ui_file
*, int, int, enum val_prettyprint
,
59 int, struct type
*, char*);
62 val_print_packed_array_elements (struct type
*, char *valaddr
, int,
63 struct ui_file
*, int, int,
64 enum val_prettyprint
);
66 static void adjust_type_signedness (struct type
*);
68 static int ada_val_print_stub (PTR args0
);
71 ada_val_print_1 (struct type
*, char*, int, CORE_ADDR
, struct ui_file
*,
72 int, int, int, enum val_prettyprint
);
75 /* Make TYPE unsigned if its range of values includes no negatives. */
77 adjust_type_signedness (type
)
80 if (type
!= NULL
&& TYPE_CODE (type
) == TYPE_CODE_RANGE
81 && TYPE_LOW_BOUND (type
) >= 0)
82 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
85 /* Assuming TYPE is a simple array type, prints its lower bound on STREAM,
86 if non-standard (i.e., other than 1 for numbers, other than lower bound
87 of index type for enumerated type). Returns 1 if something printed,
91 print_optional_low_bound (struct ui_file
*stream
, struct type
*type
)
93 struct type
*index_type
;
96 index_type
= TYPE_INDEX_TYPE (type
);
99 if (index_type
== NULL
)
101 if (TYPE_CODE (index_type
) == TYPE_CODE_RANGE
)
103 low_bound
= TYPE_LOW_BOUND (index_type
);
104 index_type
= TYPE_TARGET_TYPE (index_type
);
109 switch (TYPE_CODE (index_type
)) {
111 if (low_bound
== TYPE_FIELD_BITPOS (index_type
, 0))
114 case TYPE_CODE_UNDEF
:
115 index_type
= builtin_type_long
;
123 ada_print_scalar (index_type
, (LONGEST
) low_bound
, stream
);
124 fprintf_filtered (stream
, " => ");
128 /* Version of val_print_array_elements for GNAT-style packed arrays.
129 Prints elements of packed array of type TYPE at bit offset
130 BITOFFSET from VALADDR on STREAM. Formats according to FORMAT and
131 separates with commas. RECURSE is the recursion (nesting) level.
132 If PRETTY, uses "prettier" format. TYPE must have been decoded (as
133 by ada_coerce_to_simple_array). */
136 val_print_packed_array_elements (struct type
*type
, char *valaddr
,
137 int bitoffset
, struct ui_file
*stream
,
138 int format
, int recurse
,
139 enum val_prettyprint pretty
)
142 unsigned int things_printed
= 0;
144 struct type
*elttype
;
146 /* Position of the array element we are examining to see
147 whether it is repeated. */
149 /* Number of repetitions we have detected so far. */
151 unsigned long bitsize
= TYPE_FIELD_BITSIZE (type
, 0);
152 struct value
* mark
= value_mark ();
154 elttype
= TYPE_TARGET_TYPE (type
);
155 eltlen
= TYPE_LENGTH (check_typedef (elttype
));
159 if (get_discrete_bounds (TYPE_FIELD_TYPE (type
, 0), &low
, &high
) < 0)
162 len
= high
- low
+ 1;
166 annotate_array_section_begin (i
, elttype
);
168 while (i
< len
&& things_printed
< print_max
)
170 struct value
*v0
, *v1
;
175 if (prettyprint_arrays
)
177 fprintf_filtered (stream
, ",\n");
178 print_spaces_filtered (2 + 2 * recurse
, stream
);
182 fprintf_filtered (stream
, ", ");
185 wrap_here (n_spaces (2 + 2 * recurse
));
188 v0
= ada_value_primitive_packed_val (NULL
, valaddr
,
189 (i0
* bitsize
) / HOST_CHAR_BIT
,
190 (i0
* bitsize
) % HOST_CHAR_BIT
,
197 v1
= ada_value_primitive_packed_val (NULL
, valaddr
,
198 (i
* bitsize
) / HOST_CHAR_BIT
,
199 (i
* bitsize
) % HOST_CHAR_BIT
,
201 if (memcmp (VALUE_CONTENTS (v0
), VALUE_CONTENTS (v1
), eltlen
)
206 if (i
- i0
> repeat_count_threshold
)
208 val_print (elttype
, VALUE_CONTENTS (v0
), 0, 0, stream
, format
,
209 0, recurse
+ 1, pretty
);
210 annotate_elt_rep (i
- i0
);
211 fprintf_filtered (stream
, " <repeats %u times>", i
- i0
);
212 annotate_elt_rep_end ();
218 for (j
= i0
; j
< i
; j
+= 1)
222 if (prettyprint_arrays
)
224 fprintf_filtered (stream
, ",\n");
225 print_spaces_filtered (2 + 2 * recurse
, stream
);
229 fprintf_filtered (stream
, ", ");
231 wrap_here (n_spaces (2 + 2 * recurse
));
233 val_print (elttype
, VALUE_CONTENTS (v0
), 0, 0, stream
, format
,
234 0, recurse
+ 1, pretty
);
238 things_printed
+= i
- i0
;
240 annotate_array_section_end ();
243 fprintf_filtered (stream
, "...");
246 value_free_to_mark (mark
);
250 printable_val_type (struct type
* type
, char* valaddr
)
252 return ada_to_fixed_type (ada_aligned_type (type
), valaddr
, 0, NULL
);
255 /* Print the character C on STREAM as part of the contents of a literal
256 string whose delimiter is QUOTER. TYPE_LEN is the length in bytes
257 (1 or 2) of the character. */
260 ada_emit_char (int c
, struct ui_file
*stream
, int quoter
, int type_len
)
265 c
&= (1 << (type_len
* TARGET_CHAR_BIT
)) - 1;
267 if (isascii (c
) && isprint (c
))
269 if (c
== quoter
&& c
== '"')
270 fprintf_filtered (stream
, "[\"%c\"]", quoter
);
272 fprintf_filtered (stream
, "%c", c
);
275 fprintf_filtered (stream
, "[\"%0*x\"]", type_len
*2, c
);
278 /* Character #I of STRING, given that TYPE_LEN is the size in bytes (1
279 or 2) of a character. */
282 char_at (char* string
, int i
, int type_len
)
287 return (int) extract_unsigned_integer (string
+ 2*i
, 2);
291 ada_printchar (int c
, struct ui_file
*stream
)
293 fputs_filtered ("'", stream
);
294 ada_emit_char (c
, stream
, '\'', 1);
295 fputs_filtered ("'", stream
);
298 /* [From print_type_scalar in typeprint.c]. Print VAL on STREAM in a
299 form appropriate for TYPE. */
302 ada_print_scalar (struct type
*type
, LONGEST val
, struct ui_file
*stream
)
307 CHECK_TYPEDEF (type
);
309 switch (TYPE_CODE (type
))
313 len
= TYPE_NFIELDS (type
);
314 for (i
= 0; i
< len
; i
++)
316 if (TYPE_FIELD_BITPOS (type
, i
) == val
)
323 fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type
, i
)), stream
);
327 print_longest (stream
, 'd', 0, val
);
332 print_longest (stream
, TYPE_UNSIGNED (type
) ? 'u' : 'd', 0, val
);
336 LA_PRINT_CHAR ((unsigned char) val
, stream
);
340 fprintf_filtered (stream
, val
? "true" : "false");
343 case TYPE_CODE_RANGE
:
344 ada_print_scalar (TYPE_TARGET_TYPE (type
), val
, stream
);
347 case TYPE_CODE_UNDEF
:
349 case TYPE_CODE_ARRAY
:
350 case TYPE_CODE_STRUCT
:
351 case TYPE_CODE_UNION
:
356 case TYPE_CODE_STRING
:
357 case TYPE_CODE_ERROR
:
358 case TYPE_CODE_MEMBER
:
359 case TYPE_CODE_METHOD
:
361 warning ("internal error: unhandled type in ada_print_scalar");
365 error ("Invalid type code in symbol table.");
370 /* Print the character string STRING, printing at most LENGTH characters.
371 Printing stops early if the number hits print_max; repeat counts
372 are printed as appropriate. Print ellipses at the end if we
373 had to stop before printing LENGTH characters, or if
374 FORCE_ELLIPSES. TYPE_LEN is the length (1 or 2) of the character type.
378 printstr (struct ui_file
*stream
, char *string
, unsigned int length
,
379 int force_ellipses
, int type_len
)
382 unsigned int things_printed
= 0;
388 fputs_filtered ("\"\"", stream
);
392 for (i
= 0; i
< length
&& things_printed
< print_max
; i
+= 1)
394 /* Position of the character we are examining
395 to see whether it is repeated. */
397 /* Number of repetitions we have detected so far. */
404 fputs_filtered (", ", stream
);
410 while (rep1
< length
&&
411 char_at(string
, rep1
, type_len
) == char_at (string
, i
, type_len
))
417 if (reps
> repeat_count_threshold
)
422 fputs_filtered ("\\\", ", stream
);
424 fputs_filtered ("\", ", stream
);
427 fputs_filtered ("'", stream
);
428 ada_emit_char (char_at (string
, i
, type_len
), stream
, '\'', type_len
);
429 fputs_filtered ("'", stream
);
430 fprintf_filtered (stream
, " <repeats %u times>", reps
);
432 things_printed
+= repeat_count_threshold
;
440 fputs_filtered ("\\\"", stream
);
442 fputs_filtered ("\"", stream
);
445 ada_emit_char (char_at (string
, i
, type_len
), stream
, '"',
451 /* Terminate the quotes if necessary. */
455 fputs_filtered ("\\\"", stream
);
457 fputs_filtered ("\"", stream
);
460 if (force_ellipses
|| i
< length
)
461 fputs_filtered ("...", stream
);
465 ada_printstr (struct ui_file
*stream
, char *string
, unsigned int length
,
466 int force_ellipses
, int width
)
468 printstr (stream
, string
, length
, force_ellipses
, width
);
472 /* Print data of type TYPE located at VALADDR (within GDB), which came from
473 the inferior at address ADDRESS, onto stdio stream STREAM according to
474 FORMAT (a letter as for the printf % codes or 0 for natural format).
475 The data at VALADDR is in target byte order.
477 If the data is printed as a string, returns the number of string characters
480 If DEREF_REF is nonzero, then dereference references, otherwise just print
483 RECURSE indicates the amount of indentation to supply before
484 continuation lines; this amount is roughly twice the value of RECURSE.
486 When PRETTY is non-zero, prints record fields on separate lines.
487 (For some reason, the current version of gdb instead uses a global
488 variable---prettyprint_arrays--- to causes a similar effect on
492 ada_val_print (struct type
* type
, char* valaddr0
, int embedded_offset
,
493 CORE_ADDR address
, struct ui_file
*stream
, int format
,
494 int deref_ref
, int recurse
, enum val_prettyprint pretty
)
496 struct ada_val_print_args args
;
497 args
.type
= type
; args
.valaddr0
= valaddr0
;
498 args
.embedded_offset
= embedded_offset
;
499 args
.address
= address
;
500 args
.stream
= stream
;
501 args
.format
= format
;
502 args
.deref_ref
= deref_ref
;
503 args
.recurse
= recurse
;
504 args
.pretty
= pretty
;
506 return catch_errors (ada_val_print_stub
, &args
, NULL
, RETURN_MASK_ALL
);
509 /* Helper for ada_val_print; used as argument to catch_errors to
510 unmarshal the arguments to ada_val_print_1, which does the work. */
512 ada_val_print_stub (PTR args0
)
514 struct ada_val_print_args
* argsp
= (struct ada_val_print_args
*) args0
;
515 return ada_val_print_1 (argsp
->type
, argsp
->valaddr0
, argsp
->embedded_offset
,
516 argsp
->address
, argsp
->stream
, argsp
->format
,
517 argsp
->deref_ref
, argsp
->recurse
,
521 /* See the comment on ada_val_print. This function differs in that it
522 * does not catch evaluation errors (leaving that to ada_val_print). */
525 ada_val_print_1 (struct type
* type
, char* valaddr0
, int embedded_offset
,
526 CORE_ADDR address
, struct ui_file
*stream
, int format
,
527 int deref_ref
, int recurse
, enum val_prettyprint pretty
)
531 struct type
*elttype
;
535 char* valaddr
= valaddr0
+ embedded_offset
;
537 CHECK_TYPEDEF (type
);
539 if (ada_is_array_descriptor (type
) || ada_is_packed_array_type (type
))
542 struct value
* mark
= value_mark ();
544 val
= value_from_contents_and_address (type
, valaddr
, address
);
545 val
= ada_coerce_to_simple_array_ptr (val
);
548 fprintf_filtered (stream
, "(null)");
552 retn
= ada_val_print_1 (VALUE_TYPE (val
), VALUE_CONTENTS (val
), 0,
553 VALUE_ADDRESS (val
), stream
, format
,
554 deref_ref
, recurse
, pretty
);
555 value_free_to_mark (mark
);
559 valaddr
= ada_aligned_value_addr (type
, valaddr
);
560 embedded_offset
-= valaddr
- valaddr0
- embedded_offset
;
561 type
= printable_val_type (type
, valaddr
);
563 switch (TYPE_CODE (type
))
566 return c_val_print (type
, valaddr0
, embedded_offset
, address
, stream
,
567 format
, deref_ref
, recurse
, pretty
);
570 case TYPE_CODE_RANGE
:
571 if (ada_is_fixed_point_type (type
))
573 LONGEST v
= unpack_long (type
, valaddr
);
574 int len
= TYPE_LENGTH (type
);
576 fprintf_filtered (stream
, len
< 4 ? "%.11g" : "%.17g",
577 (double) ada_fixed_to_float (type
, v
));
580 else if (ada_is_vax_floating_type (type
))
583 value_from_contents_and_address (type
, valaddr
, address
);
584 struct value
* func
= ada_vax_float_print_function (type
);
587 static struct type
* parray_of_char
= NULL
;
588 struct value
* printable_val
;
590 if (parray_of_char
== NULL
)
594 (NULL
, builtin_type_char
,
595 create_range_type (NULL
, builtin_type_int
, 0, 32)),
599 value_ind (value_cast (parray_of_char
,
600 call_function_by_hand (func
, 1, &val
)));
602 fprintf_filtered (stream
, "%s", VALUE_CONTENTS (printable_val
));
605 /* No special printing function. Do as best we can. */
607 else if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
609 struct type
* target_type
= TYPE_TARGET_TYPE (type
);
610 if (TYPE_LENGTH (type
) != TYPE_LENGTH (target_type
))
612 /* Obscure case of range type that has different length from
613 its base type. Perform a conversion, or we will get a
614 nonsense value. Actually, we could use the same
615 code regardless of lengths; I'm just avoiding a cast. */
617 value_cast (target_type
,
618 value_from_contents_and_address (type
, valaddr
, 0));
619 return ada_val_print_1 (target_type
, VALUE_CONTENTS (v
), 0, 0,
620 stream
, format
, 0, recurse
+ 1, pretty
);
623 return ada_val_print_1 (TYPE_TARGET_TYPE (type
),
624 valaddr0
, embedded_offset
,
625 address
, stream
, format
, deref_ref
,
630 format
= format
? format
: output_format
;
633 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
637 val_print_type_code_int (type
, valaddr
, stream
);
638 if (ada_is_character_type (type
))
640 fputs_filtered (" ", stream
);
641 ada_printchar ((unsigned char) unpack_long (type
, valaddr
),
651 print_scalar_formatted (valaddr
, type
, format
, 0, stream
);
654 len
= TYPE_NFIELDS (type
);
655 val
= unpack_long (type
, valaddr
);
656 for (i
= 0; i
< len
; i
++)
659 if (val
== TYPE_FIELD_BITPOS (type
, i
))
666 const char* name
= ada_enum_name (TYPE_FIELD_NAME (type
, i
));
668 fprintf_filtered (stream
, "%ld %s", (long) val
, name
);
670 fputs_filtered (name
, stream
);
674 print_longest (stream
, 'd', 0, val
);
678 case TYPE_CODE_UNION
:
679 case TYPE_CODE_STRUCT
:
680 if (ada_is_bogus_array_descriptor (type
))
682 fprintf_filtered (stream
, "(...?)");
687 print_record (type
, valaddr
, stream
, format
,
692 case TYPE_CODE_ARRAY
:
693 if (TYPE_LENGTH (type
) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) > 0)
695 elttype
= TYPE_TARGET_TYPE (type
);
696 eltlen
= TYPE_LENGTH (elttype
);
697 len
= TYPE_LENGTH (type
) / eltlen
;
699 /* For an array of chars, print with string syntax. */
700 if (ada_is_string_type (type
)
701 && (format
== 0 || format
== 's'))
703 if (prettyprint_arrays
)
705 print_spaces_filtered (2 + 2 * recurse
, stream
);
707 /* If requested, look for the first null char and only print
708 elements up to it. */
709 if (stop_print_at_null
)
713 /* Look for a NULL char. */
715 temp_len
< len
&& temp_len
< print_max
716 && char_at (valaddr
, temp_len
, eltlen
) != 0;
721 printstr (stream
, valaddr
, len
, 0, eltlen
);
726 fprintf_filtered (stream
, "(");
727 print_optional_low_bound (stream
, type
);
728 if (TYPE_FIELD_BITSIZE (type
, 0) > 0)
729 val_print_packed_array_elements (type
, valaddr
, 0, stream
,
733 val_print_array_elements (type
, valaddr
, address
, stream
,
734 format
, deref_ref
, recurse
,
736 fprintf_filtered (stream
, ")");
743 elttype
= check_typedef (TYPE_TARGET_TYPE (type
));
746 fprintf_filtered (stream
, "@");
747 print_address_numeric
748 (extract_address (valaddr
,
749 TARGET_PTR_BIT
/ HOST_CHAR_BIT
), 1, stream
);
751 fputs_filtered (": ", stream
);
753 /* De-reference the reference */
756 if (TYPE_CODE (elttype
) != TYPE_CODE_UNDEF
)
758 LONGEST deref_val_int
= (LONGEST
)
759 unpack_pointer (lookup_pointer_type (builtin_type_void
),
761 if (deref_val_int
!= 0)
763 struct value
* deref_val
=
764 ada_value_ind (value_from_longest
765 (lookup_pointer_type (elttype
),
767 val_print (VALUE_TYPE (deref_val
),
768 VALUE_CONTENTS (deref_val
), 0,
769 VALUE_ADDRESS (deref_val
), stream
, format
,
770 deref_ref
, recurse
+ 1, pretty
);
773 fputs_filtered ("(null)", stream
);
776 fputs_filtered ("???", stream
);
784 print_variant_part (struct type
*type
, int field_num
, char *valaddr
,
785 struct ui_file
*stream
, int format
, int recurse
,
786 enum val_prettyprint pretty
, int comma_needed
,
787 struct type
*outer_type
, char *outer_valaddr
)
789 struct type
*var_type
= TYPE_FIELD_TYPE (type
, field_num
);
791 ada_which_variant_applies (var_type
, outer_type
, outer_valaddr
);
796 return print_field_values
797 (TYPE_FIELD_TYPE (var_type
, which
),
798 valaddr
+ TYPE_FIELD_BITPOS (type
, field_num
) / HOST_CHAR_BIT
799 + TYPE_FIELD_BITPOS (var_type
, which
) / HOST_CHAR_BIT
,
800 stream
, format
, recurse
, pretty
,
801 comma_needed
, outer_type
, outer_valaddr
);
805 ada_value_print (struct value
* val0
, struct ui_file
*stream
, int format
,
806 enum val_prettyprint pretty
)
808 char* valaddr
= VALUE_CONTENTS (val0
);
809 CORE_ADDR address
= VALUE_ADDRESS (val0
) + VALUE_OFFSET (val0
);
811 ada_to_fixed_type (VALUE_TYPE (val0
), valaddr
, address
, NULL
);
812 struct value
* val
= value_from_contents_and_address (type
, valaddr
, address
);
814 /* If it is a pointer, indicate what it points to. */
815 if (TYPE_CODE (type
) == TYPE_CODE_PTR
||
816 TYPE_CODE (type
) == TYPE_CODE_REF
)
818 /* Hack: remove (char *) for char strings. Their
819 type is indicated by the quoted string anyway. */
820 if (TYPE_CODE (type
) == TYPE_CODE_PTR
&&
821 TYPE_LENGTH (TYPE_TARGET_TYPE (type
)) == sizeof(char) &&
822 TYPE_CODE (TYPE_TARGET_TYPE (type
)) == TYPE_CODE_INT
&&
823 !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type
)))
829 fprintf_filtered (stream
, "(");
830 type_print (type
, "", stream
, -1);
831 fprintf_filtered (stream
, ") ");
834 else if (ada_is_array_descriptor (type
))
836 fprintf_filtered (stream
, "(");
837 type_print (type
, "", stream
, -1);
838 fprintf_filtered (stream
, ") ");
840 else if (ada_is_bogus_array_descriptor (type
))
842 fprintf_filtered (stream
, "(");
843 type_print (type
, "", stream
, -1);
844 fprintf_filtered (stream
, ") (...?)");
847 return (val_print (type
, VALUE_CONTENTS (val
), 0, address
,
848 stream
, format
, 1, 0, pretty
));
852 print_record (struct type
*type
, char *valaddr
, struct ui_file
*stream
,
853 int format
, int recurse
, enum val_prettyprint pretty
)
855 CHECK_TYPEDEF (type
);
857 fprintf_filtered (stream
, "(");
859 if (print_field_values (type
, valaddr
, stream
, format
, recurse
, pretty
,
860 0, type
, valaddr
) != 0
863 fprintf_filtered (stream
, "\n");
864 print_spaces_filtered (2 * recurse
, stream
);
867 fprintf_filtered (stream
, ")");
870 /* Print out fields of value at VALADDR having structure type TYPE.
872 TYPE, VALADDR, STREAM, FORMAT, RECURSE, and PRETTY have the
873 same meanings as in ada_print_value and ada_val_print.
875 OUTER_TYPE and OUTER_VALADDR give type and address of enclosing record
876 (used to get discriminant values when printing variant parts).
878 COMMA_NEEDED is 1 if fields have been printed at the current recursion
879 level, so that a comma is needed before any field printed by this
882 Returns 1 if COMMA_NEEDED or any fields were printed. */
885 print_field_values (struct type
*type
, char *valaddr
, struct ui_file
*stream
,
886 int format
, int recurse
, enum val_prettyprint pretty
,
887 int comma_needed
, struct type
*outer_type
,
892 len
= TYPE_NFIELDS (type
);
894 for (i
= 0; i
< len
; i
+= 1)
896 if (ada_is_ignored_field (type
, i
))
899 if (ada_is_wrapper_field (type
, i
))
902 print_field_values (TYPE_FIELD_TYPE (type
, i
),
904 + TYPE_FIELD_BITPOS (type
, i
) / HOST_CHAR_BIT
,
905 stream
, format
, recurse
, pretty
,
906 comma_needed
, type
, valaddr
);
909 else if (ada_is_variant_part (type
, i
))
912 print_variant_part (type
, i
, valaddr
,
913 stream
, format
, recurse
, pretty
, comma_needed
,
914 outer_type
, outer_valaddr
);
919 fprintf_filtered (stream
, ", ");
924 fprintf_filtered (stream
, "\n");
925 print_spaces_filtered (2 + 2 * recurse
, stream
);
929 wrap_here (n_spaces (2 + 2 * recurse
));
933 if (TYPE_CODE (TYPE_FIELD_TYPE (type
, i
)) == TYPE_CODE_PTR
)
934 fputs_filtered ("\"( ptr \"", stream
);
936 fputs_filtered ("\"( nodef \"", stream
);
937 fprintf_symbol_filtered (stream
, TYPE_FIELD_NAME (type
, i
),
938 language_cplus
, DMGL_NO_OPTS
);
939 fputs_filtered ("\" \"", stream
);
940 fprintf_symbol_filtered (stream
, TYPE_FIELD_NAME (type
, i
),
941 language_cplus
, DMGL_NO_OPTS
);
942 fputs_filtered ("\") \"", stream
);
946 annotate_field_begin (TYPE_FIELD_TYPE (type
, i
));
947 fprintf_filtered (stream
, "%.*s",
948 ada_name_prefix_len (TYPE_FIELD_NAME (type
, i
)),
949 TYPE_FIELD_NAME (type
, i
));
950 annotate_field_name_end ();
951 fputs_filtered (" => ", stream
);
952 annotate_field_value ();
955 if (TYPE_FIELD_PACKED (type
, i
))
959 /* Bitfields require special handling, especially due to byte
961 if (TYPE_CPLUS_SPECIFIC (type
) != NULL
962 && TYPE_FIELD_IGNORE (type
, i
))
964 fputs_filtered ("<optimized out or zero length>", stream
);
968 int bit_pos
= TYPE_FIELD_BITPOS (type
, i
);
969 int bit_size
= TYPE_FIELD_BITSIZE (type
, i
);
971 adjust_type_signedness (TYPE_FIELD_TYPE (type
, i
));
972 v
= ada_value_primitive_packed_val (NULL
, valaddr
,
973 bit_pos
/ HOST_CHAR_BIT
,
974 bit_pos
% HOST_CHAR_BIT
,
976 TYPE_FIELD_TYPE (type
, i
));
977 val_print (TYPE_FIELD_TYPE(type
, i
), VALUE_CONTENTS (v
), 0, 0,
978 stream
, format
, 0, recurse
+ 1, pretty
);
982 ada_val_print (TYPE_FIELD_TYPE (type
, i
),
983 valaddr
+ TYPE_FIELD_BITPOS (type
, i
) / HOST_CHAR_BIT
,
984 0, 0, stream
, format
, 0, recurse
+ 1, pretty
);
985 annotate_field_end ();
This page took 0.049352 seconds and 4 git commands to generate.