From patchwork Thu May 16 20:34:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 32729 Received: (qmail 21285 invoked by alias); 16 May 2019 20:35:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 21190 invoked by uid 89); 16 May 2019 20:35:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 May 2019 20:35:13 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D56F983F40 for ; Thu, 16 May 2019 20:35:12 +0000 (UTC) Received: from psique.yyz.redhat.com (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A9E05C70A; Thu, 16 May 2019 20:35:12 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior Subject: [FYI 3/5] Slightly improve logic of some operations on stap-probe.c Date: Thu, 16 May 2019 16:34:59 -0400 Message-Id: <20190516203501.25992-4-sergiodj@redhat.com> In-Reply-To: <20190516203501.25992-1-sergiodj@redhat.com> References: <20190516203501.25992-1-sergiodj@redhat.com> X-IsSubscribed: yes This patch contains three very small improvement on the logic of some operations we do on stap-probe.c. They don't change what the code does. Pushed as obvious. gdb/ChangeLog: 2019-05-16 Sergio Durigan Junior * stap-probe.c (stap_parse_register_operand): Make "if (*p->arg == '-')" and "else if". (stap_parse_single_operand): Join checks for "gdbarch_stap_parse_special_token_p" and "gdbarch_stap_parse_special_token" in the same "if" statement. Invert check when verifying for operation on register displacement. --- gdb/ChangeLog | 10 ++++++++++ gdb/stap-probe.c | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3389167adb..c89b7039e8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2019-05-16 Sergio Durigan Junior + + * stap-probe.c (stap_parse_register_operand): Make "if (*p->arg == + '-')" and "else if". + (stap_parse_single_operand): Join checks for + "gdbarch_stap_parse_special_token_p" and + "gdbarch_stap_parse_special_token" in the same "if" statement. + Invert check when verifying for operation on register + displacement. + 2019-05-16 Sergio Durigan Junior * stap-probe.c (stap_get_opcode): Update comment. diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index bc2f9fc85b..db9231558f 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -705,8 +705,7 @@ stap_parse_register_operand (struct stap_parse_info *p) pointer. */ ++p->arg; } - - if (*p->arg == '-') + else if (*p->arg == '-') { got_minus = true; ++p->arg; @@ -842,15 +841,15 @@ stap_parse_single_operand (struct stap_parse_info *p) const char *int_prefix = NULL; /* We first try to parse this token as a "special token". */ - if (gdbarch_stap_parse_special_token_p (gdbarch)) - if (gdbarch_stap_parse_special_token (gdbarch, p) != 0) - { - /* If the return value of the above function is not zero, - it means it successfully parsed the special token. + if (gdbarch_stap_parse_special_token_p (gdbarch) + && (gdbarch_stap_parse_special_token (gdbarch, p) != 0)) + { + /* If the return value of the above function is not zero, + it means it successfully parsed the special token. - If it is NULL, we try to parse it using our method. */ - return; - } + If it is NULL, we try to parse it using our method. */ + return; + } if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+') { @@ -890,7 +889,7 @@ stap_parse_single_operand (struct stap_parse_info *p) { /* If we are here, it means it is a displacement. The only operations allowed here are `-' and `+'. */ - if (c == '~') + if (c != '-' && c != '+') error (_("Invalid operator `%c' for register displacement " "on expression `%s'."), c, p->saved_arg);