* c-exp.y (exp): Add production to support direct creation
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 ****
This commit is contained in:
parent
fa2b89f103
commit
ec16f7015b
6 changed files with 95 additions and 13 deletions
11
gdb/c-exp.y
11
gdb/c-exp.y
|
@ -318,6 +318,17 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
|
||||||
{ arglist_len++; }
|
{ 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
|
exp : '{' type '}' exp %prec UNARY
|
||||||
{ write_exp_elt_opcode (UNOP_MEMVAL);
|
{ write_exp_elt_opcode (UNOP_MEMVAL);
|
||||||
write_exp_elt_type ($2);
|
write_exp_elt_type ($2);
|
||||||
|
|
|
@ -118,6 +118,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
|
||||||
fprintf_filtered (stream, "0x%x ", address);
|
fprintf_filtered (stream, "0x%x ", address);
|
||||||
}
|
}
|
||||||
LA_PRINT_STRING (stream, valaddr, len, 0);
|
LA_PRINT_STRING (stream, valaddr, len, 0);
|
||||||
|
i = len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,16 @@ chill_print_type (type, varstring, stream, show, level)
|
||||||
fputs_filtered (") ", stream);
|
fputs_filtered (") ", stream);
|
||||||
chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
|
chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
|
||||||
break;
|
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:
|
default:
|
||||||
chill_print_type_base (type, stream, show, level);
|
chill_print_type_base (type, stream, show, level);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -52,7 +52,7 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
|
||||||
enum val_prettyprint pretty;
|
enum val_prettyprint pretty;
|
||||||
{
|
{
|
||||||
LONGEST val;
|
LONGEST val;
|
||||||
unsigned int i;
|
unsigned int i = 0; /* Number of characters printed. */
|
||||||
struct type *elttype;
|
struct type *elttype;
|
||||||
unsigned eltlen;
|
unsigned eltlen;
|
||||||
CORE_ADDR addr;
|
CORE_ADDR addr;
|
||||||
|
@ -156,7 +156,6 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
|
||||||
|
|
||||||
/* For a pointer to char or unsigned char, also print the string
|
/* For a pointer to char or unsigned char, also print the string
|
||||||
pointed to, unless pointer is null. */
|
pointed to, unless pointer is null. */
|
||||||
i = 0; /* Number of characters printed. */
|
|
||||||
if (TYPE_LENGTH (elttype) == 1
|
if (TYPE_LENGTH (elttype) == 1
|
||||||
&& TYPE_CODE (elttype) == TYPE_CODE_CHAR
|
&& TYPE_CODE (elttype) == TYPE_CODE_CHAR
|
||||||
&& (format == 0 || format == 's')
|
&& (format == 0 || format == 's')
|
||||||
|
@ -178,15 +177,12 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
|
||||||
print_scalar_formatted (valaddr, type, format, 0, stream);
|
print_scalar_formatted (valaddr, type, format, 0, stream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
addr = unpack_pointer (lookup_pointer_type (builtin_type_char), valaddr);
|
|
||||||
if (addressprint && format != 's')
|
if (addressprint && format != 's')
|
||||||
{
|
{
|
||||||
fprintf_filtered (stream, "0x%x ", addr);
|
fprintf_filtered (stream, "0x%x ", addr);
|
||||||
}
|
}
|
||||||
if (addr != 0)
|
i = TYPE_LENGTH (type);
|
||||||
{
|
LA_PRINT_STRING (stream, valaddr, i, 0);
|
||||||
i = val_print_string (addr, TYPE_LENGTH (type), stream);
|
|
||||||
}
|
|
||||||
/* Return number of characters printed, plus one for the terminating
|
/* Return number of characters printed, plus one for the terminating
|
||||||
null if we have "reached the end". */
|
null if we have "reached the end". */
|
||||||
return (i + (print_max && i != print_max));
|
return (i + (print_max && i != print_max));
|
||||||
|
|
|
@ -522,6 +522,9 @@ dwarf_read_array_type PARAMS ((struct dieinfo *));
|
||||||
static void
|
static void
|
||||||
read_tag_pointer_type PARAMS ((struct dieinfo *dip));
|
read_tag_pointer_type PARAMS ((struct dieinfo *dip));
|
||||||
|
|
||||||
|
static void
|
||||||
|
read_tag_string_type PARAMS ((struct dieinfo *dip));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
read_subroutine_type PARAMS ((struct dieinfo *, char *, char *));
|
read_subroutine_type PARAMS ((struct dieinfo *, char *, char *));
|
||||||
|
|
||||||
|
@ -1524,6 +1527,60 @@ read_tag_pointer_type (dip)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
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
|
LOCAL FUNCTION
|
||||||
|
|
||||||
read_subroutine_type -- process TAG_subroutine_type dies
|
read_subroutine_type -- process TAG_subroutine_type dies
|
||||||
|
@ -2011,6 +2068,9 @@ process_dies (thisdie, enddie, objfile)
|
||||||
case TAG_pointer_type:
|
case TAG_pointer_type:
|
||||||
read_tag_pointer_type (&di);
|
read_tag_pointer_type (&di);
|
||||||
break;
|
break;
|
||||||
|
case TAG_string_type:
|
||||||
|
read_tag_string_type (&di);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
new_symbol (&di, objfile);
|
new_symbol (&di, objfile);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -314,8 +314,10 @@ allocate_stub_method (type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a range type using either a blank type supplied in RESULT_TYPE,
|
/* 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
|
or creating a new type, inheriting the objfile from INDEX_TYPE.
|
||||||
range from LOW_BOUND to HIGH_BOUND, inclusive.
|
|
||||||
|
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
|
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? */
|
sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
|
||||||
|
@ -348,8 +350,10 @@ create_range_type (result_type, index_type, low_bound, high_bound)
|
||||||
|
|
||||||
|
|
||||||
/* Create an array type using either a blank type supplied in RESULT_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
|
or creating a new type, inheriting the objfile from RANGE_TYPE.
|
||||||
indices will be of type 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
|
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? */
|
sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
|
||||||
|
@ -374,7 +378,7 @@ create_array_type (result_type, element_type, range_type)
|
||||||
}
|
}
|
||||||
if (result_type == NULL)
|
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_CODE (result_type) = TYPE_CODE_ARRAY;
|
||||||
TYPE_TARGET_TYPE (result_type) = element_type;
|
TYPE_TARGET_TYPE (result_type) = element_type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue