--- a/ax-gdb.c +++ b/ax-gdb.c @@ -43,6 +43,7 @@ #include "arch-utils.h" #include "cli/cli-utils.h" #include "linespec.h" +#include "target-attributes.h" #include "valprint.h" #include "c-lang.h" @@ -1923,22 +1924,38 @@ gen_expr (struct expression *exp, union { char *name = internalvar_name ((*pc)[1].internalvar); struct trace_state_variable *tsv; + struct target_attribute *ta; + int id = -1; (*pc) += 3; gen_expr (exp, pc, ax, value); - tsv = find_trace_state_variable (name); - if (tsv) + + ta = find_target_attribute_name (name); + if (ta) { - ax_tsv (ax, aop_setv, tsv->number); + check_agent_target_attribute (ta, 1); + id = ta->id; + } + else + { + tsv = find_trace_state_variable (name); + if (tsv) + id = tsv->number; + } + + if (id >= 0) + { + ax_tsv (ax, aop_setv, id); if (trace_kludge) - ax_tsv (ax, aop_tracev, tsv->number); + ax_tsv (ax, aop_tracev, id); } else - error (_("$%s is not a trace state variable, " + error (_("$%s is not a target attribute or trace state variable, " "may not assign to it"), name); } else - error (_("May only assign to trace state variables")); + error (_("\ +May only assign to target attribute or trace state variables")); break; case BINOP_ASSIGN_MODIFY: @@ -1949,32 +1966,51 @@ gen_expr (struct expression *exp, union if ((*pc)[0].opcode == OP_INTERNALVAR) { char *name = internalvar_name ((*pc)[1].internalvar); - struct trace_state_variable *tsv; + struct trace_state_variable *tsv = NULL; + struct target_attribute *ta = NULL; + int id = -1; (*pc) += 3; - tsv = find_trace_state_variable (name); - if (tsv) + + ta = find_target_attribute_name (name); + if (ta) + { + check_agent_target_attribute (ta, 0); + id = ta->id; + } + else + { + tsv = find_trace_state_variable (name); + if (tsv) + id = tsv->number; + } + + if (id >= 0) { /* The tsv will be the left half of the binary operation. */ - ax_tsv (ax, aop_getv, tsv->number); + ax_tsv (ax, aop_getv, id); if (trace_kludge) - ax_tsv (ax, aop_tracev, tsv->number); + ax_tsv (ax, aop_tracev, id); /* Trace state variables are always 64-bit integers. */ value1.kind = axs_rvalue; - value1.type = builtin_type (exp->gdbarch)->builtin_long_long; + if (ta) + value1.type = target_attribute_type (exp->gdbarch, ta); + else + value1.type = builtin_type (exp->gdbarch)->builtin_long_long; /* Now do right half of expression. */ gen_expr_binop_rest (exp, op2, pc, ax, value, &value1, &value2); /* We have a result of the binary op, set the tsv. */ - ax_tsv (ax, aop_setv, tsv->number); + ax_tsv (ax, aop_setv, id); if (trace_kludge) - ax_tsv (ax, aop_tracev, tsv->number); + ax_tsv (ax, aop_tracev, id); } else - error (_("$%s is not a trace state variable, " + error (_("$%s is not a target attribute or trace state variable, " "may not assign to it"), name); } else - error (_("May only assign to trace state variables")); + error (_("\ +May only assign to target attribute or trace state variables")); break; /* Note that we need to be a little subtle about generating code @@ -2040,22 +2076,41 @@ gen_expr (struct expression *exp, union { struct internalvar *var = (*pc)[1].internalvar; const char *name = internalvar_name (var); - struct trace_state_variable *tsv; + struct trace_state_variable *tsv = NULL; + struct target_attribute *ta = NULL; + int id = -1; (*pc) += 3; - tsv = find_trace_state_variable (name); - if (tsv) + + ta = find_target_attribute_name (name); + if (ta) + { + check_agent_target_attribute (ta, 0); + id = ta->id; + } + else { - ax_tsv (ax, aop_getv, tsv->number); + tsv = find_trace_state_variable (name); + if (tsv) + id = tsv->number; + } + + if (id >= 0) + { + ax_tsv (ax, aop_getv, id); if (trace_kludge) - ax_tsv (ax, aop_tracev, tsv->number); + ax_tsv (ax, aop_tracev, id); /* Trace state variables are always 64-bit integers. */ value->kind = axs_rvalue; - value->type = builtin_type (exp->gdbarch)->builtin_long_long; + if (ta) + value->type = target_attribute_type (exp->gdbarch, ta); + else + value->type = builtin_type (exp->gdbarch)->builtin_long_long; } else if (! compile_internalvar_to_ax (var, ax, value)) - error (_("$%s is not a trace state variable; GDB agent " - "expressions cannot use convenience variables."), name); + error (_("$%s is not a target attribute or trace state variable; " + "GDB agent expressions cannot use convenience variables."), + name); } break; --- a/remote.c +++ b/remote.c @@ -10339,7 +10339,9 @@ remote_download_tracepoint (struct bp_lo capabilities at definition time. */ if (remote_supports_cond_tracepoints ()) { + struct cleanup *back_to = set_check_agent_target_attribute (loc); aexpr = gen_eval_for_expr (tpaddr, loc->cond); + do_cleanups (back_to); aexpr_chain = make_cleanup_free_agent_expr (aexpr); xsnprintf (buf + strlen (buf), BUF_SIZE - strlen (buf), ":X%x,", aexpr->len); --- a/tracepoint.c +++ b/tracepoint.c @@ -786,6 +786,7 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { + struct cleanup *back_to; p = tmp_p; exp = parse_exp_1 (&p, loc->address, block_for_pc (loc->address), 1); @@ -809,10 +810,12 @@ validate_actionline (char **line, struct } } + back_to = set_check_agent_target_attribute (loc); /* We have something to collect, make sure that the expr to bytecode translator can handle it and that it's not too long. */ aexpr = gen_trace_for_expr (loc->address, exp); + do_cleanups (back_to); make_cleanup_free_agent_expr (aexpr); if (aexpr->len > MAX_AGENT_EXPR_LEN) @@ -839,16 +842,20 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { + struct cleanup *back_to; + p = tmp_p; /* Only expressions are allowed for this action. */ exp = parse_exp_1 (&p, loc->address, block_for_pc (loc->address), 1); old_chain = make_cleanup (free_current_contents, &exp); + back_to = set_check_agent_target_attribute (loc); /* We have something to evaluate, make sure that the expr to bytecode translator can handle it and that it's not too long. */ aexpr = gen_eval_for_expr (loc->address, exp); + do_cleanups (back_to); make_cleanup_free_agent_expr (aexpr); if (aexpr->len > MAX_AGENT_EXPR_LEN) @@ -1506,6 +1513,7 @@ encode_actions_1 (struct command_line *a unsigned long addr, len; struct cleanup *old_chain = NULL; struct cleanup *old_chain1 = NULL; + struct cleanup *back_to; exp = parse_exp_1 (&action_exp, tloc->address, block_for_pc (tloc->address), 1); @@ -1547,7 +1555,9 @@ encode_actions_1 (struct command_line *a break; default: /* Full-fledged expression. */ + back_to = set_check_agent_target_attribute (tloc); aexpr = gen_trace_for_expr (tloc->address, exp); + do_cleanups (back_to); old_chain1 = make_cleanup_free_agent_expr (aexpr); @@ -1596,12 +1606,15 @@ encode_actions_1 (struct command_line *a { struct cleanup *old_chain = NULL; struct cleanup *old_chain1 = NULL; + struct cleanup *back_to; exp = parse_exp_1 (&action_exp, tloc->address, block_for_pc (tloc->address), 1); old_chain = make_cleanup (free_current_contents, &exp); + back_to = set_check_agent_target_attribute (tloc); aexpr = gen_eval_for_expr (tloc->address, exp); + do_cleanups (back_to); old_chain1 = make_cleanup_free_agent_expr (aexpr); ax_reqs (aexpr);