+Sat Jun 4 18:17:03 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ Fix value_print, which used to be ostensibly langauge-indepentdent,
+ but would print pointers and arrays in C syntax. Instead, call
+ a language-specific function.
+ * language.h (struct language_defn): New functional field
+ la_value_print. (LA_VALUE_PRINT): New macro.
+ * language.c (unk_lang_value_print ): New stub/dummy function.
+ (unknown_language_defn, auto_language_defn, local_language_defn):
+ Use it.
+ * c-valprint.c (c_value_print): New function, with code moved from:
+ * valprint.c (value_print): ... here. Now just invoke
+ LA_VALUE_PRINT to do language-specific stuff.
+ * valprint.c (value_print_array_elements): Make non-static.
+ * c-lang.c (c_language_defn, cplus_language_defn): Add
+ c_value_print in the la_value_print field,
+ * m2-lang.c (m2_language_defn): Likewise.
+ * ch-lang.c (chill_language_defn): But here use chill_value_print.
+ * ch-valprint.c (chill_val_print): Print null pointer as NULL.
+ * ch-valprint.c (chill_value_print): New function, based on
+ c_value_print, but use Chill "look and feel."
+ * c-lang.h (c_value_print): New prototype.
+ * ch-lang.h (chill_value_print): New prototype.
+ * value.h (value_print_array_elements): New prototype.
+
+ * ch-valprint.c (chill_val_print, case TYPE_CODE_BITSTRING
+ and case TYPE_CODE_SET): Check that the element type isn't a stub.
+
+
Fri Jun 3 09:15:00 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
* main.c: Move entire file except for #ifndef MAIN_OVERRIDE code
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
+ c_value_print, /* Print a top-level value */
&builtin_type_double, /* longest floating point type */ /*FIXME*/
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
c_create_fundamental_type, /* Create fundamental type in this language */
c_print_type, /* Print a type using appropriate syntax */
c_val_print, /* Print a value using appropriate syntax */
+ c_value_print, /* Print a top-level value */
&builtin_type_double, /* longest floating point type */ /*FIXME*/
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#ifdef __STDC__ /* Forward decls for prototypes */
+struct value;
+#endif
+
extern int
c_parse PARAMS ((void)); /* Defined in c-exp.y */
extern int
c_val_print PARAMS ((struct type *, char *, CORE_ADDR, GDB_FILE *, int, int,
int, enum val_prettyprint));
+
+extern int
+c_value_print PARAMS ((struct value *, GDB_FILE *, int, enum val_prettyprint));
gdb_flush (stream);
return (0);
}
+\f
+int
+c_value_print (val, stream, format, pretty)
+ value_ptr val;
+ GDB_FILE *stream;
+ int format;
+ enum val_prettyprint pretty;
+{
+ /* A "repeated" value really contains several values in a row.
+ They are made by the @ operator.
+ Print such values as if they were arrays. */
+
+ if (VALUE_REPEATED (val))
+ {
+ register unsigned int n = VALUE_REPETITIONS (val);
+ register unsigned int 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)
+ LA_PRINT_STRING (stream, VALUE_CONTENTS (val), n, 0);
+ else
+ {
+ value_print_array_elements (val, stream, format, pretty);
+ }
+ 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));
+ }
+}
chill_create_fundamental_type,/* Create fundamental type in this language */
chill_print_type, /* Print a type using appropriate syntax */
chill_val_print, /* Print a value using appropriate syntax */
+ chill_value_print, /* Print a top-levl value */
&builtin_type_chill_real, /* longest floating point type */
{"", "B'", "", ""}, /* Binary format info */
{"O'%lo", "O'", "o", ""}, /* Octal format info */
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#ifdef __STDC__ /* Forward decls for prototypes */
+struct value;
+#endif
+
extern int
chill_parse PARAMS ((void)); /* Defined in ch-exp.y */
chill_val_print PARAMS ((struct type *, char *, CORE_ADDR, GDB_FILE *, int, int,
int, enum val_prettyprint));
+extern int
+chill_value_print PARAMS ((struct value *, GDB_FILE *,
+ int, enum val_prettyprint));
+
extern int
chill_is_varying_struct PARAMS ((struct type *type));
}
addr = unpack_pointer (type, valaddr);
elttype = TYPE_TARGET_TYPE (type);
+
+ /* We assume a NULL pointer is all zeros ... */
+ if (addr == 0)
+ {
+ fputs_filtered ("NULL", stream);
+ return 0;
+ }
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
case TYPE_CODE_BITSTRING:
case TYPE_CODE_SET:
+ elttype = TYPE_FIELD_TYPE (type, 0);
+ check_stub_type (elttype);
+ if (TYPE_FLAGS (elttype) & TYPE_FLAG_STUB)
+ {
+ fprintf_filtered (stream, "<incomplete type>");
+ gdb_flush (stream);
+ break;
+ }
{
- struct type *range = TYPE_FIELD_TYPE (type, 0);
+ struct type *range = elttype;
int low_bound = TYPE_LOW_BOUND (range);
int high_bound = TYPE_HIGH_BOUND (range);
int i;
}
fprintf_filtered (stream, "]");
}
+\f
+int
+chill_value_print (val, stream, format, pretty)
+ value_ptr val;
+ GDB_FILE *stream;
+ int format;
+ enum val_prettyprint pretty;
+{
+ /* A "repeated" value really contains several values in a row.
+ They are made by the @ operator.
+ Print such values as if they were arrays. */
+
+ if (VALUE_REPEATED (val))
+ {
+ register unsigned int n = VALUE_REPETITIONS (val);
+ register unsigned int 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)
+ LA_PRINT_STRING (stream, VALUE_CONTENTS (val), n, 0);
+ else
+ {
+ value_print_array_elements (val, stream, format, pretty);
+ }
+ 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)
+ {
+ char *valaddr = VALUE_CONTENTS (val);
+ CORE_ADDR addr = unpack_pointer (type, valaddr);
+ if (TYPE_CODE (type) != TYPE_CODE_PTR || addr != 0)
+ {
+ int i;
+ char *name = TYPE_NAME (type);
+ if (name)
+ fputs_filtered (name, stream);
+ else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
+ fputs_filtered ("PTR", stream);
+ else
+ {
+ fprintf_filtered (stream, "(");
+ type_print (type, "", stream, -1);
+ fprintf_filtered (stream, ")");
+ }
+ fprintf_filtered (stream, "(");
+ i = val_print (type, valaddr, VALUE_ADDRESS (val),
+ stream, format, 1, 0, pretty);
+ fprintf_filtered (stream, ")");
+ return i;
+ }
+ }
+ return (val_print (type, VALUE_CONTENTS (val),
+ VALUE_ADDRESS (val), stream, format, 1, 0, pretty));
+ }
+}
+
+
error ("internal error - unimplemented function unk_lang_val_print called.");
}
+int
+unk_lang_value_print (val, stream, format, pretty)
+ value_ptr val;
+ GDB_FILE *stream;
+ int format;
+ enum val_prettyprint pretty;
+{
+ error ("internal error - unimplemented function unk_lang_value_print called.");
+}
+
static struct type ** const (unknown_builtin_types[]) = { 0 };
static const struct op_print unk_op_print_tab[] = {
{NULL, OP_NULL, PREC_NULL, 0}
unk_lang_create_fundamental_type,
unk_lang_print_type, /* Print a type using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
+ unk_lang_value_print, /* Print a top-level value */
&builtin_type_error, /* longest floating point type */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
unk_lang_create_fundamental_type,
unk_lang_print_type, /* Print a type using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
+ unk_lang_value_print, /* Print a top-level value */
&builtin_type_error, /* longest floating point type */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
unk_lang_create_fundamental_type,
unk_lang_print_type, /* Print a type using appropriate syntax */
unk_lang_val_print, /* Print a value using appropriate syntax */
+ unk_lang_value_print, /* Print a top-level value */
&builtin_type_error, /* longest floating point type */
{"", "", "", ""}, /* Binary format info */
{"0%lo", "0", "o", ""}, /* Octal format info */
int (*la_val_print) PARAMS ((struct type *, char *, CORE_ADDR, GDB_FILE *,
int, int, int, enum val_prettyprint));
+ /* Print a top-level value using syntax appropriate for this language. */
+
+ int (*la_value_print) PARAMS ((struct value *, GDB_FILE *,
+ int, enum val_prettyprint));
+
/* Longest floating point type */
struct type **la_longest_float;
#define LA_VAL_PRINT(type,valaddr,addr,stream,fmt,deref,recurse,pretty) \
(current_language->la_val_print(type,valaddr,addr,stream,fmt,deref, \
recurse,pretty))
+#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
+ (current_language->la_value_print(val,stream,fmt,pretty))
/* Return a format string for printf that will print a number in one of
the local (language-specific) formats. Result is static and is
#include "parser-defs.h"
#include "language.h"
#include "m2-lang.h"
+#include "c-lang.h"
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
m2_create_fundamental_type, /* Create fundamental type in this language */
m2_print_type, /* Print a type using appropriate syntax */
m2_val_print, /* Print a value using appropriate syntax */
+ c_value_print, /* Print a top-level value */
&builtin_type_m2_real, /* longest floating point type */
{"", "", "", ""}, /* Binary format info */
{"%loB", "", "o", "B"}, /* Octal format info */