+Mon Dec 14 18:48:52 1992 Fred Fish (fnf@cygnus.com)
+
+ * gdbtypes.c (create_array_type): Complete rewrite. Now requires
+ a optional type to decorate as an array type, the type of the
+ index, and the bounds of the array. Records this additional info
+ in the array type for use with languages with nonzero array
+ bounds.
+ * gdbtypes.h (enum type_code): Update comment for TYPE_CODE_ARRAY
+ to note that arrays may have bounds.
+ * gdbtypes.h (create_array_type): Update prototype.
+ * c-exp.y (ptype production): Adjust for new create_array_type
+ calling conventions.
+ * coffread.c (decode_type): Call create_array_type rather than
+ handcrafting array types.
+ * convex-tdep.c (value_type): Remove, now use create_array_type.
+ * convex-tdep.c (value_of_trapped_internalvar): Convert calls to
+ vector_type into calls to create_array_type.
+ * dwarfread.c (decode_subscr_data): Name changed to
+ decode_subscript_data_item throughout.
+ * dwarfread.c (decode_subscript_data_item): Rewrite to use
+ create_array_type. Now records index type and range as well.
+ * dwarfread.c (dwarf_read_array_type): Rewrite as part of
+ change to use create_array_type.
+ * dwarfread.c (read_subroutine_type): Test existing user defined
+ types before decorating them, to ensure they are blank, and
+ complain about it if they are not.
+ * dwarfread.c (decode_fund_type): For unrecognized types, always
+ return some valid type (type integer). If the unrecognized type
+ cannot be an implementation defined type, complain as well.
+ * m88k-tdep.c (pushed_size): Update comment for TYPE_CODE_ARRAY.
+ * m88k-tdep.c (store_param): Update comment for TYPE_CODE_ARRAY.
+ * mipsread.c (upgrade_type): Add FIXME comment that code to
+ handcraft arrays should be replaced with call to create_array_type.
+ * stabsread.c (read_array_type): Replace code to handcraft
+ array types with call to create_array_type.
+ * valprint.c (type_print_varspec_prefix): Minor formatting
+ change, join lines that don't need to be split.
+
Mon Dec 14 17:18:42 1992 Stu Grossman (grossman at cygnus.com)
* convex-xdep.c, hppab-nat.c, i860-tdep.c, infptrace.c: Remove
case tp_array:
array_size = pop_type_int ();
if (array_size != -1)
- follow_type = create_array_type (follow_type,
- array_size);
+ follow_type =
+ create_array_type ((struct type *) NULL,
+ follow_type, builtin_type_int,
+ 0, array_size - 1);
else
follow_type = lookup_pointer_type (follow_type);
break;
struct coff_pending *coff_file_symbols; /* static at top level, and types */
-struct coff_pending *coff_global_symbols; /* global functions and variables */
+struct coff_pending *coff_global_symbols; /* global functions and variables */
-struct coff_pending *coff_local_symbols; /* everything local to lexical context */
+struct coff_pending *coff_local_symbols; /* everything local to lexical context */
/* List of unclosed lexical contexts
(that will become blocks, eventually). */
coff_new_init PARAMS ((struct objfile *));
static void
-coff_symfile_read PARAMS ((struct objfile *, CORE_ADDR, int));
+coff_symfile_read PARAMS ((struct objfile *, struct section_offsets *, int));
static void
coff_symfile_finish PARAMS ((struct objfile *));
coff_global_symbols = 0;
coff_context_stack = 0;
within_function = 0;
- last_source_file = 0;
+ last_source_file = NULL;
/* Initialize the source file line number information for this file. */
free ((PTR)line_vector);
line_vector = 0;
line_vector_length = -1;
- last_source_file = 0;
+ last_source_file = NULL;
return;
}
/* Reinitialize for beginning of new file. */
line_vector = 0;
line_vector_length = -1;
- last_source_file = 0;
+ last_source_file = NULL;
}
\f
static void
/* ARGSUSED */
static void
-coff_symfile_read (objfile, addr, mainline)
+coff_symfile_read (objfile, section_offsets, mainline)
struct objfile *objfile;
- CORE_ADDR addr;
+ struct section_offsets *section_offsets;
int mainline;
{
struct coff_symfile_info *info;
current_objfile = objfile;
nlist_stream_global = stream;
nlist_nsyms_global = nsyms;
- last_source_file = 0;
+ last_source_file = NULL;
memset (opaque_type_chain, 0, sizeof opaque_type_chain);
if (type_vector) /* Get rid of previous one */
TYPE_LENGTH (target) = TYPE_LENGTH (real_target);
TYPE_NFIELDS (target) = TYPE_NFIELDS (real_target);
- TYPE_FIELDS (target) = (struct field *)
- obstack_alloc (¤t_objfile -> type_obstack, field_size);
+ TYPE_FIELDS (target) = (struct field *) TYPE_ALLOC (target, field_size);
memcpy (TYPE_FIELDS (target), TYPE_FIELDS (real_target), field_size);
{
int i, n;
register unsigned short *dim;
- struct type *base_type;
+ struct type *base_type, *index_type;
/* Define an array type. */
/* auxent refers to array, not base type */
*dim = *(dim + 1);
*dim = 0;
- type = (struct type *)
- obstack_alloc (¤t_objfile -> type_obstack,
- sizeof (struct type));
- memset (type, 0, sizeof (struct type));
- TYPE_OBJFILE (type) = current_objfile;
-
base_type = decode_type (cs, new_c_type, aux);
-
- TYPE_CODE (type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (type) = base_type;
- TYPE_LENGTH (type) = n * TYPE_LENGTH (base_type);
+ index_type = lookup_fundamental_type (current_objfile, FT_INTEGER);
+ type = create_array_type ((struct type *) NULL, base_type,
+ index_type, 0, n - 1);
}
return type;
}
TYPE_NFIELDS (type) = nfields;
TYPE_FIELDS (type) = (struct field *)
- obstack_alloc (¤t_objfile -> type_obstack,
- sizeof (struct field) * nfields);
+ TYPE_ALLOC (type, sizeof (struct field) * nfields);
/* Copy the saved-up fields into the field vector. */
TYPE_CODE (type) = TYPE_CODE_ENUM;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
- obstack_alloc (¤t_objfile -> type_obstack,
- sizeof (struct field) * nsyms);
+ TYPE_ALLOC (type, sizeof (struct field) * nsyms);
/* Find the symbols for the values and put them into the type.
The symbols can be found in the symlist that we put them on
return type;
}
+/* Fake up support for relocating symbol addresses. FIXME. */
+
+struct section_offsets coff_symfile_faker = {0};
+
+struct section_offsets *
+coff_symfile_offsets (objfile, addr)
+ struct objfile *objfile;
+ CORE_ADDR addr;
+{
+ return &coff_symfile_faker;
+}
+
/* Register our ability to parse symbols for coff BFD files */
static struct sym_fns coff_sym_fns =
coff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
coff_symfile_read, /* sym_read: read a symbol file into symtab */
coff_symfile_finish, /* sym_finish: finished with file, cleanup */
+ coff_symfile_offsets, /* sym_offsets: xlate external to internal form */
NULL /* next: pointer to next struct sym_fns */
};
long vm[4];
long i, *p;
bcopy (read_vector_register_1 (VM_REGNUM), vm, sizeof vm);
- type = vector_type (builtin_type_int, len);
+ type = create_array_type ((struct type *) NULL, builtin_type_int,
+ builtin_type_int, 0, len - 1);
val = allocate_value (type);
p = (long *) VALUE_CONTENTS (val);
for (i = 0; i < len; i++)
}
else if (name[0] == 'V')
{
- type = vector_type (builtin_type_long_long, len);
+ type = create_array_type ((struct type *) NULL, builtin_type_long_long,
+ builtin_type_int, 0, len - 1);
val = allocate_value (type);
bcopy (read_vector_register_1 (name[1] - '0'),
VALUE_CONTENTS (val), TYPE_LENGTH (type));
else if (name[0] == 'v')
{
long *p1, *p2;
- type = vector_type (builtin_type_long, len);
+ type = create_array_type ((struct type *) NULL, builtin_type_long,
+ builtin_type_int, 0, len - 1);
val = allocate_value (type);
p1 = read_vector_register_1 (name[1] - '0');
p2 = (long *) VALUE_CONTENTS (val);
return val;
}
-/* Construct the type for a vector register's value --
- array[LENGTH] of ELEMENT_TYPE. */
-
-static struct type *
-vector_type (element_type, length)
- struct type *element_type;
- long length;
-{
- struct type *type = (struct type *) xmalloc (sizeof (struct type));
- bzero (type, sizeof type);
- TYPE_CODE (type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (type) = element_type;
- TYPE_LENGTH (type) = length * TYPE_LENGTH (TYPE_TARGET_TYPE (type));
- return type;
-}
-
/* Handle a new value assigned to a trapped internal variable */
void
decode_array_element_type PARAMS ((char *));
static struct type *
-decode_subscr_data PARAMS ((char *, char *));
+decode_subscript_data_item PARAMS ((char *, char *));
static void
dwarf_read_array_type PARAMS ((struct dieinfo *));
LOCAL FUNCTION
- decode_subscr_data -- decode array subscript and element type data
+ decode_subscript_data_item -- decode array subscript item
SYNOPSIS
- static struct type *decode_subscr_data (char *scan, char *end)
+ static struct type *
+ decode_subscript_data_item (char *scan, char *end)
DESCRIPTION
source (I.E. leftmost dimension first, next to leftmost second,
etc).
+ The data items describing each array dimension consist of four
+ parts: (1) a format specifier, (2) type type of the subscript
+ index, (3) a description of the low bound of the array dimension,
+ and (4) a description of the high bound of the array dimension.
+
+ The last data item is the description of the type of each of
+ the array elements.
+
We are passed a pointer to the start of the block of bytes
- containing the data items, and a pointer to the first byte past
- the data. This function decodes the data and returns a type.
+ containing the remaining data items, and a pointer to the first
+ byte past the data. This function recursively decodes the
+ remaining data items and returns a type.
+
+ If we somehow fail to decode some data, we complain about it
+ and return a type "array of int".
BUGS
FIXME: This code only implements the forms currently used
*/
static struct type *
-decode_subscr_data (scan, end)
+decode_subscript_data_item (scan, end)
char *scan;
char *end;
{
- struct type *typep = NULL;
- struct type *nexttype;
+ struct type *typep = NULL; /* Array type we are building */
+ struct type *nexttype; /* Type of each element (may be array) */
+ struct type *indextype; /* Type of this index */
unsigned int format;
unsigned short fundtype;
unsigned long lowbound;
typep = decode_array_element_type (scan);
break;
case FMT_FT_C_C:
- /* Read the type of the index, but don't do anything with it.
- FIXME: This is OK for C since only int's are allowed.
- It might not be OK for other languages. */
fundtype = target_to_host (scan, SIZEOF_FMT_FT, GET_UNSIGNED,
current_objfile);
+ indextype = decode_fund_type (fundtype);
scan += SIZEOF_FMT_FT;
nbytes = TARGET_FT_LONG_SIZE (current_objfile);
lowbound = target_to_host (scan, nbytes, GET_UNSIGNED, current_objfile);
scan += nbytes;
highbound = target_to_host (scan, nbytes, GET_UNSIGNED, current_objfile);
scan += nbytes;
- nexttype = decode_subscr_data (scan, end);
- if (nexttype != NULL)
+ nexttype = decode_subscript_data_item (scan, end);
+ if (nexttype == NULL)
{
- typep = alloc_type (current_objfile);
- TYPE_CODE (typep) = TYPE_CODE_ARRAY;
- TYPE_LENGTH (typep) = TYPE_LENGTH (nexttype);
- TYPE_LENGTH (typep) *= (highbound - lowbound) + 1;
- TYPE_TARGET_TYPE (typep) = nexttype;
- }
+ /* Munged subscript data or other problem, fake it. */
+ SQUAWK (("can't decode subscript data items"));
+ nexttype = dwarf_fundamental_type (current_objfile, FT_INTEGER);
+ }
+ typep = create_array_type ((struct type *) NULL, nexttype, indextype,
+ lowbound, highbound);
break;
case FMT_FT_C_X:
case FMT_FT_X_C:
case FMT_UT_X_C:
case FMT_UT_X_X:
SQUAWK (("array subscript format 0x%x not handled yet", format));
+ typep = dwarf_fundamental_type (current_objfile, FT_INTEGER);
+ typep = create_array_type ((struct type *) NULL, typep, typep, 0, 1);
break;
default:
SQUAWK (("unknown array subscript format %x", format));
+ typep = dwarf_fundamental_type (current_objfile, FT_INTEGER);
+ typep = create_array_type ((struct type *) NULL, typep, typep, 0, 1);
break;
}
return (typep);
blocksz = target_to_host (sub, nbytes, GET_UNSIGNED, current_objfile);
subend = sub + nbytes + blocksz;
sub += nbytes;
- type = decode_subscr_data (sub, subend);
- if (type == NULL)
+ type = decode_subscript_data_item (sub, subend);
+ if ((utype = lookup_utype (dip -> die_ref)) == NULL)
{
- if ((utype = lookup_utype (dip -> die_ref)) == NULL)
- {
- utype = alloc_utype (dip -> die_ref, NULL);
- }
- TYPE_CODE (utype) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (utype) =
- dwarf_fundamental_type (current_objfile, FT_INTEGER);
- TYPE_LENGTH (utype) = 1 * TYPE_LENGTH (TYPE_TARGET_TYPE (utype));
+ /* Install user defined type that has not been referenced yet. */
+ alloc_utype (dip -> die_ref, type);
+ }
+ else if (TYPE_CODE (utype) == TYPE_CODE_UNDEF)
+ {
+ /* Ick! A forward ref has already generated a blank type in our
+ slot, and this type probably already has things pointing to it
+ (which is what caused it to be created in the first place).
+ If it's just a place holder we can plop our fully defined type
+ on top of it. We can't recover the space allocated for our
+ new type since it might be on an obstack, but we could reuse
+ it if we kept a list of them, but it might not be worth it
+ (FIXME). */
+ *utype = *type;
}
else
{
- if ((utype = lookup_utype (dip -> die_ref)) == NULL)
- {
- alloc_utype (dip -> die_ref, type);
- }
- else
- {
- TYPE_CODE (utype) = TYPE_CODE_ARRAY;
- TYPE_LENGTH (utype) = TYPE_LENGTH (type);
- TYPE_TARGET_TYPE (utype) = TYPE_TARGET_TYPE (type);
- }
+ /* Double ick! Not only is a type already in our slot, but
+ someone has decorated it. Complain and leave it alone. */
+ SQUAWK (("duplicate user defined array type definition"));
}
}
}
ftype = lookup_function_type (type);
alloc_utype (dip -> die_ref, ftype);
}
- else
+ else if (TYPE_CODE (ftype) == TYPE_CODE_UNDEF)
{
/* We have an existing partially constructed type, so bash it
into the correct type. */
TYPE_LENGTH (ftype) = 1;
TYPE_CODE (ftype) = TYPE_CODE_FUNC;
}
+ else
+ {
+ SQUAWK (("duplicate user defined function type definition"));
+ }
}
/*
NOTES
- If we encounter a fundamental type that we are unprepared to
- deal with, and it is not in the range of those types defined
- as application specific types, then we issue a warning and
- treat the type as an "int".
+ For robustness, if we are asked to translate a fundamental
+ type that we are unprepared to deal with, we return int so
+ callers can always depend upon a valid type being returned,
+ and so gdb may at least do something reasonable by default.
+ If the type is not in the range of those types defined as
+ application specific types, we also issue a warning.
*/
static struct type *
}
- if ((typep == NULL) && !(FT_lo_user <= fundtype && fundtype <= FT_hi_user))
+ if (typep == NULL)
{
- SQUAWK (("unexpected fundamental type 0x%x", fundtype));
- typep = dwarf_fundamental_type (current_objfile, FT_VOID);
+ typep = dwarf_fundamental_type (current_objfile, FT_INTEGER);
+ if (!(FT_lo_user <= fundtype && fundtype <= FT_hi_user))
+ {
+ SQUAWK (("unexpected fundamental type 0x%x", fundtype));
+ }
}
return (typep);
return (mtype);
}
-/* Create an array type. Elements will be of type TYPE, and there will
- be NUM of them.
+/* Create an array type using either a blank type supplied in RESULT_TYPE,
+ or creating a new type. Elements will be of type ELEMENT_TYPE, the
+ indices will be of type INDEX_TYPE, and will range from LOW_BOUND
+ to HIGH_BOUND, inclusive.
- Eventually this should be extended to take two more arguments which
- specify the bounds of the array and the type of the index.
- It should also be changed to be a "lookup" function, with the
- appropriate data structures added to the type field.
- Then read array type should call here. */
+ FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
+ sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
struct type *
-create_array_type (element_type, number)
+create_array_type (result_type, element_type, index_type, low_bound,
+ high_bound)
+ struct type *result_type;
struct type *element_type;
- int number;
+ struct type *index_type;
+ int low_bound;
+ int high_bound;
{
- struct type *result_type;
struct type *range_type;
- result_type = alloc_type (TYPE_OBJFILE (element_type));
+ /* Create a blank type if we are not given one to bash on. */
+ if (result_type == NULL)
+ {
+ result_type = alloc_type (TYPE_OBJFILE (element_type));
+ }
+ /* Create a range type. */
+ range_type = alloc_type (TYPE_OBJFILE (element_type));
+ TYPE_CODE (range_type) = TYPE_CODE_RANGE;
+ TYPE_TARGET_TYPE (range_type) = index_type;
+ TYPE_LENGTH (range_type) = sizeof (int); /* This should never be needed. */
+ TYPE_NFIELDS (range_type) = 2;
+ TYPE_FIELDS (range_type) = (struct field *)
+ TYPE_ALLOC (range_type, 2 * sizeof (struct field));
+ memset (TYPE_FIELDS (range_type), 0, 2 * sizeof (struct field));
+ TYPE_FIELD_BITPOS (range_type, 0) = low_bound;
+ TYPE_FIELD_BITPOS (range_type, 1) = high_bound;
+ TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */
+ TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */
+
+ /* Create the array type. */
TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
TYPE_TARGET_TYPE (result_type) = element_type;
- TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type);
+ TYPE_LENGTH (result_type) =
+ TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
TYPE_NFIELDS (result_type) = 1;
TYPE_FIELDS (result_type) = (struct field *)
TYPE_ALLOC (result_type, sizeof (struct field));
-
- {
- /* Create range type. */
- range_type = alloc_type (TYPE_OBJFILE (result_type));
- TYPE_CODE (range_type) = TYPE_CODE_RANGE;
- TYPE_TARGET_TYPE (range_type) = builtin_type_int; /* FIXME */
-
- /* This should never be needed. */
- TYPE_LENGTH (range_type) = sizeof (int);
-
- TYPE_NFIELDS (range_type) = 2;
- TYPE_FIELDS (range_type) = (struct field *)
- TYPE_ALLOC (range_type, 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (range_type, 0) = 0; /* FIXME */
- TYPE_FIELD_BITPOS (range_type, 1) = number-1; /* FIXME */
- TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */
- TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */
- }
+ memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
TYPE_FIELD_TYPE (result_type, 0) = range_type;
TYPE_VPTR_FIELDNO (result_type) = -1;
{
TYPE_CODE_UNDEF, /* Not used; catches errors */
TYPE_CODE_PTR, /* Pointer type */
- TYPE_CODE_ARRAY, /* Array type, lower bound zero */
+ TYPE_CODE_ARRAY, /* Array type with lower & upper bounds. */
TYPE_CODE_STRUCT, /* C struct or Pascal record */
TYPE_CODE_UNION, /* C union or Pascal variant part */
TYPE_CODE_ENUM, /* Enumeration type */
lookup_function_type PARAMS ((struct type *));
extern struct type *
-create_array_type PARAMS ((struct type *, int));
+create_array_type PARAMS ((struct type *, struct type *, struct type *, int,
+ int));
extern struct type *
lookup_unsigned_typename PARAMS ((char *));
case TYPE_CODE_ENUM: /* Enumeration type */
case TYPE_CODE_INT: /* Integer type */
case TYPE_CODE_REF: /* C++ Reference types */
- case TYPE_CODE_ARRAY: /* Array type, lower bound zero */
+ case TYPE_CODE_ARRAY: /* Array type, lower & upper bounds */
return 1;
case TYPE_CODE_PTR: /* Pointer type */
case TYPE_CODE_ENUM: /* Enumeration type */
case TYPE_CODE_INT: /* Integer type */
- case TYPE_CODE_ARRAY: /* Array type, lower bound zero */
+ case TYPE_CODE_ARRAY: /* Array type, lower & upper bounds */
case TYPE_CODE_REF: /* C++ Reference types */
store_parm_word (start, *val_addr);
#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
+#include <string.h>
#include "gdb-stabs.h"
#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
#include "aout/aout64.h"
#include "aout/stab_gnu.h" /* STABS information */
+#include "expression.h"
+#include "language.h" /* Needed inside partial-stab.h */
struct coff_exec {
struct external_filehdr f;
if (tsym->st == stMember) {
if (nfields == 0 && type_code == TYPE_CODE_UNDEF)
/* If the type of the member is Nil (or Void),
- assume the tag is an enumeration. */
+ without qualifiers, assume the tag is an
+ enumeration. */
if (tsym->index == indexNil)
type_code = TYPE_CODE_ENUM;
else {
ecoff_swap_tir_in (bigend,
&ax[tsym->index].a_ti,
&tir);
- if (tir.bt == btNil || tir.bt == btVoid)
- type_code = TYPE_CODE_ENUM;
+ if ((tir.bt == btNil || tir.bt == btVoid)
+ && tir.tq0 == tqNil)
+ type_code = TYPE_CODE_ENUM;
}
nfields++;
if (tsym->value > max_value)
return 0;
case tqArray:
+ /* We should probably try to use create_array_type here. FIXME! */
off = 0;
t = init_type(TYPE_CODE_ARRAY, 0, 0, (char *) NULL,
(struct objfile *) NULL);
if (fh->csym >= 2
&& strcmp((char *)(((SYMR *)fh->isymBase)[1].iss),
stabs_symbol) == 0) {
+ processing_gcc_compilation = 2;
for (cur_sdx = 2; cur_sdx < fh->csym; cur_sdx++) {
int type_code;
char *namestring;
}
}
else {
+ processing_gcc_compilation = 0;
for (cur_sdx = 0; cur_sdx < fh->csym; ) {
char *name;
enum address_class class;
PDR *pr;
+ /* We indicate that this is a GCC compilation so that certain features
+ will be enabled in stabsread/dbxread. */
+ processing_gcc_compilation = 2;
/* Parse local symbols first */
if (fh->csym <= 2) /* FIXME, this blows psymtab->symtab ptr */
int maxlines;
EXTR **ext_ptr;
+ processing_gcc_compilation = 0;
+
/* How many symbols will we need */
/* FIXME, this does not count enum values. */
f_max = pst->n_global_syms + pst->n_static_syms;
upper = -1;
}
- {
- /* Create range type. */
- range_type = alloc_type (objfile);
- TYPE_CODE (range_type) = TYPE_CODE_RANGE;
- TYPE_TARGET_TYPE (range_type) = index_type;
-
- /* This should never be needed. */
- TYPE_LENGTH (range_type) = sizeof (int);
-
- TYPE_NFIELDS (range_type) = 2;
- TYPE_FIELDS (range_type) = (struct field *)
- TYPE_ALLOC (range_type, 2 * sizeof (struct field));
- memset (TYPE_FIELDS (range_type), 0, 2 * sizeof (struct field));
- TYPE_FIELD_BITPOS (range_type, 0) = lower;
- TYPE_FIELD_BITPOS (range_type, 1) = upper;
- }
-
- TYPE_CODE (type) = TYPE_CODE_ARRAY;
- TYPE_TARGET_TYPE (type) = element_type;
- TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type);
- TYPE_NFIELDS (type) = 1;
- TYPE_FIELDS (type) = (struct field *)
- TYPE_ALLOC (type, sizeof (struct field));
- memset (TYPE_FIELDS (type), 0, sizeof (struct field));
- TYPE_FIELD_TYPE (type, 0) = range_type;
+ type = create_array_type (type, element_type, index_type, lower, upper);
/* If we have an array whose element type is not yet known, but whose
bounds *are* known, record it to be adjusted at the end of the file. */
+
if (TYPE_LENGTH (element_type) == 0 && !adjustable)
- add_undefined_type (type);
+ {
+ add_undefined_type (type);
+ }
return type;
}
/* Prototypes for local functions */
-static void
-print_string PARAMS ((FILE *, char *, unsigned int, int));
-
static void
show_print PARAMS ((char *, int));
/* Maximum number of chars to print for a string pointer value
or vector contents, or UINT_MAX for no limit. */
-static unsigned int print_max;
+unsigned int print_max;
/* Default input and output radixes, and output format letter. */
unsigned output_radix = 10;
int output_format = 0;
-/* Print repeat counts if there are more than this
- many repetitions of an element in an array. */
-#define REPEAT_COUNT_THRESHOLD 10
+/* Print repeat counts if there are more than this many repetitions of an
+ element in an array. Referenced by the low level language dependent
+ print routines. */
+
+unsigned int repeat_count_threshold = 10;
/* Define a mess of print controls. */
struct obstack dont_print_obstack;
\f
-/* Print the character string STRING, printing at most LENGTH characters.
- Printing stops early if the number hits print_max; repeat counts
- are printed as appropriate. Print ellipses at the end if we
- had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
-
-static void
-print_string (stream, string, length, force_ellipses)
- FILE *stream;
- char *string;
- unsigned int length;
- int force_ellipses;
-{
- register unsigned int i;
- unsigned int things_printed = 0;
- int in_quotes = 0;
- int need_comma = 0;
- extern int inspect_it;
-
- if (length == 0)
- {
- fputs_filtered ("\"\"", stdout);
- return;
- }
-
- for (i = 0; i < length && things_printed < print_max; ++i)
- {
- /* Position of the character we are examining
- to see whether it is repeated. */
- unsigned int rep1;
- /* Number of repetitions we have detected so far. */
- unsigned int reps;
-
- QUIT;
-
- if (need_comma)
- {
- fputs_filtered (", ", stream);
- need_comma = 0;
- }
-
- rep1 = i + 1;
- reps = 1;
- while (rep1 < length && string[rep1] == string[i])
- {
- ++rep1;
- ++reps;
- }
-
- if (reps > REPEAT_COUNT_THRESHOLD)
- {
- if (in_quotes)
- {
- if (inspect_it)
- fputs_filtered ("\\\", ", stream);
- else
- fputs_filtered ("\", ", stream);
- in_quotes = 0;
- }
- fputs_filtered ("'", stream);
- printchar (string[i], stream, '\'');
- fprintf_filtered (stream, "' <repeats %u times>", reps);
- i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
- need_comma = 1;
- }
- else
- {
- if (!in_quotes)
- {
- if (inspect_it)
- fputs_filtered ("\\\"", stream);
- else
- fputs_filtered ("\"", stream);
- in_quotes = 1;
- }
- printchar (string[i], stream, '"');
- ++things_printed;
- }
- }
-
- /* Terminate the quotes if necessary. */
- if (in_quotes)
- {
- if (inspect_it)
- fputs_filtered ("\\\"", stream);
- else
- fputs_filtered ("\"", stream);
- }
-
- if (force_ellipses || i < length)
- fputs_filtered ("...", stream);
-}
-
/* Print a floating point value of type TYPE, pointed to in GDB by VALADDR,
on 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);
+ local_printstr (stream, VALUE_CONTENTS (val), n, 0);
else
{
unsigned int things_printed = 0;
++rep1;
}
- if (reps > REPEAT_COUNT_THRESHOLD)
+ if (reps > repeat_count_threshold)
{
val_print (VALUE_TYPE (val),
VALUE_CONTENTS (val) + typelen * i,
stream, format, 1, 0, pretty);
fprintf (stream, " <repeats %u times>", reps);
i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
+ things_printed += repeat_count_threshold;
}
else
{
/* For an array of chars, print with string syntax. */
if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT
&& (format == 0 || format == 's') )
- print_string (stream, valaddr, len, 0);
+ local_printstr (stream, valaddr, len, 0);
else
{
unsigned int things_printed = 0;
++rep1;
}
- if (reps > REPEAT_COUNT_THRESHOLD)
+ if (reps > repeat_count_threshold)
{
val_print (elttype, valaddr + i * eltlen,
0, stream, format, deref_ref,
recurse + 1, pretty);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
- things_printed += REPEAT_COUNT_THRESHOLD;
+ things_printed += repeat_count_threshold;
}
else
{
int force_ellipses = 1;
/* This loop always fetches print_max characters, even
- though print_string might want to print more or fewer
+ though local_printstr might want to print more or fewer
(with repeated characters). This is so that
we don't spend forever fetching if we print
a long string consisting of the same character
if (addressprint)
fputs_filtered (" ", stream);
- print_string (stream, string, i, force_ellipses);
+ local_printstr (stream, string, i, force_ellipses);
}
if (errcode != 0)
if (TYPE_LENGTH (type) == 1)
{
- fprintf_filtered (stream, " '");
- printchar ((unsigned char) unpack_long (type, valaddr),
- stream, '\'');
- fprintf_filtered (stream, "'");
+ fputs_filtered (" ", stream);
+ local_printchar ((unsigned char) unpack_long (type, valaddr),
+ stream);
}
break;
+ case TYPE_CODE_CHAR:
+ if (format || output_format)
+ {
+ print_scalar_formatted (valaddr, type,
+ format? format: output_format,
+ 0, stream);
+ break;
+ }
+ fprintf_filtered (stream, TYPE_UNSIGNED (type) ? "%u" : "%d",
+ unpack_long (type, valaddr));
+ fputs_filtered (" ", stream);
+ local_printchar ((unsigned char) unpack_long (type, valaddr), stream);
+ break;
+
case TYPE_CODE_FLT:
if (format)
print_scalar_formatted (valaddr, type, format, 0, stream);
fprintf_filtered (stream, "<range type>");
break;
+ /* start-sanitize-chill (FIXME!) */
case TYPE_CODE_BOOL:
val = unpack_long (builtin_type_chill_bool, valaddr);
fprintf_filtered (stream, val ? "TRUE" : "FALSE");
break;
+ /* end-sanitize-chill */
default:
error ("Invalid type code in symbol table.");
type_print(type,"",stream,0);
break;
#endif
+/* start-sanitize-chill */
#ifdef _LANG_chill
case language_chill:
error("Missing Chill support in function typedef_print."); /*FIXME*/
#endif
+/* end-sanitize-chill */
default:
error("Language not supported.");
}
case TYPE_CODE_MEMBER:
if (passed_a_ptr)
fprintf_filtered (stream, "(");
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
+ type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
fprintf_filtered (stream, " ");
name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
if (name)
case TYPE_CODE_METHOD:
if (passed_a_ptr)
fprintf (stream, "(");
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
+ type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
if (passed_a_ptr)
{
fprintf_filtered (stream, " ");
- type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0,
- passed_a_ptr);
+ type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
fprintf_filtered (stream, "::");
}
break;
break;
case TYPE_CODE_FUNC:
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
+ type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
case TYPE_CODE_ARRAY:
- type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
- 0);
+ type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
if (passed_a_ptr)
fprintf_filtered (stream, "(");
break;
&setprintlist),
&showprintlist);
+ add_show_from_set
+ (add_set_cmd ("repeats", no_class, var_uinteger,
+ (char *)&repeat_count_threshold,
+ "Set threshold for repeated print elements.\n\
+\"set print repeats 0\" causes all elements to be individually printed.",
+ &setprintlist),
+ &showprintlist);
+
add_show_from_set
(add_set_cmd ("pretty", class_support, var_boolean, (char *)&prettyprint,
"Set prettyprinting of structures.",