public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] fix detection of binary being named "step"
@ 2022-03-22 22:19 Reuben Thomas
  0 siblings, 0 replies; only message in thread
From: Reuben Thomas @ 2022-03-22 22:19 UTC (permalink / raw)
  To: Reuben Thomas via Gdb-patches

[-- 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-22 22:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22 22:19 [PATCH] fix detection of binary being named "step" Reuben Thomas

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).