/* SystemTap probe support for GDB.
- Copyright (C) 2012-2020 Free Software Foundation, Inc.
+ Copyright (C) 2012-2021 Free Software Foundation, Inc.
This file is part of GDB.
return;
}
- if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+')
+ if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' || *p->arg == '!')
{
char c = *p->arg;
/* We use this variable to do a lookahead. */
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
else if (c == '~')
write_exp_elt_opcode (&p->pstate, UNOP_COMPLEMENT);
+ else if (c == '!')
+ write_exp_elt_opcode (&p->pstate, UNOP_LOGICAL_NOT);
}
}
else if (isdigit (*p->arg))
{
gdb_assert (gdbarch_stap_is_single_operand_p (p->gdbarch));
- if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' /* Unary. */
+ if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' || *p->arg == '!'
|| isdigit (*p->arg)
|| gdbarch_stap_is_single_operand (p->gdbarch, p->arg))
stap_parse_single_operand (p);
stap_parse_argument_1 (p, 0, STAP_OPERAND_PREC_NONE);
- --p->inside_paren_p;
+ p->arg = skip_spaces (p->arg);
if (*p->arg != ')')
- error (_("Missign close-paren on expression `%s'."),
+ error (_("Missing close-parenthesis on expression `%s'."),
p->saved_arg);
+ --p->inside_paren_p;
++p->arg;
if (p->inside_paren_p)
p->arg = skip_spaces (p->arg);
stap_parse_argument_conditionally (p);
}
+ if (p->inside_paren_p)
+ p->arg = skip_spaces (p->arg);
+
/* Start to parse the right-side, and to "join" left and right sides
depending on the operation specified.
if (p->inside_paren_p)
p->arg = skip_spaces (p->arg);
- /* Parse the right-side of the expression. */
+ /* Parse the right-side of the expression.
+
+ We save whether the right-side is a parenthesized
+ subexpression because, if it is, we will have to finish
+ processing this part of the expression before continuing. */
+ bool paren_subexp = *p->arg == '(';
+
stap_parse_argument_conditionally (p);
+ if (p->inside_paren_p)
+ p->arg = skip_spaces (p->arg);
+ if (paren_subexp)
+ {
+ write_exp_elt_opcode (&p->pstate, opcode);
+ continue;
+ }
/* While we still have operators, try to parse another
right-side, but using the current right-side as a left-side. */
/* Parse the right-side of the expression, but since we already
have a left-side at this point, set `has_lhs' to 1. */
stap_parse_argument_1 (p, 1, lookahead_prec);
+ if (p->inside_paren_p)
+ p->arg = skip_spaces (p->arg);
}
write_exp_elt_opcode (&p->pstate, opcode);
stap_probe::evaluate_argument (unsigned n, struct frame_info *frame)
{
struct stap_probe_arg *arg;
- int pos = 0;
struct gdbarch *gdbarch = get_frame_arch (frame);
arg = this->get_arg_by_number (n, gdbarch);
- return evaluate_subexp_standard (arg->atype, arg->aexpr.get (), &pos,
- EVAL_NORMAL);
+ return evaluate_expression (arg->aexpr.get (), arg->atype);
}
/* Compile the probe's argument N (indexed from 0) to agent expression.