From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Change handling of '!' operator in stap probes
Date: Thu, 31 Dec 2020 16:02:05 -0700 [thread overview]
Message-ID: <20201231230205.264712-1-tom@tromey.com> (raw)
While working on the expression rewrite, I noticed that the '!'
operator is handled as if it were a binary operator. However, this
seems incorrect. Instead, I think it should be handled alongside the
other unary operators in stap_parse_single_operand.
This patch makes this change.
Tested on x86-64 Fedora 32. However, I am not completely certain
whether the test suite manages to test this code.
gdb/ChangeLog
2020-12-31 Tom Tromey <tom@tromey.com>
* stap-probe.c (enum stap_operand_prec): Update comment.
(stap_get_operator_prec): Don't mention UNOP_LOGICAL_NOT.
(stap_get_opcode): Don't handle '!'.
(stap_parse_single_operand): Handle '!' here.
---
gdb/ChangeLog | 7 +++++++
gdb/stap-probe.c | 12 ++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index ffcded3c317..366bba093d9 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -253,8 +253,7 @@ enum stap_operand_prec
greater-than, etc) operands. */
STAP_OPERAND_PREC_ADD_CMP,
- /* Precedence of bitwise operands (bitwise OR, XOR, bitwise AND,
- logical NOT). */
+ /* Precedence of bitwise operands (bitwise OR, XOR, bitwise AND). */
STAP_OPERAND_PREC_BITWISE,
/* Precedence of multiplicative operands (multiplication, division,
@@ -306,7 +305,6 @@ stap_get_operator_prec (enum exp_opcode op)
case BINOP_BITWISE_IOR:
case BINOP_BITWISE_AND:
case BINOP_BITWISE_XOR:
- case UNOP_LOGICAL_NOT:
return STAP_OPERAND_PREC_BITWISE;
case BINOP_MUL:
@@ -402,10 +400,6 @@ stap_get_opcode (const char **s)
op = BINOP_BITWISE_XOR;
break;
- case '!':
- op = UNOP_LOGICAL_NOT;
- break;
-
case '+':
op = BINOP_ADD;
break;
@@ -870,7 +864,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
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. */
@@ -924,6 +918,8 @@ stap_parse_single_operand (struct stap_parse_info *p)
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))
--
2.26.2
next reply other threads:[~2020-12-31 23:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-31 23:02 Tom Tromey [this message]
2021-01-03 7:59 ` Sergio Durigan Junior via Gdb-patches
2021-01-12 15:52 ` Sergio Durigan Junior via Gdb-patches
2021-01-18 2:49 ` Sergio Durigan Junior via Gdb-patches
2021-01-20 18:40 ` Tom Tromey
2021-01-20 18:55 ` Sergio Durigan Junior via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201231230205.264712-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox