@@ -50,6 +50,7 @@ typedef struct AccelClass {
hwaddr start_addr, hwaddr size);
/* gdbstub related hooks */
+ bool (*supports_guest_debug)(AccelState *as);
int (*gdbstub_supported_sstep_flags)(AccelState *as);
bool *allowed;
@@ -65,7 +65,6 @@ struct AccelOpsClass {
int64_t (*get_elapsed_ticks)(void);
/* gdbstub hooks */
- bool (*supports_guest_debug)(void);
int (*update_guest_debug)(CPUState *cpu);
int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
@@ -71,7 +71,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu);
/*
* Return whether the guest supports debugging.
*/
-bool hvf_arch_supports_guest_debug(void);
+bool hvf_arch_supports_guest_debug(AccelState *as);
bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
@@ -364,6 +364,7 @@ static void hvf_accel_class_init(ObjectClass *oc, const void *data)
ac->name = "HVF";
ac->init_machine = hvf_accel_init;
ac->allowed = &hvf_allowed;
+ ac->supports_guest_debug = hvf_arch_supports_guest_debug;
ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
}
@@ -600,7 +601,6 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
ops->remove_breakpoint = hvf_remove_breakpoint;
ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
ops->update_guest_debug = hvf_update_guest_debug;
- ops->supports_guest_debug = hvf_arch_supports_guest_debug;
};
static const TypeInfo hvf_accel_ops_type = {
.name = ACCEL_OPS_NAME("hvf"),
@@ -106,11 +106,6 @@ void tcg_handle_interrupt(CPUState *cpu, int mask)
}
}
-static bool tcg_supports_guest_debug(void)
-{
- return true;
-}
-
/* Translate GDB watchpoint type to a flags value for cpu_watchpoint_* */
static inline int xlat_gdb_type(CPUState *cpu, int gdbtype)
{
@@ -218,7 +213,6 @@ static void tcg_accel_ops_init(AccelClass *ac)
}
ops->cpu_reset_hold = tcg_cpu_reset_hold;
- ops->supports_guest_debug = tcg_supports_guest_debug;
ops->insert_breakpoint = tcg_insert_breakpoint;
ops->remove_breakpoint = tcg_remove_breakpoint;
ops->remove_all_breakpoints = tcg_remove_all_breakpoints;
@@ -219,6 +219,11 @@ static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
qatomic_set(&one_insn_per_tb, value);
}
+static bool tcg_supports_guest_debug(AccelState *as)
+{
+ return true;
+}
+
static int tcg_gdbstub_supported_sstep_flags(AccelState *as)
{
/*
@@ -242,6 +247,7 @@ static void tcg_accel_class_init(ObjectClass *oc, const void *data)
ac->cpu_common_realize = tcg_exec_realizefn;
ac->cpu_common_unrealize = tcg_exec_unrealizefn;
ac->allowed = &tcg_allowed;
+ ac->supports_guest_debug = tcg_supports_guest_debug;
ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
object_class_property_add_str(oc, "thread",
@@ -634,9 +634,10 @@ int gdb_signal_to_target(int sig)
bool gdb_supports_guest_debug(void)
{
- const AccelOpsClass *ops = cpus_get_accel();
- if (ops->supports_guest_debug) {
- return ops->supports_guest_debug();
+ AccelState *accel = current_accel();
+ AccelClass *acc = ACCEL_GET_CLASS(accel);
+ if (acc->supports_guest_debug) {
+ return acc->supports_guest_debug(accel);
}
return false;
}
@@ -2409,7 +2409,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu)
hvf_arch_set_traps(cpu);
}
-bool hvf_arch_supports_guest_debug(void)
+bool hvf_arch_supports_guest_debug(AccelState *as)
{
return true;
}
@@ -1024,7 +1024,7 @@ void hvf_arch_update_guest_debug(CPUState *cpu)
{
}
-bool hvf_arch_supports_guest_debug(void)
+bool hvf_arch_supports_guest_debug(AccelState *as)
{
return false;
}
AccelOpsClass is for methods dealing with vCPUs. When only dealing with AccelState, AccelClass is sufficient. In order to have AccelClass methods instrospect their state, we need to pass AccelState by argument. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- include/qemu/accel.h | 1 + include/system/accel-ops.h | 1 - include/system/hvf.h | 2 +- accel/hvf/hvf-accel-ops.c | 2 +- accel/tcg/tcg-accel-ops.c | 6 ------ accel/tcg/tcg-all.c | 6 ++++++ gdbstub/system.c | 7 ++++--- target/arm/hvf/hvf.c | 2 +- target/i386/hvf/hvf.c | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-)