Hold @can_reverse in AccelGdbConfig, set it when initializing
AccelState in AccelClass::init_machine handlers (only TCG sets
it). Remove gdb_can_reverse() as now unused.

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Manos Pitsidianakis <[email protected]>
Message-ID: <[email protected]>
---
 gdbstub/internals.h  | 1 -
 include/qemu/accel.h | 2 ++
 accel/tcg/tcg-all.c  | 3 +++
 gdbstub/gdbstub.c    | 4 ++--
 gdbstub/system.c     | 5 -----
 gdbstub/user.c       | 6 ------
 6 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index 0444dee2246..0b74ea4000f 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -154,7 +154,6 @@ CPUState *gdb_first_attached_cpu(void);
 void gdb_append_thread_id(CPUState *cpu, GString *buf);
 int gdb_get_cpu_index(CPUState *cpu);
 unsigned int gdb_get_max_cpus(void); /* both */
-bool gdb_can_reverse(void); /* system emulation, stub for user */
 int gdb_target_sigtrap(void); /* user */
 
 void gdb_create_default_process(GDBState *s);
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 3b01d55741b..8e0c3dfe088 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -77,9 +77,11 @@ void accel_cpu_common_unrealize(CPUState *cpu);
  * struct AccelGdbConfig - gdbstub configuration for an accelerator.
  *
  * @sstep_flags: Set SSTEP_* flags that accelerator supports for guest debug.
+ * @can_reverse: Whether reverse mode is supported.
  */
 typedef struct AccelGdbConfig {
     unsigned sstep_flags;
+    bool can_reverse;
 } AccelGdbConfig;
 
 #endif /* QEMU_ACCEL_H */
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index d30b53cd3b7..7186c10cf02 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -159,6 +159,9 @@ static int tcg_init_machine(AccelState *as, MachineState 
*ms)
          */
         as->gdbstub.sstep_flags |= SSTEP_NOIRQ | SSTEP_NOTIMER;
     }
+    if (replay_mode == REPLAY_MODE_PLAY) {
+        as->gdbstub.can_reverse = true;
+    }
 
     page_init();
     tb_htable_init();
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 6c4fa065638..0a328b0dd48 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -1376,7 +1376,7 @@ static void handle_step(GArray *params, void *user_ctx)
 
 static void handle_backward(GArray *params, void *user_ctx)
 {
-    if (!gdb_can_reverse()) {
+    if (!gdbserver_state.accel_config.can_reverse) {
         gdb_put_packet("E22");
         return;
     }
@@ -1684,7 +1684,7 @@ static void handle_query_supported(GArray *params, void 
*user_ctx)
         g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
     }
 
-    if (gdb_can_reverse()) {
+    if (gdbserver_state.accel_config.can_reverse) {
         g_string_append(gdbserver_state.str_buf,
             ";ReverseStep+;ReverseContinue+");
     }
diff --git a/gdbstub/system.c b/gdbstub/system.c
index 1179c82cb86..2e8c457097b 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -479,11 +479,6 @@ unsigned int gdb_get_max_cpus(void)
     return ms->smp.max_cpus;
 }
 
-bool gdb_can_reverse(void)
-{
-    return replay_mode == REPLAY_MODE_PLAY;
-}
-
 /*
  * Softmmu specific command helpers
  */
diff --git a/gdbstub/user.c b/gdbstub/user.c
index f7bc4e63dfd..299388b9f71 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -786,12 +786,6 @@ unsigned int gdb_get_max_cpus(void)
     return max_cpus;
 }
 
-/* replay not supported for user-mode */
-bool gdb_can_reverse(void)
-{
-    return false;
-}
-
 /*
  * Break/Watch point helpers
  */
-- 
2.53.0


Reply via email to