Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Change handling of '!' operator in stap probes
@ 2020-12-31 23:02 Tom Tromey
  2021-01-03  7:59 ` Sergio Durigan Junior via Gdb-patches
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2020-12-31 23:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-20 18:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-31 23:02 [PATCH] Change handling of '!' operator in stap probes Tom Tromey
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox