* expression.h (enum exp_opcode): Document a register name for

OP_REGISTER.
	* parse.c (write_dollar_variable): Write the register name for
	OP_REGISTER.
	(operator_length_standard): Expect the register name following
	OP_REGISTER.
	* ada-lang.c (resolve_subexp): Likewise.
	* ax-gdb.c (gen_expr): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	* expprint.c (print_subexp_standard, dump_subexp_body_standard):
	Likewise.
	* tracepoint.c (encode_actions): Likewise.
This commit is contained in:
Daniel Jacobowitz
2007-06-13 17:11:09 +00:00
parent 0caa462c16
commit 67f3407ffb
8 changed files with 60 additions and 24 deletions

View File

@@ -1,3 +1,18 @@
2007-06-13 Daniel Jacobowitz <dan@codesourcery.com>
* expression.h (enum exp_opcode): Document a register name for
OP_REGISTER.
* parse.c (write_dollar_variable): Write the register name for
OP_REGISTER.
(operator_length_standard): Expect the register name following
OP_REGISTER.
* ada-lang.c (resolve_subexp): Likewise.
* ax-gdb.c (gen_expr): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* expprint.c (print_subexp_standard, dump_subexp_body_standard):
Likewise.
* tracepoint.c (encode_actions): Likewise.
2007-06-13 Daniel Jacobowitz <dan@codesourcery.com> 2007-06-13 Daniel Jacobowitz <dan@codesourcery.com>
* utils.c (set_screen_size): Use INT_MAX for default columns. * utils.c (set_screen_size): Use INT_MAX for default columns.

View File

@@ -2710,7 +2710,6 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
case OP_TYPE: case OP_TYPE:
case OP_BOOL: case OP_BOOL:
case OP_LAST: case OP_LAST:
case OP_REGISTER:
case OP_INTERNALVAR: case OP_INTERNALVAR:
*pos += 3; *pos += 3;
break; break;
@@ -2720,6 +2719,10 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
nargs = 1; nargs = 1;
break; break;
case OP_REGISTER:
*pos += 4 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
break;
case STRUCTOP_STRUCT: case STRUCTOP_STRUCT:
*pos += 4 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); *pos += 4 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
nargs = 1; nargs = 1;

View File

@@ -1599,8 +1599,14 @@ gen_expr (union exp_element **pc, struct agent_expr *ax,
case OP_REGISTER: case OP_REGISTER:
{ {
int reg = (int) (*pc)[1].longconst; const char *name = &(*pc)[2].string;
(*pc) += 3; int reg;
(*pc) += 4 + BYTES_TO_EXP_ELEM ((*pc)[1].longconst + 1);
reg = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
name, strlen (name));
if (reg == -1)
internal_error (__FILE__, __LINE__,
_("Register $%s not available"), name);
value->kind = axs_lvalue_register; value->kind = axs_lvalue_register;
value->u.reg = reg; value->u.reg = reg;
value->type = register_type (current_gdbarch, reg); value->type = register_type (current_gdbarch, reg);

View File

@@ -500,16 +500,21 @@ evaluate_subexp_standard (struct type *expect_type,
case OP_REGISTER: case OP_REGISTER:
{ {
int regno = longest_to_int (exp->elts[pc + 1].longconst); const char *name = &exp->elts[pc + 2].string;
int regno;
struct value *val; struct value *val;
(*pos) += 2;
(*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
regno = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
name, strlen (name));
if (regno == -1)
error (_("Register $%s not available."), name);
if (noside == EVAL_AVOID_SIDE_EFFECTS) if (noside == EVAL_AVOID_SIDE_EFFECTS)
val = value_zero (register_type (current_gdbarch, regno), not_lval); val = value_zero (register_type (current_gdbarch, regno), not_lval);
else else
val = value_of_register (regno, get_selected_frame (NULL)); val = value_of_register (regno, get_selected_frame (NULL));
if (val == NULL) if (val == NULL)
error (_("Value of register %s not available."), error (_("Value of register %s not available."), name);
frame_map_regnum_to_name (get_selected_frame (NULL), regno));
else else
return val; return val;
} }

View File

@@ -130,10 +130,8 @@ print_subexp_standard (struct expression *exp, int *pos,
case OP_REGISTER: case OP_REGISTER:
{ {
int regnum = longest_to_int (exp->elts[pc + 1].longconst); const char *name = &exp->elts[pc + 2].string;
const char *name = user_reg_map_regnum_to_name (current_gdbarch, (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
regnum);
(*pos) += 2;
fprintf_filtered (stream, "$%s", name); fprintf_filtered (stream, "$%s", name);
return; return;
} }
@@ -965,9 +963,8 @@ dump_subexp_body_standard (struct expression *exp,
elt += 2; elt += 2;
break; break;
case OP_REGISTER: case OP_REGISTER:
fprintf_filtered (stream, "Register %ld", fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string);
(long) exp->elts[elt].longconst); elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1);
elt += 2;
break; break;
case OP_INTERNALVAR: case OP_INTERNALVAR:
fprintf_filtered (stream, "Internal var @"); fprintf_filtered (stream, "Internal var @");

View File

@@ -166,9 +166,8 @@ enum exp_opcode
With another OP_LAST at the end, this makes three exp_elements. */ With another OP_LAST at the end, this makes three exp_elements. */
OP_LAST, OP_LAST,
/* OP_REGISTER is followed by an integer in the next exp_element. /* OP_REGISTER is followed by a string in the next exp_element.
This is the number of a register to fetch (as an int). This is the name of a register to fetch. */
With another OP_REGISTER at the end, this makes three exp_elements. */
OP_REGISTER, OP_REGISTER,
/* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element. /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.

View File

@@ -548,7 +548,9 @@ handle_last:
return; return;
handle_register: handle_register:
write_exp_elt_opcode (OP_REGISTER); write_exp_elt_opcode (OP_REGISTER);
write_exp_elt_longcst (i); str.length--;
str.ptr++;
write_exp_string (str);
write_exp_elt_opcode (OP_REGISTER); write_exp_elt_opcode (OP_REGISTER);
return; return;
} }
@@ -717,7 +719,6 @@ operator_length_standard (struct expression *expr, int endpos,
case OP_TYPE: case OP_TYPE:
case OP_BOOL: case OP_BOOL:
case OP_LAST: case OP_LAST:
case OP_REGISTER:
case OP_INTERNALVAR: case OP_INTERNALVAR:
oplen = 3; oplen = 3;
break; break;
@@ -772,6 +773,7 @@ operator_length_standard (struct expression *expr, int endpos,
case STRUCTOP_PTR: case STRUCTOP_PTR:
args = 1; args = 1;
/* fall through */ /* fall through */
case OP_REGISTER:
case OP_M2_STRING: case OP_M2_STRING:
case OP_STRING: case OP_STRING:
case OP_OBJC_NSSTRING: /* Objective C Foundation Class NSString constant */ case OP_OBJC_NSSTRING: /* Objective C Foundation Class NSString constant */

View File

@@ -1602,11 +1602,20 @@ encode_actions (struct tracepoint *t, char ***tdp_actions,
switch (exp->elts[0].opcode) switch (exp->elts[0].opcode)
{ {
case OP_REGISTER: case OP_REGISTER:
i = exp->elts[1].longconst; {
const char *name = &exp->elts[2].string;
i = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
name, strlen (name));
if (i == -1)
internal_error (__FILE__, __LINE__,
_("Register $%s not available"),
name);
if (info_verbose) if (info_verbose)
printf_filtered ("OP_REGISTER: "); printf_filtered ("OP_REGISTER: ");
add_register (collect, i); add_register (collect, i);
break; break;
}
case UNOP_MEMVAL: case UNOP_MEMVAL:
/* safe because we know it's a simple expression */ /* safe because we know it's a simple expression */