On 03/06/16 23:40, Alex Bennée wrote: > diff --git a/exec.c b/exec.c > index a3a93ae..b225282 100644 > --- a/exec.c > +++ b/exec.c > @@ -25,6 +25,7 @@ > #include "qemu/cutils.h" > #include "cpu.h" > #include "exec/exec-all.h" > +#include "qom/cpu.h" > #include "tcg.h" > #include "hw/qdev-core.h" > #if !defined(CONFIG_USER_ONLY) > @@ -62,7 +63,46 @@ > #include "qemu/mmap-alloc.h" > #endif > > -//#define DEBUG_SUBPAGE > +/* #define DEBUG_SUBPAGE */ > +/* #define DEBUG_DEBUG */ > + > +#ifdef DEBUG_DEBUG > +#define CHECK_DEBUG_SAFE 1 > +#else > +#define CHECK_DEBUG_SAFE 0 > +#endif > + > +/* > + * Safe access to debugging structures. > + * > + * Breakpoints and Watchpoints are kept in the vCPU structures. There > + * are two ways they are manipulated: > + * > + * - Outside of the context of the vCPU thread (e.g. gdbstub) > + * - Inside the context of the vCPU (architectural debug registers) > + * > + * In system emulation mode the chance of corruption is usually > + * mitigated by the fact the vCPUs is usually suspended whenever these > + * changes are made. > + * > + * In user emulation mode it is less clear (XXX: work this out) > + */ > + > +#ifdef CONFIG_SOFTMMU > +#define assert_debug_safe(cpu) do { \ > + if (CHECK_DEBUG_SAFE) { \ > + g_assert(!cpu->created || \ > + (cpu_is_stopped(cpu) || cpu == current_cpu)); \
There's no need in parentheses around "cpu_is_stopped(cpu) || cpu == current_cpu". > + } \ > + } while (0) > +#else > +#define assert_debug_safe(cpu) do { \ > + if (CHECK_DEBUG_SAFE) { \ > + g_assert(false); \ > + } \ Can be simply: #define assert_debug_safe(cpu) Kind regards, Sergey > + } while (0) > +#endif > + > > #if !defined(CONFIG_USER_ONLY) > /* ram_list is read under rcu_read_lock()/rcu_read_unlock(). Writes >