accel: Have each implementation return their AccelGdbConfig
Hold the per-accelerator AccelGdbConfig in AccelState, set its single @sstep_flags field in AccelClass::init_machine handlers. Remove the AccelClass::gdbstub_supported_sstep_flags() getter and inline the single accel_supported_gdbstub_sstep_flags() call in gdb_init_gdbserver_state(). Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260705215729.62196-15-philmd@oss.qualcomm.com>
Philippe Mathieu-Daudé committed
Jun 26, 2026 at 12:10 UTC
8c60f7f38ed97c11a49649bf746dc572ebcbea00
11 files changed
+20
-71
accel/accel-common.c
-10
@@ -113,16 +113,6 @@ void accel_cpu_common_unrealize(CPUState *cpu)
113
}
114
}
115
116
-int accel_supported_gdbstub_sstep_flags(void)
117
-{
118
- AccelState *accel = current_accel();
119
- AccelClass *acc = ACCEL_GET_CLASS(accel);
120
- if (acc->gdbstub_supported_sstep_flags) {
121
- return acc->gdbstub_supported_sstep_flags(accel);
122
- }
123
- return 0;
124
-}
125
-
116
static const TypeInfo accel_types[] = {
117
{
118
.name = TYPE_ACCEL,
accel/hvf/hvf-all.c
+2
-6
@@ -220,6 +220,8 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
220
}
221
assert_hvf_ok(ret);
222
223
+ as->gdbstub.sstep_flags = SSTEP_ENABLE | SSTEP_NOIRQ;
224
+
225
QTAILQ_INIT(&s->hvf_sw_breakpoints);
226
227
hvf_state = s;
@@ -228,11 +230,6 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
230
return hvf_arch_init();
231
}
232
231
-static int hvf_gdbstub_sstep_flags(AccelState *as)
232
-{
233
- return SSTEP_ENABLE | SSTEP_NOIRQ;
234
-}
235
-
233
static void hvf_set_kernel_irqchip(Object *obj, Visitor *v,
234
const char *name, void *opaque,
235
Error **errp)
@@ -278,7 +275,6 @@ static void hvf_accel_class_init(ObjectClass *oc, const void *data)
275
ac->name = "HVF";
276
ac->init_machine = hvf_accel_init;
277
ac->allowed = &hvf_allowed;
281
- ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
278
hvf_kernel_irqchip_override = false;
279
hvf_kernel_irqchip = false;
280
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
accel/kvm/kvm-all.c
+2
-15
@@ -104,7 +104,6 @@ bool kvm_readonly_mem_allowed;
104
bool kvm_vm_attributes_allowed;
105
bool kvm_msi_use_devid;
106
bool kvm_pre_fault_memory_supported;
107
-static int kvm_sstep_flags;
107
static bool kvm_immediate_exit;
108
static uint64_t kvm_supported_memory_attributes;
109
static bool kvm_guest_memfd_supported;
@@ -3041,13 +3040,13 @@ static int kvm_init(AccelState *as, MachineState *ms)
3040
(kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0);
3041
3042
if (s->have_guest_debug) {
3044
- kvm_sstep_flags = SSTEP_ENABLE;
3043
+ as->gdbstub.sstep_flags = SSTEP_ENABLE;
3044
3045
int guest_debug_flags =
3046
kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG2);
3047
3048
if (guest_debug_flags & KVM_GUESTDBG_BLOCKIRQ) {
3050
- kvm_sstep_flags |= SSTEP_NOIRQ;
3049
+ as->gdbstub.sstep_flags |= SSTEP_NOIRQ;
3050
}
3051
}
3052
#endif
@@ -4279,17 +4278,6 @@ static void kvm_accel_instance_init(Object *obj)
4278
s->honor_guest_pat = ON_OFF_AUTO_OFF;
4279
}
4280
4282
-/**
4283
- * kvm_gdbstub_sstep_flags():
4284
- *
4285
- * Returns: SSTEP_* flags that KVM supports for guest debug. The
4286
- * support is probed during kvm_init()
4287
- */
4288
-static int kvm_gdbstub_sstep_flags(AccelState *as)
4289
-{
4290
- return kvm_sstep_flags;
4291
-}
4292
-
4281
static void kvm_accel_class_init(ObjectClass *oc, const void *data)
4282
{
4283
AccelClass *ac = ACCEL_CLASS(oc);
@@ -4298,7 +4286,6 @@ static void kvm_accel_class_init(ObjectClass *oc, const void *data)
4286
ac->rebuild_guest = kvm_reset_vmfd;
4287
ac->has_memory = kvm_accel_has_memory;
4288
ac->allowed = &kvm_allowed;
4301
- ac->gdbstub_supported_sstep_flags = kvm_gdbstub_sstep_flags;
4289
4290
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
4291
NULL, kvm_set_kernel_irqchip,
accel/tcg/tcg-all.c
+11
-16
@@ -149,6 +149,17 @@ static int tcg_init_machine(AccelState *as, MachineState *ms)
149
150
tcg_allowed = true;
151
152
+ as->gdbstub.sstep_flags = SSTEP_ENABLE;
153
+ if (replay_mode == REPLAY_MODE_NONE) {
154
+ /*
155
+ * In replay mode all events will come from the log and can't be
156
+ * suppressed otherwise we would break determinism. However as those
157
+ * events are tied to the number of executed instructions we won't see
158
+ * them occurring every time we single step.
159
+ */
160
+ as->gdbstub.sstep_flags |= SSTEP_NOIRQ | SSTEP_NOTIMER;
161
+ }
162
+
163
page_init();
164
tb_htable_init();
165
tcg_init(s->tb_size * MiB, s->splitwx_enabled, max_threads);
@@ -242,21 +253,6 @@ static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
253
qatomic_set(&one_insn_per_tb, value);
254
}
255
245
-static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
246
-{
247
- /*
248
- * In replay mode all events will come from the log and can't be
249
- * suppressed otherwise we would break determinism. However as those
250
- * events are tied to the number of executed instructions we won't see
251
- * them occurring every time we single step.
252
- */
253
- if (replay_mode != REPLAY_MODE_NONE) {
254
- return SSTEP_ENABLE;
255
- } else {
256
- return SSTEP_ENABLE | SSTEP_NOIRQ | SSTEP_NOTIMER;
257
- }
258
-}
259
-
256
static void tcg_accel_class_init(ObjectClass *oc, const void *data)
257
{
258
AccelClass *ac = ACCEL_CLASS(oc);
@@ -266,7 +262,6 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
262
ac->cpu_common_unrealize = tcg_exec_unrealizefn;
263
ac->get_stats = tcg_get_stats;
264
ac->allowed = &tcg_allowed;
269
- ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
265
266
object_class_property_add_str(oc, "thread",
267
tcg_get_thread,
accel/whpx/whpx-common.c
-1
@@ -527,7 +527,6 @@ static void whpx_accel_class_init(ObjectClass *oc, const void *data)
527
ac->init_machine = whpx_accel_init;
528
ac->pre_resume_vm = whpx_pre_resume_vm;
529
ac->allowed = &whpx_allowed;
530
- ac->gdbstub_supported_sstep_flags = whpx_arch_gdbstub_sstep_flags;
530
531
object_class_property_add(oc, "kernel-irqchip", "on|off|split",
532
NULL, whpx_set_kernel_irqchip,
gdbstub/gdbstub.c
+1
-1
@@ -72,7 +72,7 @@ void gdb_init_gdbserver_state(void)
72
* By default try to use no IRQs and no timers while single
73
* stepping so as to make single stepping like a typical ICE HW step.
74
*/
75
- gdbserver_state.accel_config.sstep_flags = accel_supported_gdbstub_sstep_flags();
75
+ gdbserver_state.accel_config = current_accel()->gdbstub;
76
gdbserver_state.sstep_flags = SSTEP_ENABLE | SSTEP_NOIRQ | SSTEP_NOTIMER;
77
gdbserver_state.sstep_flags &= gdbserver_state.accel_config.sstep_flags;
78
}
include/accel/accel-ops.h
+2
-3
@@ -13,6 +13,8 @@
13
14
struct AccelState {
15
Object parent_obj;
16
+
17
+ AccelGdbConfig gdbstub;
18
};
19
20
struct AccelClass {
@@ -36,9 +38,6 @@ struct AccelClass {
38
bool (*has_memory)(AccelState *accel, AddressSpace *as,
39
hwaddr start_addr, hwaddr size);
40
39
- /* gdbstub related hooks */
40
- int (*gdbstub_supported_sstep_flags)(AccelState *as);
41
-
41
bool *allowed;
42
/*
43
* Array of global properties that would be applied when specific
include/qemu/accel.h
-8
@@ -82,12 +82,4 @@ typedef struct AccelGdbConfig {
82
unsigned sstep_flags;
83
} AccelGdbConfig;
84
85
-/**
86
- * accel_supported_gdbstub_sstep_flags:
87
- *
88
- * Returns the supported single step modes for the configured
89
- * accelerator.
90
- */
91
-int accel_supported_gdbstub_sstep_flags(void);
92
-
85
#endif /* QEMU_ACCEL_H */
include/system/whpx-all.h
-1
@@ -23,7 +23,6 @@ void whpx_arch_destroy_vcpu(CPUState *cpu);
23
void whpx_arch_accel_class_init(ObjectClass *oc);
24
25
/* called by whpx-accel-ops */
26
-int whpx_arch_gdbstub_sstep_flags(AccelState *as);
26
bool whpx_arch_supports_guest_debug(void);
27
28
#endif
target/arm/whpx/whpx-all.c
-5
@@ -295,11 +295,6 @@ void whpx_translate_cpu_breakpoints(
295
/* Breakpoints aren’t supported on this platform */
296
}
297
298
-int whpx_arch_gdbstub_sstep_flags(AccelState *as)
299
-{
300
- return 0;
301
-}
302
-
298
bool whpx_arch_supports_guest_debug(void)
299
{
300
return false;
target/i386/whpx/whpx-all.c
+2
-5
@@ -1853,11 +1853,6 @@ void whpx_apply_breakpoints(
1853
}
1854
}
1855
1856
-int whpx_arch_gdbstub_sstep_flags(AccelState *as)
1857
-{
1858
- return SSTEP_ENABLE;
1859
-}
1860
-
1856
bool whpx_arch_supports_guest_debug(void)
1857
{
1858
return true;
@@ -3348,6 +3343,8 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
3343
whpx_memory_init();
3344
whpx_init_emu();
3345
3346
+ as->gdbstub.sstep_flags = SSTEP_ENABLE;
3347
+
3348
return 0;
3349
3350
error: