qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 1/5] Rename the singlestep global variable to one_insn_per_tb


From: Peter Maydell
Subject: [RFC PATCH 1/5] Rename the singlestep global variable to one_insn_per_tb
Date: Mon, 6 Feb 2023 17:13:55 +0000

The 'singlestep' global variable is badly misnamed, because it has
nothing to do with single-stepping the emulation either via the gdb
stub or by emulation of architectural debug facilities.  Instead what
it does is force TCG to put only one instruction into each TB.
Rename it to one_insn_per_tb, so that it reflects what it does better
and is easier to search for in the codebase.

This misnaming is also present in user-facing interfaces: the command
line option '-singlestep', the HMP 'singlestep' command, and the QMP
StatusInfo object.  Those are harder to update because we need to
retain backwards compatibility.  Subsequent patches will add
better-named aliases so we can eventually deprecate-and-drop the old,
bad name.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/exec/cpu-common.h   | 2 +-
 accel/tcg/cpu-exec.c        | 4 ++--
 bsd-user/main.c             | 4 ++--
 linux-user/main.c           | 4 ++--
 softmmu/globals.c           | 2 +-
 softmmu/runstate-hmp-cmds.c | 4 ++--
 softmmu/runstate.c          | 2 +-
 softmmu/vl.c                | 2 +-
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 6feaa40ca7b..f2592a1967f 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -163,7 +163,7 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
                         void *ptr, size_t len, bool is_write);
 
 /* vl.c */
-extern int singlestep;
+extern int one_insn_per_tb;
 
 void list_cpus(const char *optarg);
 
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 9c857eeb077..08a65f8d506 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -157,12 +157,12 @@ uint32_t curr_cflags(CPUState *cpu)
      * Record gdb single-step.  We should be exiting the TB by raising
      * EXCP_DEBUG, but to simplify other tests, disable chaining too.
      *
-     * For singlestep and -d nochain, suppress goto_tb so that
+     * For one-insn-per-tb and -d nochain, suppress goto_tb so that
      * we can log -d cpu,exec after every TB.
      */
     if (unlikely(cpu->singlestep_enabled)) {
         cflags |= CF_NO_GOTO_TB | CF_NO_GOTO_PTR | CF_SINGLE_STEP | 1;
-    } else if (singlestep) {
+    } else if (one_insn_per_tb) {
         cflags |= CF_NO_GOTO_TB | 1;
     } else if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
         cflags |= CF_NO_GOTO_TB;
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 6f09180d654..a8de6906ed5 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -50,7 +50,7 @@
 #include "host-os.h"
 #include "target_arch_cpu.h"
 
-int singlestep;
+int one_insn_per_tb;
 uintptr_t guest_base;
 bool have_guest_base;
 /*
@@ -391,7 +391,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(r, "seed")) {
             seed_optarg = optarg;
         } else if (!strcmp(r, "singlestep")) {
-            singlestep = 1;
+            one_insn_per_tb = 1;
         } else if (!strcmp(r, "strace")) {
             do_strace = 1;
         } else if (!strcmp(r, "trace")) {
diff --git a/linux-user/main.c b/linux-user/main.c
index 4290651c3cf..99bcd542b42 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -66,7 +66,7 @@
 
 char *exec_path;
 
-int singlestep;
+int one_insn_per_tb;
 static const char *argv0;
 static const char *gdbstub;
 static envlist_t *envlist;
@@ -397,7 +397,7 @@ static void handle_arg_reserved_va(const char *arg)
 
 static void handle_arg_singlestep(const char *arg)
 {
-    singlestep = 1;
+    one_insn_per_tb = 1;
 }
 
 static void handle_arg_strace(const char *arg)
diff --git a/softmmu/globals.c b/softmmu/globals.c
index 527edbefdd0..f46df89d2db 100644
--- a/softmmu/globals.c
+++ b/softmmu/globals.c
@@ -43,7 +43,7 @@ int vga_interface_type = VGA_NONE;
 bool vga_interface_created;
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 int win2k_install_hack;
-int singlestep;
+int one_insn_per_tb;
 int fd_bootchk = 1;
 int graphic_rotate;
 QEMUOptionRom option_rom[MAX_OPTION_ROMS];
diff --git a/softmmu/runstate-hmp-cmds.c b/softmmu/runstate-hmp-cmds.c
index d55a7d4db89..29c9a038863 100644
--- a/softmmu/runstate-hmp-cmds.c
+++ b/softmmu/runstate-hmp-cmds.c
@@ -44,9 +44,9 @@ void hmp_singlestep(Monitor *mon, const QDict *qdict)
 {
     const char *option = qdict_get_try_str(qdict, "option");
     if (!option || !strcmp(option, "on")) {
-        singlestep = 1;
+        one_insn_per_tb = 1;
     } else if (!strcmp(option, "off")) {
-        singlestep = 0;
+        one_insn_per_tb = 0;
     } else {
         monitor_printf(mon, "unexpected option %s\n", option);
     }
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index cab9f6fc075..8272aef43b4 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -236,7 +236,7 @@ StatusInfo *qmp_query_status(Error **errp)
     StatusInfo *info = g_malloc0(sizeof(*info));
 
     info->running = runstate_is_running();
-    info->singlestep = singlestep;
+    info->singlestep = one_insn_per_tb;
     info->status = current_run_state;
 
     return info;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 9177d95d4ec..dbe5124b5e7 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2957,7 +2957,7 @@ void qemu_init(int argc, char **argv)
                 qdict_put_str(machine_opts_dict, "firmware", optarg);
                 break;
             case QEMU_OPTION_singlestep:
-                singlestep = 1;
+                one_insn_per_tb = 1;
                 break;
             case QEMU_OPTION_S:
                 autostart = 0;
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]