From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [FYI 3/5] Slightly improve logic of some operations on stap-probe.c
Date: Thu, 16 May 2019 20:35:00 -0000 [thread overview]
Message-ID: <20190516203501.25992-4-sergiodj@redhat.com> (raw)
In-Reply-To: <20190516203501.25992-1-sergiodj@redhat.com>
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 <sergiodj@redhat.com>
* 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 <sergiodj@redhat.com>
+
+ * 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 <sergiodj@redhat.com>
* 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);
--
2.17.2
next prev parent reply other threads:[~2019-05-16 20:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 20:35 [FYI 0/5] Some improvements on stap code Sergio Durigan Junior
2019-05-16 20:35 ` [FYI 2/5] Update some comments on stap-probe.c Sergio Durigan Junior
2019-05-16 20:35 ` Sergio Durigan Junior [this message]
2019-05-16 20:35 ` [FYI 1/5] Bool-ify stap-probe.c and stap-related code on i386-tdep.c Sergio Durigan Junior
2019-05-16 20:41 ` [FYI 4/5] Fix complaint string formatting on stap-probe.c Sergio Durigan Junior
2019-05-16 20:44 ` [FYI 5/5] Make stap-probe.c:stap_parse_register_operand's "regname" an std::string Sergio Durigan Junior
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=20190516203501.25992-4-sergiodj@redhat.com \
--to=sergiodj@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).