diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 29 | ||||
-rw-r--r-- | gdb/ch-exp.y | 2 | ||||
-rw-r--r-- | gdb/ch-lang.c | 27 | ||||
-rw-r--r-- | gdb/ch-lang.h | 5 | ||||
-rw-r--r-- | gdb/ch-typeprint.c | 53 | ||||
-rw-r--r-- | gdb/ch-valprint.c | 33 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 80 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 6 | ||||
-rw-r--r-- | gdb/stabsread.c | 9 |
9 files changed, 189 insertions, 55 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 35caa75..30a362b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,32 @@ +Tue Dec 21 13:32:02 1993 Per Bothner (bothner@kalessin.cygnus.com) + + * ch-exp.y (match_dollar_tokens): Fix off-by-one bug. + * ch-lang.c (chill_is_varying_struct), ch-lang.h: New function. + * ch-lang.c (chill_printstr): Use double quotes, not single quotes. + * ch-typeprint.c (chill_type_print_base): Handle TYPE_CODE_BITSTRING. + Improve printing of TYPE_CODE_STRING, TYPE_CODE_SET, and + TYPE_CODE_STRUCT (including checking chill_is_varying_struct). + Print TYPE_DUMMY_RANGE by printing its TYPE_TARGET_TYPE. + Handle TYPE_CODE_ENUM. + * ch-valprint.c (chill_val_print): Handle TYPE_CODE_BITSTRING. + For TYPE_CODE_STRING, never print address. Handle VARYING strings. + * gdbtypes.c (force_to_range_type): New. + * gdbtypes.c (create_set_type): Make work, following Chill layout. + * gdbtypes.h (TYPE_LOW_BOUND, TYPE_HIGH_BOUND, TYPE_DUMMY_RANGE): New. + * stabsread.c (read_type): Distinguish string and bitstring from + char-array and set. + * valarith.c (value_subscript), valops.c (value_coerce_array): + Handle STRINGs as well as ARRAYs. + * valarith.c (value_bit_index): Fix think. Use new macros. + + +Fri Dec 17 10:45:32 1993 Kung Hsu (kung@cirdan.cygnus.com) + + * symtab (decode_line_1): fix a bug when position char is not + set correctly. + * c-valprint (c_val_print): handle vtbl printing when vtbl is not + set up yet. + Thu Dec 16 16:46:01 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * mips-tdep.c (read_next_frame_reg): If SIGFRAME_REG_SIZE is not diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y index b6be4a2..59ffd3f 100644 --- a/gdb/ch-exp.y +++ b/gdb/ch-exp.y @@ -1657,7 +1657,7 @@ match_dollar_tokens () && !isalnum (tokptr[namelength])) { yylval.lval = regno; - lexptr += namelength + 1; + lexptr += namelength; return (GDB_REGNAME); } } diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c index 7fa063b..32ab878 100644 --- a/gdb/ch-lang.c +++ b/gdb/ch-lang.c @@ -128,7 +128,7 @@ chill_printstr (stream, string, length, force_ellipses) { if (in_control_form || in_literal_form) { - fputs_filtered ("'//", stream); + fputs_filtered ("\"//", stream); in_control_form = in_literal_form = 0; } chill_printchar (c, stream); @@ -145,10 +145,10 @@ chill_printstr (stream, string, length, force_ellipses) { if (in_control_form) { - fputs_filtered ("'//", stream); + fputs_filtered ("\"//", stream); in_control_form = 0; } - fputs_filtered ("'", stream); + fputs_filtered ("\"", stream); in_literal_form = 1; } fprintf_filtered (stream, "%c", c); @@ -159,10 +159,10 @@ chill_printstr (stream, string, length, force_ellipses) { if (in_literal_form) { - fputs_filtered ("'//", stream); + fputs_filtered ("\"//", stream); in_literal_form = 0; } - fputs_filtered ("c'", stream); + fputs_filtered ("c\"", stream); in_control_form = 1; } fprintf_filtered (stream, "%.2x", c); @@ -174,7 +174,7 @@ chill_printstr (stream, string, length, force_ellipses) /* Terminate the quotes if necessary. */ if (in_literal_form || in_control_form) { - fputs_filtered ("'", stream); + fputs_filtered ("\"", stream); } if (force_ellipses || (i < length)) { @@ -182,6 +182,21 @@ chill_printstr (stream, string, length, force_ellipses) } } +/* Return 1 if TYPE is a varying string or array. */ + +int +chill_is_varying_struct (type) + struct type *type; +{ + if (TYPE_CODE (type) != TYPE_CODE_STRUCT) + return 0; + if (TYPE_NFIELDS (type) != 2) + return 0; + if (strcmp (TYPE_FIELD_NAME (type, 0), "<var_length>") != 0) + return 0; + return 1; +} + static struct type * chill_create_fundamental_type (objfile, typeid) struct objfile *objfile; diff --git a/gdb/ch-lang.h b/gdb/ch-lang.h index 6646b05..80c753e 100644 --- a/gdb/ch-lang.h +++ b/gdb/ch-lang.h @@ -29,3 +29,8 @@ chill_print_type PARAMS ((struct type *, char *, GDB_FILE *, int, int)); extern int chill_val_print PARAMS ((struct type *, char *, CORE_ADDR, GDB_FILE *, int, int, int, enum val_prettyprint)); + +extern int +chill_is_varying_struct PARAMS ((struct type *type)); + + diff --git a/gdb/ch-typeprint.c b/gdb/ch-typeprint.c index 3073486..377fff9 100644 --- a/gdb/ch-typeprint.c +++ b/gdb/ch-typeprint.c @@ -131,16 +131,22 @@ chill_type_print_base (type, stream, show, level) chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level); break; + case TYPE_CODE_BITSTRING: + fprintf_filtered (stream, "BOOLS (%d)", + TYPE_FIELD_BITPOS (TYPE_FIELD_TYPE(type,0), 1) + 1); + break; + case TYPE_CODE_SET: fputs_filtered ("POWERSET ", stream); - chill_print_type (TYPE_FIELD_TYPE (type, 0), "", stream, show, level); + chill_print_type (TYPE_FIELD_TYPE (type, 0), "", stream, + show - 1, level); break; case TYPE_CODE_STRING: range_type = TYPE_FIELD_TYPE (type, 0); index_type = TYPE_TARGET_TYPE (range_type); high_bound = TYPE_FIELD_BITPOS (range_type, 1); - fputs_filtered ("CHAR (", stream); + fputs_filtered ("CHARS (", stream); print_type_scalar (index_type, high_bound + 1, stream); fputs_filtered (")", stream); break; @@ -159,19 +165,16 @@ chill_type_print_base (type, stream, show, level) break; case TYPE_CODE_STRUCT: - fprintf_filtered (stream, "STRUCT "); - if ((name = type_name_no_tag (type)) != NULL) + if (chill_is_varying_struct (type)) { - fputs_filtered (name, stream); - fputs_filtered (" ", stream); - wrap_here (" "); - } - if (show < 0) - { - fprintf_filtered (stream, "(...)"); + chill_type_print_base (TYPE_FIELD_TYPE (type, 1), + stream, show, level); + fputs_filtered (" VARYING", stream); } else { + fprintf_filtered (stream, "STRUCT "); + fprintf_filtered (stream, "(\n"); if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) { @@ -237,7 +240,10 @@ chill_type_print_base (type, stream, show, level) break; case TYPE_CODE_RANGE: - if (TYPE_TARGET_TYPE (type)) + if (TYPE_DUMMY_RANGE (type)) + chill_type_print_base (TYPE_TARGET_TYPE (type), + stream, show, level); + else if (TYPE_TARGET_TYPE (type)) { chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); @@ -255,10 +261,31 @@ chill_type_print_base (type, stream, show, level) TYPE_FIELD_BITPOS (type, 1)); break; + case TYPE_CODE_ENUM: + { + register int lastval = 0; + fprintf_filtered (stream, "SET ("); + len = TYPE_NFIELDS (type); + for (i = 0; i < len; i++) + { + QUIT; + if (i) fprintf_filtered (stream, ", "); + wrap_here (" "); + fputs_filtered (TYPE_FIELD_NAME (type, i), stream); + if (lastval != TYPE_FIELD_BITPOS (type, i)) + { + fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i)); + lastval = TYPE_FIELD_BITPOS (type, i); + } + lastval++; + } + fprintf_filtered (stream, ")"); + } + break; + case TYPE_CODE_VOID: case TYPE_CODE_UNDEF: case TYPE_CODE_ERROR: - case TYPE_CODE_ENUM: case TYPE_CODE_UNION: case TYPE_CODE_METHOD: error ("missing language support in chill_type_print_base"); diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c index 1f0987c..e1e5929 100644 --- a/gdb/ch-valprint.c +++ b/gdb/ch-valprint.c @@ -183,12 +183,6 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, print_scalar_formatted (valaddr, type, format, 0, stream); break; } - if (addressprint && format != 's') - { - /* This used to say `addr', which is unset at this point. - Is `address' what is meant? */ - fprintf_filtered (stream, "H'%lx ", (unsigned long) address); - } i = TYPE_LENGTH (type); LA_PRINT_STRING (stream, valaddr, i, 0); /* Return number of characters printed, plus one for the terminating @@ -196,13 +190,14 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, return (i + (print_max && i != print_max)); break; + case TYPE_CODE_BITSTRING: case TYPE_CODE_SET: { struct type *range = TYPE_FIELD_TYPE (type, 0); - int low_bound = TYPE_FIELD_BITPOS (range, 0); - int high_bound = TYPE_FIELD_BITPOS (range, 1); + int low_bound = TYPE_LOW_BOUND (range); + int high_bound = TYPE_HIGH_BOUND (range); int i; - int is_bitstring = 0; + int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING; int need_comma = 0; int in_range = 0; @@ -242,6 +237,26 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, break; case TYPE_CODE_STRUCT: + if (chill_is_varying_struct (type)) + { + struct type *inner = TYPE_FIELD_TYPE (type, 1); + long length = unpack_long (TYPE_FIELD_TYPE (type, 0), valaddr); + char *data_addr = valaddr + TYPE_FIELD_BITPOS (type, 1) / 8; + + switch (TYPE_CODE (inner)) + { + case TYPE_CODE_STRING: + if (length > TYPE_LENGTH (type)) + { + fprintf_filtered (stream, + "<dynamic length %d > static length %d>", + length, TYPE_LENGTH (type)); + length > TYPE_LENGTH (type); + } + LA_PRINT_STRING (stream, data_addr, length, 0); + return length; + } + } chill_print_value_fields (type, valaddr, stream, format, recurse, pretty, 0); break; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 528e907..b24d3e4 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -348,6 +348,45 @@ create_range_type (result_type, index_type, low_bound, high_bound) return (result_type); } +/* A lot of code assumes that the "index type" of an array/string/ + set/bitstring is specifically a range type, though in some languages + it can be any discrete type. */ + +struct type * +force_to_range_type (type) + struct type *type; +{ + if (TYPE_CODE (type) == TYPE_CODE_RANGE) + return type; + + if (TYPE_CODE (type) == TYPE_CODE_ENUM) + { + int low_bound = TYPE_FIELD_BITPOS (type, 0); + int high_bound = TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1); + struct type *range_type = create_range_type (NULL, type, low_bound, high_bound); + TYPE_NAME (range_type) = TYPE_NAME (range_type); + TYPE_DUMMY_RANGE (range_type) = 1; + return range_type; + } + if (TYPE_CODE (type) == TYPE_CODE_BOOL) + { + struct type *range_type = create_range_type (NULL, type, 0, 1); + TYPE_NAME (range_type) = TYPE_NAME (range_type); + TYPE_DUMMY_RANGE (range_type) = 1; + return range_type; + } + if (TYPE_CODE (type) == TYPE_CODE_CHAR) + { + struct type *range_type = create_range_type (NULL, type, 0, 255); + TYPE_NAME (range_type) = TYPE_NAME (range_type); + TYPE_DUMMY_RANGE (range_type) = 1; + return range_type; + } + + warning ("internal error: array index type must be a discrete type"); + type = lookup_fundamental_type (TYPE_OBJFILE (type), FT_INTEGER); + return create_range_type ((struct type *) NULL, type, 0, 0); +} /* Create an array type using either a blank type supplied in RESULT_TYPE, or creating a new type, inheriting the objfile from RANGE_TYPE. @@ -367,23 +406,15 @@ create_array_type (result_type, element_type, range_type) int low_bound; int high_bound; - if (TYPE_CODE (range_type) != TYPE_CODE_RANGE) - { - /* FIXME: We only handle range types at the moment. Complain and - create a dummy range type to use. */ - warning ("internal error: array index type must be a range type"); - range_type = lookup_fundamental_type (TYPE_OBJFILE (range_type), - FT_INTEGER); - range_type = create_range_type ((struct type *) NULL, range_type, 0, 0); - } + range_type = force_to_range_type (range_type); if (result_type == NULL) { result_type = alloc_type (TYPE_OBJFILE (range_type)); } TYPE_CODE (result_type) = TYPE_CODE_ARRAY; TYPE_TARGET_TYPE (result_type) = element_type; - low_bound = TYPE_FIELD_BITPOS (range_type, 0); - high_bound = TYPE_FIELD_BITPOS (range_type, 1); + low_bound = TYPE_LOW_BOUND (range_type); + high_bound = TYPE_HIGH_BOUND (range_type); TYPE_LENGTH (result_type) = TYPE_LENGTH (element_type) * (high_bound - low_bound + 1); TYPE_NFIELDS (result_type) = 1; @@ -422,32 +453,29 @@ create_set_type (result_type, domain_type) struct type *result_type; struct type *domain_type; { + int low_bound, high_bound, bit_length; if (result_type == NULL) { result_type = alloc_type (TYPE_OBJFILE (domain_type)); } + domain_type = force_to_range_type (domain_type); TYPE_CODE (result_type) = TYPE_CODE_SET; TYPE_NFIELDS (result_type) = 1; TYPE_FIELDS (result_type) = (struct field *) TYPE_ALLOC (result_type, 1 * sizeof (struct field)); memset (TYPE_FIELDS (result_type), 0, sizeof (struct field)); TYPE_FIELD_TYPE (result_type, 0) = domain_type; - if (TYPE_CODE (domain_type) != TYPE_CODE_RANGE) - TYPE_LENGTH (result_type) = 4; /* Error? */ + low_bound = TYPE_LOW_BOUND (domain_type); + high_bound = TYPE_HIGH_BOUND (domain_type); + bit_length = high_bound - low_bound + 1; + if (bit_length <= TARGET_CHAR_BIT) + TYPE_LENGTH (result_type) = 1; + else if (bit_length <= TARGET_SHORT_BIT) + TYPE_LENGTH (result_type) = TARGET_SHORT_BIT / TARGET_CHAR_BIT; else - { - int low_bound = TYPE_FIELD_BITPOS (domain_type, 0); - int high_bound = TYPE_FIELD_BITPOS (domain_type, 1); - int bit_length = high_bound - low_bound + 1; - if (bit_length <= TARGET_CHAR_BIT) - TYPE_LENGTH (result_type) = 1; - else if (bit_length <= TARGET_SHORT_BIT) - TYPE_LENGTH (result_type) = TARGET_SHORT_BIT / TARGET_CHAR_BIT; - else - TYPE_LENGTH (result_type) - = ((bit_length + TARGET_INT_BIT - 1) / TARGET_INT_BIT) - * TARGET_CHAR_BIT; - } + TYPE_LENGTH (result_type) + = ((bit_length + TARGET_INT_BIT - 1) / TARGET_INT_BIT) + * TARGET_CHAR_BIT; return (result_type); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2c5685f..1a37b8e 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -463,6 +463,12 @@ allocate_cplus_struct_type PARAMS ((struct type *)); #define TYPE_NFIELDS(thistype) (thistype)->nfields #define TYPE_FIELDS(thistype) (thistype)->fields +#define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0) +#define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1) +/* If TYPE_DUMMY_RANGE is true for a range type, it was allocated + by force_to_range_type. */ +#define TYPE_DUMMY_RANGE(type) ((type)->vptr_fieldno) + /* C++ */ #define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype diff --git a/gdb/stabsread.c b/gdb/stabsread.c index a0c9672..66cc052 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1214,6 +1214,9 @@ read_type (pp, objfile) there is no size attribute. */ int type_size = -1; + /* Used to distinguish string and bitstring from char-array and set. */ + int is_string = 0; + /* Read type number if present. The type number may be omitted. for instance in a two-dimensional array declared with type "ar1;1;10;ar1;1;10;4". */ @@ -1263,6 +1266,8 @@ read_type (pp, objfile) if (type_size <= 0) type_size = -1; break; + case 'S': + is_string = 1; default: /* Ignore unrecognized type attributes, so future compilers can invent new ones. */ @@ -1566,11 +1571,15 @@ read_type (pp, objfile) type = dbx_alloc_type (typenums, objfile); type = read_array_type (pp, type, objfile); + if (is_string) + TYPE_CODE (type) = TYPE_CODE_STRING; break; case 'S': type1 = read_type (pp, objfile); type = create_set_type ((struct type*) NULL, type1); + if (is_string) + TYPE_CODE (type) = TYPE_CODE_BITSTRING; if (typenums[0] != -1) *dbx_lookup_type (typenums) = type; break; |