* ch-valprint.c (chill_val_print): Remove call to calculate_array_length.
(calculate_array_length): Move function from here ... * ch-exp.c (calculate_array_length): ... to here. (parse_primval): If we have a symbol with an array type and the length is 0, call calculate_array_length.
This commit is contained in:
parent
8b554809c0
commit
f046f4c87a
|
@ -1,3 +1,12 @@
|
||||||
|
Wed Apr 10 02:56:06 1996 Wilfried Moser (Alcatel) <moser@rtl.cygnus.com>
|
||||||
|
|
||||||
|
* ch-valprint.c (chill_val_print): Remove call to calculate_array_length.
|
||||||
|
(calculate_array_length): Move function from here ...
|
||||||
|
|
||||||
|
* ch-exp.c (calculate_array_length): ... to here.
|
||||||
|
(parse_primval): If we have a symbol with an array type
|
||||||
|
and the length is 0, call calculate_array_length.
|
||||||
|
|
||||||
Tue Apr 9 01:23:05 1996 Wilfried Moser (Alcatel) <moser@rtl.cygnus.com>
|
Tue Apr 9 01:23:05 1996 Wilfried Moser (Alcatel) <moser@rtl.cygnus.com>
|
||||||
|
|
||||||
* eval.c (evaluate_subexp_standard): In case of TYPE_CODE_SET:
|
* eval.c (evaluate_subexp_standard): In case of TYPE_CODE_SET:
|
||||||
|
|
63
gdb/ch-exp.c
63
gdb/ch-exp.c
|
@ -138,6 +138,7 @@ static int parse_opt_untyped_expr ();
|
||||||
static void parse_if_expression_body PARAMS((void));
|
static void parse_if_expression_body PARAMS((void));
|
||||||
static void write_lower_upper_value PARAMS ((enum exp_opcode, struct type *));
|
static void write_lower_upper_value PARAMS ((enum exp_opcode, struct type *));
|
||||||
static enum ch_terminal ch_lex ();
|
static enum ch_terminal ch_lex ();
|
||||||
|
static void calculate_array_length (struct type *);
|
||||||
|
|
||||||
#define MAX_LOOK_AHEAD 2
|
#define MAX_LOOK_AHEAD 2
|
||||||
static enum ch_terminal terminal_buffer[MAX_LOOK_AHEAD+1] = {
|
static enum ch_terminal terminal_buffer[MAX_LOOK_AHEAD+1] = {
|
||||||
|
@ -673,11 +674,20 @@ parse_primval ()
|
||||||
break;
|
break;
|
||||||
case GENERAL_PROCEDURE_NAME:
|
case GENERAL_PROCEDURE_NAME:
|
||||||
case LOCATION_NAME:
|
case LOCATION_NAME:
|
||||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
{
|
||||||
write_exp_elt_block (NULL);
|
struct type *type;
|
||||||
write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
|
|
||||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
/* FIXME: look at calculate_array_length */
|
||||||
FORWARD_TOKEN ();
|
type = PEEK_LVAL().ssym.sym->type;
|
||||||
|
if (type && TYPE_CODE (type) == TYPE_CODE_ARRAY &&
|
||||||
|
TYPE_LENGTH (type) == 0)
|
||||||
|
calculate_array_length (type);
|
||||||
|
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||||
|
write_exp_elt_block (NULL);
|
||||||
|
write_exp_elt_sym (PEEK_LVAL ().ssym.sym);
|
||||||
|
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||||
|
FORWARD_TOKEN ();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GDB_VARIABLE: /* gdb specific */
|
case GDB_VARIABLE: /* gdb specific */
|
||||||
FORWARD_TOKEN ();
|
FORWARD_TOKEN ();
|
||||||
|
@ -2082,6 +2092,49 @@ write_lower_upper_value (opcode, type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* In certain cases it could happen, that an array type doesn't
|
||||||
|
have a length (this have to do with seizing). The reason is
|
||||||
|
shown in the following stabs:
|
||||||
|
|
||||||
|
.stabs "m_x:Tt81=s36i:1,0,32;ar:82=ar80;0;1;83=xsm_struct:,32,256;;",128,0,25,0
|
||||||
|
|
||||||
|
.stabs "m_struct:Tt83=s16f1:9,0,16;f2:85=*84,32,32;f3:84,64,64;;",128,0,10,0
|
||||||
|
|
||||||
|
When processing t81, the array ar80 doesn't have a length, cause
|
||||||
|
struct m_struct is specified extern at thse moment. Afterwards m_struct
|
||||||
|
gets specified and updated, but not the surrounding type.
|
||||||
|
|
||||||
|
So we walk through array's till we find a type with a length and
|
||||||
|
calculate the array length.
|
||||||
|
|
||||||
|
FIXME: Where may this happen too ?
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
calculate_array_length (type)
|
||||||
|
struct type *type;
|
||||||
|
{
|
||||||
|
struct type *target_type;
|
||||||
|
struct type *range_type;
|
||||||
|
LONGEST lower_bound, upper_bound;
|
||||||
|
|
||||||
|
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
||||||
|
/* not an array, stop processing */
|
||||||
|
return;
|
||||||
|
|
||||||
|
target_type = TYPE_TARGET_TYPE (type);
|
||||||
|
range_type = TYPE_FIELD_TYPE (type, 0);
|
||||||
|
lower_bound = TYPE_FIELD_BITPOS (range_type, 0);
|
||||||
|
upper_bound = TYPE_FIELD_BITPOS (range_type, 1);
|
||||||
|
|
||||||
|
if (TYPE_LENGTH (target_type) == 0 &&
|
||||||
|
TYPE_CODE (target_type) == TYPE_CODE_ARRAY)
|
||||||
|
/* we've got another array */
|
||||||
|
calculate_array_length (target_type);
|
||||||
|
|
||||||
|
TYPE_LENGTH (type) = (upper_bound - lower_bound + 1) * TYPE_LENGTH (target_type);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
chill_error (msg)
|
chill_error (msg)
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
|
@ -176,49 +176,6 @@ chill_val_print_array_elements (type, valaddr, address, stream,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In certain cases it could happen, that an array type doesn't
|
|
||||||
have a length (this have to do with seizing). The reason is
|
|
||||||
shown in the following stabs:
|
|
||||||
|
|
||||||
.stabs "m_x:Tt81=s36i:1,0,32;ar:82=ar80;0;1;83=xsm_struct:,32,256;;",128,0,25,0
|
|
||||||
|
|
||||||
.stabs "m_struct:Tt83=s16f1:9,0,16;f2:85=*84,32,32;f3:84,64,64;;",128,0,10,0
|
|
||||||
|
|
||||||
When processing t81, the array ar80 doesn't have a length, cause
|
|
||||||
struct m_struct is specified extern at thse moment. Afterwards m_struct
|
|
||||||
gets specified and updated, but not the surrounding type.
|
|
||||||
|
|
||||||
So we walk through array's till we find a type with a length and
|
|
||||||
calculate the array length.
|
|
||||||
|
|
||||||
FIXME: Where may this happen too ?
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
|
||||||
calculate_array_length (type)
|
|
||||||
struct type *type;
|
|
||||||
{
|
|
||||||
struct type *target_type;
|
|
||||||
struct type *range_type;
|
|
||||||
LONGEST lower_bound, upper_bound;
|
|
||||||
|
|
||||||
if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
|
|
||||||
/* not an array, stop processing */
|
|
||||||
return;
|
|
||||||
|
|
||||||
target_type = TYPE_TARGET_TYPE (type);
|
|
||||||
range_type = TYPE_FIELD_TYPE (type, 0);
|
|
||||||
lower_bound = TYPE_FIELD_BITPOS (range_type, 0);
|
|
||||||
upper_bound = TYPE_FIELD_BITPOS (range_type, 1);
|
|
||||||
|
|
||||||
if (TYPE_LENGTH (target_type) == 0 &&
|
|
||||||
TYPE_CODE (target_type) == TYPE_CODE_ARRAY)
|
|
||||||
/* we've got another array */
|
|
||||||
calculate_array_length (target_type);
|
|
||||||
|
|
||||||
TYPE_LENGTH (type) = (upper_bound - lower_bound + 1) * TYPE_LENGTH (target_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print data of type TYPE located at VALADDR (within GDB), which came from
|
/* Print data of type TYPE located at VALADDR (within GDB), which came from
|
||||||
the inferior at address ADDRESS, onto stdio stream STREAM according to
|
the inferior at address ADDRESS, onto stdio stream STREAM according to
|
||||||
FORMAT (a letter or 0 for natural format). The data at VALADDR is in
|
FORMAT (a letter or 0 for natural format). The data at VALADDR is in
|
||||||
|
@ -254,10 +211,6 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
|
||||||
switch (TYPE_CODE (type))
|
switch (TYPE_CODE (type))
|
||||||
{
|
{
|
||||||
case TYPE_CODE_ARRAY:
|
case TYPE_CODE_ARRAY:
|
||||||
if (TYPE_LENGTH (type) == 0)
|
|
||||||
/* see comment function calculate_array_length */
|
|
||||||
calculate_array_length (type);
|
|
||||||
|
|
||||||
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
|
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
|
||||||
{
|
{
|
||||||
if (prettyprint_arrays)
|
if (prettyprint_arrays)
|
||||||
|
|
Loading…
Reference in New Issue