From 871a5af9482957c31b2c12984f1582d2e1f87d35 Mon Sep 17 00:00:00 2001 From: Reuben Thomas 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