@samitouri / QOSamiQemu / commits / 2aaa8ee7de

accel: Hold @can_reverse information in AccelGdbConfig

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é <philmd@oss.qualcomm.com> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Message-ID: <20260705215729.62196-17-philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Jun 26, 2026 at 12:41 UTC 2aaa8ee7dec5a8a10ec2c69ea774971e940f26d3
6 files changed +7 -14
accel/tcg/tcg-all.c
+3
@@ -159,6 +159,9 @@ static int tcg_init_machine(AccelState *as, MachineState *ms)
159 */
160 as->gdbstub.sstep_flags |= SSTEP_NOIRQ | SSTEP_NOTIMER;
161 }
162 + if (replay_mode == REPLAY_MODE_PLAY) {
163 + as->gdbstub.can_reverse = true;
164 + }
165
166 page_init();
167 tb_htable_init();
gdbstub/gdbstub.c
+2 -2
@@ -1376,7 +1376,7 @@ static void handle_step(GArray *params, void *user_ctx)
1376
1377 static void handle_backward(GArray *params, void *user_ctx)
1378 {
1379 - if (!gdb_can_reverse()) {
1379 + if (!gdbserver_state.accel_config.can_reverse) {
1380 gdb_put_packet("E22");
1381 return;
1382 }
@@ -1684,7 +1684,7 @@ static void handle_query_supported(GArray *params, void *user_ctx)
1684 g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
1685 }
1686
1687 - if (gdb_can_reverse()) {
1687 + if (gdbserver_state.accel_config.can_reverse) {
1688 g_string_append(gdbserver_state.str_buf,
1689 ";ReverseStep+;ReverseContinue+");
1690 }
gdbstub/internals.h
-1
@@ -154,7 +154,6 @@ CPUState *gdb_first_attached_cpu(void);
154 void gdb_append_thread_id(CPUState *cpu, GString *buf);
155 int gdb_get_cpu_index(CPUState *cpu);
156 unsigned int gdb_get_max_cpus(void); /* both */
157 -bool gdb_can_reverse(void); /* system emulation, stub for user */
157 int gdb_target_sigtrap(void); /* user */
158
159 void gdb_create_default_process(GDBState *s);
gdbstub/system.c
-5
@@ -479,11 +479,6 @@ unsigned int gdb_get_max_cpus(void)
479 return ms->smp.max_cpus;
480 }
481
482 -bool gdb_can_reverse(void)
483 -{
484 - return replay_mode == REPLAY_MODE_PLAY;
485 -}
486 -
482 /*
483 * Softmmu specific command helpers
484 */
gdbstub/user.c
-6
@@ -786,12 +786,6 @@ unsigned int gdb_get_max_cpus(void)
786 return max_cpus;
787 }
788
789 -/* replay not supported for user-mode */
790 -bool gdb_can_reverse(void)
791 -{
792 - return false;
793 -}
794 -
789 /*
790 * Break/Watch point helpers
791 */
include/qemu/accel.h
+2
@@ -77,9 +77,11 @@ void accel_cpu_common_unrealize(CPUState *cpu);
77 * struct AccelGdbConfig - gdbstub configuration for an accelerator.
78 *
79 * @sstep_flags: Set SSTEP_* flags that accelerator supports for guest debug.
80 + * @can_reverse: Whether reverse mode is supported.
81 */
82 typedef struct AccelGdbConfig {
83 unsigned sstep_flags;
84 + bool can_reverse;
85 } AccelGdbConfig;
86
87 #endif /* QEMU_ACCEL_H */