mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 03:29:43 +00:00
gdbstub: move guest debug support check to ops
This removes the final hard coding of kvm_enabled() in gdbstub and moves the check to an AccelOps. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Mads Ynddal <mads@ynddal.dk> Message-Id: <20220929114231.583801-46-alex.bennee@linaro.org>
This commit is contained in:
parent
ae7467b1ac
commit
a48e7d9e52
@ -99,6 +99,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
|
||||
ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
|
||||
|
||||
#ifdef KVM_CAP_SET_GUEST_DEBUG
|
||||
ops->supports_guest_debug = kvm_supports_guest_debug;
|
||||
ops->insert_breakpoint = kvm_insert_breakpoint;
|
||||
ops->remove_breakpoint = kvm_remove_breakpoint;
|
||||
ops->remove_all_breakpoints = kvm_remove_all_breakpoints;
|
||||
|
@ -3287,6 +3287,12 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
|
||||
return data.err;
|
||||
}
|
||||
|
||||
bool kvm_supports_guest_debug(void)
|
||||
{
|
||||
/* probed during kvm_init() */
|
||||
return kvm_has_guest_debug;
|
||||
}
|
||||
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
struct kvm_sw_breakpoint *bp;
|
||||
|
@ -18,6 +18,7 @@ void kvm_destroy_vcpu(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_post_reset(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_post_init(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu);
|
||||
bool kvm_supports_guest_debug(void);
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
void kvm_remove_all_breakpoints(CPUState *cpu);
|
||||
|
@ -93,6 +93,11 @@ 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)
|
||||
{
|
||||
@ -198,6 +203,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -45,7 +45,6 @@
|
||||
|
||||
#include "qemu/sockets.h"
|
||||
#include "sysemu/hw_accel.h"
|
||||
#include "sysemu/kvm.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "semihosting/semihost.h"
|
||||
#include "exec/exec-all.h"
|
||||
@ -3447,8 +3446,8 @@ int gdbserver_start(const char *device)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (kvm_enabled() && !kvm_supports_guest_debug()) {
|
||||
error_report("gdbstub: KVM doesn't support guest debugging");
|
||||
if (!gdb_supports_guest_debug()) {
|
||||
error_report("gdbstub: current accelerator doesn't support guest debugging");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#ifndef _INTERNALS_H_
|
||||
#define _INTERNALS_H_
|
||||
|
||||
bool gdb_supports_guest_debug(void);
|
||||
int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len);
|
||||
int gdb_breakpoint_remove(CPUState *cs, int type, hwaddr addr, hwaddr len);
|
||||
void gdb_breakpoint_remove_all(CPUState *cs);
|
||||
|
@ -15,6 +15,15 @@
|
||||
#include "sysemu/cpus.h"
|
||||
#include "internals.h"
|
||||
|
||||
bool gdb_supports_guest_debug(void)
|
||||
{
|
||||
const AccelOpsClass *ops = cpus_get_accel();
|
||||
if (ops->supports_guest_debug) {
|
||||
return ops->supports_guest_debug();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
const AccelOpsClass *ops = cpus_get_accel();
|
||||
|
@ -14,6 +14,12 @@
|
||||
#include "hw/core/cpu.h"
|
||||
#include "internals.h"
|
||||
|
||||
bool gdb_supports_guest_debug(void)
|
||||
{
|
||||
/* user-mode == TCG == supported */
|
||||
return true;
|
||||
}
|
||||
|
||||
int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
CPUState *cpu;
|
||||
|
@ -47,6 +47,7 @@ struct AccelOpsClass {
|
||||
int64_t (*get_elapsed_ticks)(void);
|
||||
|
||||
/* gdbstub hooks */
|
||||
bool (*supports_guest_debug)(void);
|
||||
int (*insert_breakpoint)(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
int (*remove_breakpoint)(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
void (*remove_all_breakpoints)(CPUState *cpu);
|
||||
|
@ -46,7 +46,6 @@ extern bool kvm_readonly_mem_allowed;
|
||||
extern bool kvm_direct_msi_allowed;
|
||||
extern bool kvm_ioeventfd_any_length_allowed;
|
||||
extern bool kvm_msi_use_devid;
|
||||
extern bool kvm_has_guest_debug;
|
||||
|
||||
#define kvm_enabled() (kvm_allowed)
|
||||
/**
|
||||
@ -168,11 +167,6 @@ extern bool kvm_has_guest_debug;
|
||||
*/
|
||||
#define kvm_msi_devid_required() (kvm_msi_use_devid)
|
||||
|
||||
/*
|
||||
* Does KVM support guest debugging
|
||||
*/
|
||||
#define kvm_supports_guest_debug() (kvm_has_guest_debug)
|
||||
|
||||
#else
|
||||
|
||||
#define kvm_enabled() (0)
|
||||
@ -190,7 +184,6 @@ extern bool kvm_has_guest_debug;
|
||||
#define kvm_direct_msi_enabled() (false)
|
||||
#define kvm_ioeventfd_any_length_enabled() (false)
|
||||
#define kvm_msi_devid_required() (false)
|
||||
#define kvm_supports_guest_debug() (false)
|
||||
|
||||
#endif /* CONFIG_KVM_IS_POSSIBLE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user