public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Reuben Thomas <rrt@sc3d.org>
To: Reuben Thomas via Gdb-patches <gdb-patches@sourceware.org>
Subject: [PATCH] fix detection of binary being named "step"
Date: Tue, 22 Mar 2022 22:19:27 +0000	[thread overview]
Message-ID: <CAOnWdoj_c8OAOPeqqkQE_LQhjE4bio2sB+aqev7TwE9Viz+hcg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

This patch fixes the internal functionality of the standalone simulator
that allows testing of single stepping by naming the binary "step".

-- 
https://rrt.sc3d.org

[-- Attachment #2: 0001-sim-run-fix-detection-of-binary-being-called-step.patch --]
[-- Type: text/x-patch, Size: 1143 bytes --]

From 871a5af9482957c31b2c12984f1582d2e1f87d35 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Tue, 22 Mar 2022 22:12:41 +0000
Subject: [PATCH] sim/run: fix detection of binary being called 'step'

The string comparison to test the name of the program should
check the last four characters. Instead, it was checking the four
characters before the string!

	* nrun.c: Add strlen (myname) to the pointer, to get to the end of
        the string before counting back four characters.
---
 sim/common/nrun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index d13afcab03d..2618e576e5c 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -74,7 +74,7 @@ main (int argc, char **argv)
      instead of allowing it to run free.  The sole purpose of this
      HACK is to allow the sim_resume interface's step argument to be
      tested without having to build/run gdb. */
-  if (strlen (myname) > 4 && strcmp (myname - 4, "step") == 0)
+  if (strlen (myname) > 4 && strcmp (myname + strlen (myname) - 4, "step") == 0)
     {
       single_step = 1;
     }
-- 
2.25.1


                 reply	other threads:[~2022-03-22 22:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAOnWdoj_c8OAOPeqqkQE_LQhjE4bio2sB+aqev7TwE9Viz+hcg@mail.gmail.com \
    --to=rrt@sc3d.org \
    --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).