-
- /* A "repeated" value really contains several values in a row.
- They are made by the @ operator.
- Print such values as if they were arrays. */
-
- else if (VALUE_REPEATED (val))
- {
- n = VALUE_REPETITIONS (val);
- typelen = TYPE_LENGTH (VALUE_TYPE (val));
- fprintf_filtered (stream, "{");
- /* Print arrays of characters using string syntax. */
- if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT
- && format == 0)
- print_string (stream, VALUE_CONTENTS (val), n, 0);
- else
- {
- unsigned int things_printed = 0;
-
- for (i = 0; i < n && things_printed < print_max; i++)
- {
- /* Position of the array element we are examining to see
- whether it is repeated. */
- unsigned int rep1;
- /* Number of repetitions we have detected so far. */
- unsigned int reps;
-
- if (i != 0)
- fprintf_filtered (stream, ", ");
- wrap_here ("");
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < n
- && !bcmp (VALUE_CONTENTS (val) + typelen * i,
- VALUE_CONTENTS (val) + typelen * rep1, typelen))
- {
- ++reps;
- ++rep1;
- }
-
- if (reps > REPEAT_COUNT_THRESHOLD)
- {
- val_print (VALUE_TYPE (val),
- VALUE_CONTENTS (val) + typelen * i,
- VALUE_ADDRESS (val) + typelen * i,
- stream, format, 1, 0, pretty);
- fprintf (stream, " <repeats %u times>", reps);
- i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
- }
- else
- {
- val_print (VALUE_TYPE (val),
- VALUE_CONTENTS (val) + typelen * i,
- VALUE_ADDRESS (val) + typelen * i,
- stream, format, 1, 0, pretty);
- things_printed++;
- }
- }
- if (i < n)
- fprintf_filtered (stream, "...");
- }
- fprintf_filtered (stream, "}");
- return n * typelen;
- }
- else
- {
- struct type *type = VALUE_TYPE (val);
-
- /* If it is a pointer, indicate what it points to.
-
- Print type also if it is a reference.
-
- C++: if it is a member pointer, we will take care
- of that when we print it. */
- if (TYPE_CODE (type) == TYPE_CODE_PTR
- || TYPE_CODE (type) == TYPE_CODE_REF)
- {
- /* Hack: remove (char *) for char strings. Their
- type is indicated by the quoted string anyway. */
- if (TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof(char)
- && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT
- && !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type)))
- {
- /* Print nothing */
- }
- else
- {
- fprintf_filtered (stream, "(");
- type_print (type, "", stream, -1);
- fprintf_filtered (stream, ") ");
- }
- }
- return val_print (type, VALUE_CONTENTS (val),
- VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
- }
-}
-
-/* Return truth value for assertion that TYPE is of the type
- "pointer to virtual function". */
-static int
-is_vtbl_ptr_type(type)
- struct type *type;
-{
- char *typename = type_name_no_tag (type);
- static const char vtbl_ptr_name[] =
- { CPLUS_MARKER,'v','t','b','l','_','p','t','r','_','t','y','p','e', 0 };
-
- return (typename != NULL && !strcmp(typename, vtbl_ptr_name));
-}
-
-/* Return truth value for the assertion that TYPE is of the type
- "pointer to virtual function table". */
-static int
-is_vtbl_member(type)
- struct type *type;
-{
- if (TYPE_CODE (type) == TYPE_CODE_PTR)
- type = TYPE_TARGET_TYPE (type);
- else
- return 0;
-
- if (TYPE_CODE (type) == TYPE_CODE_ARRAY
- && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT)
- /* Virtual functions tables are full of pointers to virtual functions. */
- return is_vtbl_ptr_type (TYPE_TARGET_TYPE (type));
- return 0;
-}
-\f
-/* Mutually recursive subroutines of cplus_val_print and val_print to print out
- a structure's fields: val_print_fields and cplus_val_print.
-
- TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the
- same meanings as in cplus_val_print and val_print.
-
- DONT_PRINT is an array of baseclass types that we
- should not print, or zero if called from top level. */
-
-static void
-val_print_fields (type, valaddr, stream, format, recurse, pretty, dont_print)
- struct type *type;
- char *valaddr;
- FILE *stream;
- int format;
- int recurse;
- enum val_prettyprint pretty;
- struct type **dont_print;
-{
- int i, len, n_baseclasses;
-
- check_stub_type (type);
-
- fprintf_filtered (stream, "{");
- len = TYPE_NFIELDS (type);
- n_baseclasses = TYPE_N_BASECLASSES (type);
-
- /* Print out baseclasses such that we don't print
- duplicates of virtual baseclasses. */
- if (n_baseclasses > 0)
- cplus_val_print (type, valaddr, stream, format, recurse+1, pretty, dont_print);
-
- if (!len && n_baseclasses == 1)
- fprintf_filtered (stream, "<No data fields>");
- else
- {
- extern int inspect_it;
- int fields_seen = 0;
-
- for (i = n_baseclasses; i < len; i++)
- {
- /* Check if static field */
- if (TYPE_FIELD_STATIC (type, i))
- continue;
- if (fields_seen)
- fprintf_filtered (stream, ", ");
- else if (n_baseclasses > 0)
- {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 + 2 * recurse, stream);
- fputs_filtered ("members of ", stream);
- fputs_filtered (type_name_no_tag (type), stream);
- fputs_filtered (": ", stream);
- }
- fields_seen = 1;
-
- if (pretty)
- {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 + 2 * recurse, stream);
- }
- else
- {
- wrap_here (n_spaces (2 + 2 * recurse));
- }
- if (inspect_it)
- {
- if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
- fputs_filtered ("\"( ptr \"", stream);
- else
- fputs_filtered ("\"( nodef \"", stream);
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- fputs_filtered ("\" \"", stream);
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- fputs_filtered ("\") \"", stream);
- }
- else
- {
- fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
- fputs_filtered (" = ", stream);
- }
- if (TYPE_FIELD_PACKED (type, i))
- {
- value v;
-
- /* Bitfields require special handling, especially due to byte
- order problems. */
- v = value_from_longest (TYPE_FIELD_TYPE (type, i),
- unpack_field_as_long (type, valaddr, i));
-
- val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0,
- stream, format, 0, recurse + 1, pretty);
- }
- else
- {
- val_print (TYPE_FIELD_TYPE (type, i),
- valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
- 0, stream, format, 0, recurse + 1, pretty);
- }
- }
- if (pretty)
- {
- fprintf_filtered (stream, "\n");
- print_spaces_filtered (2 * recurse, stream);
- }
- }
- fprintf_filtered (stream, "}");