From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id vBU6GHVY7l8qMQAAWB0awg (envelope-from ) for ; Thu, 31 Dec 2020 18:02:13 -0500 Received: by simark.ca (Postfix, from userid 112) id 53CC61F0AA; Thu, 31 Dec 2020 18:02:13 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,RDNS_NONE,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E3B521E552 for ; Thu, 31 Dec 2020 18:02:12 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F7DC385480A; Thu, 31 Dec 2020 23:02:12 +0000 (GMT) Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.50.185]) by sourceware.org (Postfix) with ESMTPS id D997A3857815 for ; Thu, 31 Dec 2020 23:02:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D997A3857815 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 2E48A46A8 for ; Thu, 31 Dec 2020 17:02:08 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id v6xLkluwoDT64v6xMkthYf; Thu, 31 Dec 2020 17:02:08 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=MU9Y/+oOgpwXcFUlm2+tgsgWZSCQgBtEvR72SoetkE8=; b=QdnV9Av/d4mmdUdZ2VISKyGW2L aGW+RycHwCa7A0jiskQIww7wCq2+FUGGMBBd8ssnFEZsg0Vq8sVN1k05I+ufYU27vTOHhr3v3pAFx 3A88/aduK2dAsR9yqJjWMwa9R; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:57490 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kv6xL-000Bsp-Eg; Thu, 31 Dec 2020 16:02:07 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH] Change handling of '!' operator in stap probes Date: Thu, 31 Dec 2020 16:02:05 -0700 Message-Id: <20201231230205.264712-1-tom@tromey.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kv6xL-000Bsp-Eg X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:57490 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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 * 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