diff options
author | Fred Fish <fnf@specifix.com> | 1992-12-15 02:52:11 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1992-12-15 02:52:11 +0000 |
commit | 85f0a8484fae7fc4f28b85298253e786645a5b6a (patch) | |
tree | 723472495b0c8155f5eb698d4bbb08cb935ebc69 | |
parent | 7f70a2756406d76578fc4a6af98c42fd85f28b12 (diff) | |
download | gdb-85f0a8484fae7fc4f28b85298253e786645a5b6a.zip gdb-85f0a8484fae7fc4f28b85298253e786645a5b6a.tar.gz gdb-85f0a8484fae7fc4f28b85298253e786645a5b6a.tar.bz2 |
* 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.
-rw-r--r-- | gdb/ChangeLog | 38 | ||||
-rw-r--r-- | gdb/c-exp.y | 6 | ||||
-rw-r--r-- | gdb/coffread.c | 55 | ||||
-rw-r--r-- | gdb/convex-tdep.c | 25 | ||||
-rw-r--r-- | gdb/dwarfread.c | 118 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 65 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 5 | ||||
-rw-r--r-- | gdb/m88k-tdep.c | 4 | ||||
-rw-r--r-- | gdb/mipsread.c | 19 | ||||
-rw-r--r-- | gdb/stabsread.c | 31 | ||||
-rw-r--r-- | gdb/valprint.c | 170 |
11 files changed, 257 insertions, 279 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81adf14..29698d1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,41 @@ +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 diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 5274118..8273f6a 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -721,8 +721,10 @@ ptype : typebase 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; diff --git a/gdb/coffread.c b/gdb/coffread.c index e82b6fc..1086d4c 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -130,9 +130,9 @@ struct coff_pending 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). */ @@ -267,7 +267,7 @@ static void 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 *)); @@ -522,7 +522,7 @@ coff_start_symtab () 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. */ @@ -591,7 +591,7 @@ coff_end_symtab (objfile) free ((PTR)line_vector); line_vector = 0; line_vector_length = -1; - last_source_file = 0; + last_source_file = NULL; return; } @@ -654,7 +654,7 @@ coff_end_symtab (objfile) /* Reinitialize for beginning of new file. */ line_vector = 0; line_vector_length = -1; - last_source_file = 0; + last_source_file = NULL; } static void @@ -762,9 +762,9 @@ static bfd *symfile_bfd; /* 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; @@ -917,7 +917,7 @@ read_coff_symtab (symtab_offset, nsyms, objfile) 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 */ @@ -1481,8 +1481,7 @@ patch_type (type, real_type) 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); @@ -1774,7 +1773,7 @@ decode_type (cs, c_type, aux) { 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 */ @@ -1789,17 +1788,10 @@ decode_type (cs, c_type, aux) *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; } @@ -2045,8 +2037,7 @@ coff_read_struct_type (index, length, lastsym) 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. */ @@ -2128,8 +2119,7 @@ coff_read_enum_type (index, length, lastsym) 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 @@ -2154,6 +2144,18 @@ coff_read_enum_type (index, length, lastsym) 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 = @@ -2164,6 +2166,7 @@ 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 */ }; diff --git a/gdb/convex-tdep.c b/gdb/convex-tdep.c index ac213ae..a374a80 100644 --- a/gdb/convex-tdep.c +++ b/gdb/convex-tdep.c @@ -350,7 +350,8 @@ value_of_trapped_internalvar (var) 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++) @@ -358,7 +359,8 @@ value_of_trapped_internalvar (var) } 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)); @@ -366,7 +368,8 @@ value_of_trapped_internalvar (var) 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); @@ -385,22 +388,6 @@ value_of_trapped_internalvar (var) 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 diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c index df9d72d..6d63543 100644 --- a/gdb/dwarfread.c +++ b/gdb/dwarfread.c @@ -413,7 +413,7 @@ static struct type * 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 *)); @@ -1249,11 +1249,12 @@ decode_array_element_type (scan) 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 @@ -1265,9 +1266,21 @@ 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 @@ -1278,12 +1291,13 @@ BUGS */ 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; @@ -1299,26 +1313,24 @@ decode_subscr_data (scan, end) 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: @@ -1328,9 +1340,13 @@ decode_subscr_data (scan, end) 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); @@ -1374,30 +1390,29 @@ dwarf_read_array_type (dip) 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")); } } } @@ -1495,7 +1510,7 @@ read_subroutine_type (dip, thisdie, enddie) 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. */ @@ -1504,6 +1519,10 @@ read_subroutine_type (dip, thisdie, enddie) TYPE_LENGTH (ftype) = 1; TYPE_CODE (ftype) = TYPE_CODE_FUNC; } + else + { + SQUAWK (("duplicate user defined function type definition")); + } } /* @@ -3197,10 +3216,12 @@ DESCRIPTION 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 * @@ -3311,10 +3332,13 @@ decode_fund_type (fundtype) } - 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); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index dfb98ac..e3ec14a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -290,49 +290,54 @@ allocate_stub_method (type) 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; diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index dfddc89..50ea2bd 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -62,7 +62,7 @@ enum type_code { 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 */ @@ -583,7 +583,8 @@ extern struct 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 *)); diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c index 1d71a51..43501d7 100644 --- a/gdb/m88k-tdep.c +++ b/gdb/m88k-tdep.c @@ -603,7 +603,7 @@ pushed_size (prev_words, v) 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; @@ -663,7 +663,7 @@ store_parm (prev_words, left_parm_addr, v) 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); diff --git a/gdb/mipsread.c b/gdb/mipsread.c index 5480c14..15e5d8b 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -68,6 +68,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <sys/param.h> #include <sys/file.h> #include <sys/stat.h> +#include <string.h> #include "gdb-stabs.h" @@ -78,6 +79,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #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; @@ -1106,15 +1109,17 @@ data: /* Common code for symbols describing data */ 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) @@ -1549,6 +1554,7 @@ upgrade_type(tpp, tq, ax, bigend) 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); @@ -1978,6 +1984,7 @@ parse_partial_symbols (end_of_text_seg, objfile, section_offsets) 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; @@ -2009,6 +2016,7 @@ parse_partial_symbols (end_of_text_seg, objfile, section_offsets) } } else { + processing_gcc_compilation = 0; for (cur_sdx = 0; cur_sdx < fh->csym; ) { char *name; enum address_class class; @@ -2356,6 +2364,9 @@ psymtab_to_symtab_1(pst, filename) 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 */ @@ -2421,6 +2432,8 @@ psymtab_to_symtab_1(pst, filename) 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; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 90f0300..dfbd3cb 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2371,36 +2371,15 @@ read_array_type (pp, type, objfile) 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; } diff --git a/gdb/valprint.c b/gdb/valprint.c index 8811cc5..80dc89b 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -34,9 +34,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Prototypes for local functions */ static void -print_string PARAMS ((FILE *, char *, unsigned int, int)); - -static void show_print PARAMS ((char *, int)); static void @@ -88,7 +85,7 @@ extern int demangle; /* whether to print C++ syms raw or source-form */ /* 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. */ @@ -96,9 +93,11 @@ unsigned input_radix = 10; 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. */ @@ -113,99 +112,6 @@ int objectprint; /* Controls looking up an object's derived type struct obstack dont_print_obstack; -/* 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. */ @@ -351,7 +257,7 @@ value_print (val, stream, format, pretty) /* 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; @@ -378,7 +284,7 @@ value_print (val, stream, format, pretty) ++rep1; } - if (reps > REPEAT_COUNT_THRESHOLD) + if (reps > repeat_count_threshold) { val_print (VALUE_TYPE (val), VALUE_CONTENTS (val) + typelen * i, @@ -386,7 +292,7 @@ value_print (val, stream, format, pretty) 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 { @@ -783,7 +689,7 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) /* 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; @@ -826,14 +732,14 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) ++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 { @@ -981,7 +887,7 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) 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 @@ -1014,7 +920,7 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) if (addressprint) fputs_filtered (" ", stream); - print_string (stream, string, i, force_ellipses); + local_printstr (stream, string, i, force_ellipses); } if (errcode != 0) @@ -1251,13 +1157,26 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) 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); @@ -1285,10 +1204,12 @@ val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) 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."); @@ -1331,10 +1252,12 @@ typedef_print (type, new, stream) 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."); } @@ -1526,8 +1449,7 @@ type_print_varspec_prefix (type, stream, show, passed_a_ptr) 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) @@ -1540,13 +1462,11 @@ type_print_varspec_prefix (type, stream, show, passed_a_ptr) 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; @@ -1557,15 +1477,13 @@ type_print_varspec_prefix (type, stream, show, passed_a_ptr) 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; @@ -2153,6 +2071,14 @@ _initialize_valprint () &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.", &setprintlist), |