of array constants using the obvious syntax.
* c-valprint.c (c_val_print): Set printed string length.
* dwarfread.c (read_tag_string_type): New prototype and
function that handles TAG_string_type DIEs.
* dwarfread.c (process_dies): Add case for TAG_string_type
that calls new read_tag_string_type function.
* expprint.c (print_subexp): Add support for OP_ARRAY.
* gdbtypes.c (create_range_type, create_array_type): Inherit
objfile from the index type.
**** start-sanitize-chill ****
* ch-typeprint.c (chill_print_type): Add case for
TYPE_CODE_STRING.
* ch-valprint.c (chill_val_print): Fix case for
TYPE_CODE_STRING.
**** end-sanitize-chill ****
{ arglist_len++; }
;
+exp : '{'
+ /* This is to save the value of arglist_len
+ being accumulated by an outer function call. */
+ { start_arglist (); }
+ arglist '}' %prec ARROW
+ { write_exp_elt_opcode (OP_ARRAY);
+ write_exp_elt_longcst ((LONGEST) 0);
+ write_exp_elt_longcst ((LONGEST) end_arglist () - 1);
+ write_exp_elt_opcode (OP_ARRAY); }
+ ;
+
exp : '{' type '}' exp %prec UNARY
{ write_exp_elt_opcode (UNOP_MEMVAL);
write_exp_elt_type ($2);
fprintf_filtered (stream, "0x%x ", address);
}
LA_PRINT_STRING (stream, valaddr, len, 0);
+ i = len;
}
else
{
fputs_filtered (") ", stream);
chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, 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);
+ print_type_scalar (index_type, high_bound + 1, stream);
+ fputs_filtered (") ", stream);
+ break;
+
default:
chill_print_type_base (type, stream, show, level);
break;
enum val_prettyprint pretty;
{
LONGEST val;
- unsigned int i;
+ unsigned int i = 0; /* Number of characters printed. */
struct type *elttype;
unsigned eltlen;
CORE_ADDR addr;
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
- i = 0; /* Number of characters printed. */
if (TYPE_LENGTH (elttype) == 1
&& TYPE_CODE (elttype) == TYPE_CODE_CHAR
&& (format == 0 || format == 's')
print_scalar_formatted (valaddr, type, format, 0, stream);
break;
}
- addr = unpack_pointer (lookup_pointer_type (builtin_type_char), valaddr);
if (addressprint && format != 's')
{
- fprintf_filtered (stream, "0x%x", addr);
- }
- if (addr != 0)
- {
- i = val_print_string (addr, TYPE_LENGTH (type), stream);
+ fprintf_filtered (stream, "0x%x ", addr);
}
+ i = TYPE_LENGTH (type);
+ LA_PRINT_STRING (stream, valaddr, i, 0);
/* Return number of characters printed, plus one for the terminating
null if we have "reached the end". */
return (i + (print_max && i != print_max));
static void
read_tag_pointer_type PARAMS ((struct dieinfo *dip));
+static void
+read_tag_string_type PARAMS ((struct dieinfo *dip));
+
static void
read_subroutine_type PARAMS ((struct dieinfo *, char *, char *));
/*
+LOCAL FUNCTION
+
+ read_tag_string_type -- read TAG_string_type DIE
+
+SYNOPSIS
+
+ static void read_tag_string_type (struct dieinfo *dip)
+
+DESCRIPTION
+
+ Extract all information from a TAG_string_type DIE and add to
+ the user defined type vector. It isn't really a user defined
+ type, but it behaves like one, with other DIE's using an
+ AT_user_def_type attribute to reference it.
+ */
+
+static void
+read_tag_string_type (dip)
+ struct dieinfo *dip;
+{
+ struct type *utype;
+ struct type *indextype;
+ struct type *rangetype;
+ unsigned long lowbound = 0;
+ unsigned long highbound;
+
+ if ((utype = lookup_utype (dip -> die_ref)) != NULL)
+ {
+ /* Ack, someone has stuck a type in the slot we want. Complain
+ about it. */
+ complain (&dup_user_type_definition, DIE_ID, DIE_NAME);
+ }
+ else
+ {
+ if (dip -> has_at_byte_size)
+ {
+ /* A fixed bounds string */
+ highbound = dip -> at_byte_size - 1;
+ }
+ else
+ {
+ /* A varying length string. Stub for now. (FIXME) */
+ highbound = 1;
+ }
+ indextype = dwarf_fundamental_type (current_objfile, FT_INTEGER);
+ rangetype = create_range_type ((struct type *) NULL, indextype,
+ lowbound, highbound);
+ utype = create_string_type ((struct type *) NULL, rangetype);
+ alloc_utype (dip -> die_ref, utype);
+ }
+}
+
+/*
+
LOCAL FUNCTION
read_subroutine_type -- process TAG_subroutine_type dies
case TAG_pointer_type:
read_tag_pointer_type (&di);
break;
+ case TAG_string_type:
+ read_tag_string_type (&di);
+ break;
default:
new_symbol (&di, objfile);
break;
}
/* Create a range type using either a blank type supplied in RESULT_TYPE,
- or creating a new type. Indices will be of type INDEX_TYPE, and will
- range from LOW_BOUND to HIGH_BOUND, inclusive.
+ or creating a new type, inheriting the objfile from INDEX_TYPE.
+
+ Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
+ HIGH_BOUND, inclusive.
FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
/* 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 RANGE_TYPE.
+ or creating a new type, inheriting the objfile from RANGE_TYPE.
+
+ Elements will be of type ELEMENT_TYPE, the indices will be of type
+ RANGE_TYPE.
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? */
}
if (result_type == NULL)
{
- result_type = alloc_type (TYPE_OBJFILE (element_type));
+ result_type = alloc_type (TYPE_OBJFILE (range_type));
}
TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
TYPE_TARGET_TYPE (result_type) = element_type;