diff options
author | Fred Fish <fnf@specifix.com> | 1993-02-24 15:49:47 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1993-02-24 15:49:47 +0000 |
commit | 8fbdca53aaf4d6d794f66496171d4b9aea8272d4 (patch) | |
tree | 761ccb19c3760899409912a82332e028fd6abd60 /gdb/ch-valprint.c | |
parent | 0cca30f32ad8731612637e7885650726382f4561 (diff) | |
download | gdb-8fbdca53aaf4d6d794f66496171d4b9aea8272d4.zip gdb-8fbdca53aaf4d6d794f66496171d4b9aea8272d4.tar.gz gdb-8fbdca53aaf4d6d794f66496171d4b9aea8272d4.tar.bz2 |
**** start-sanitize-chill ****
* ch-typeprint.c (chill_print_type_base): Name changed to
chill_type_print_base to match pattern for C and C++ names.
* ch-typeprint.c (chill_print_type): Change "char" to "CHAR"
to be consistent with other usages.
* ch-typeprint.c (chill_type_print_base): Add support for
printing Chill STRUCT types.
* ch-valprint.c: Include values.h.
* ch-valprint.c (chill_print_value_fields): New function and
prototype for printing Chill STRUCT values.
* ch-valprint.c (chill_val_print): Fix call to val_print_string
that was being called with two args instead of three.
* ch-valprint.c (chill_val_print): Call chill_print_value_fields
to print Chill STRUCT values.
**** end-sanitize-chill ****
Diffstat (limited to 'gdb/ch-valprint.c')
-rw-r--r-- | gdb/ch-valprint.c | 93 |
1 files changed, 91 insertions, 2 deletions
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c index 37730b4..40d1553 100644 --- a/gdb/ch-valprint.c +++ b/gdb/ch-valprint.c @@ -23,8 +23,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gdbtypes.h" #include "valprint.h" #include "expression.h" +#include "value.h" #include "language.h" +static void +chill_print_value_fields PARAMS ((struct type *, char *, FILE *, int, int, + enum val_prettyprint, struct type **)); + /* Print data of type TYPE located at VALADDR (within GDB), which came from the inferior at address ADDRESS, onto stdio stream STREAM according to @@ -164,7 +169,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, In that case don't try to print the string. */ print_max < UINT_MAX) { - i = val_print_string (addr, stream); + i = val_print_string (addr, 0, stream); } /* Return number of characters printed, plus one for the terminating null if we have "reached the end". */ @@ -188,10 +193,14 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, return (i + (print_max && i != print_max)); break; + case TYPE_CODE_STRUCT: + chill_print_value_fields (type, valaddr, stream, format, recurse, pretty, + 0); + break; + case TYPE_CODE_MEMBER: case TYPE_CODE_REF: case TYPE_CODE_UNION: - case TYPE_CODE_STRUCT: case TYPE_CODE_ENUM: case TYPE_CODE_FUNC: case TYPE_CODE_VOID: @@ -207,3 +216,83 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, fflush (stream); return (0); } + +/* Mutually recursive subroutines of cplus_print_value and c_val_print to + print out a structure's fields: cp_print_value_fields and cplus_print_value. + + TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the + same meanings as in cplus_print_value and c_val_print. + + DONT_PRINT is an array of baseclass types that we + should not print, or zero if called from top level. */ + +static void +chill_print_value_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; + int fields_seen = 0; + + check_stub_type (type); + + fprintf_filtered (stream, "("); + len = TYPE_NFIELDS (type); + if (len == 0) + { + fprintf_filtered (stream, "<No data fields>"); + } + else + { + for (i = 0; i < len; i++) + { + if (fields_seen) + { + fprintf_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)); + } + fprint_symbol (stream, TYPE_FIELD_NAME (type, i)); + 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)); + + chill_val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0, + stream, format, 0, recurse + 1, pretty); + } + else + { + chill_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, ")"); +} + |