qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v3 05/19] exec: add assert_debug_safe and notes on


From: Sergey Fedorov
Subject: Re: [Qemu-devel] [RFC v3 05/19] exec: add assert_debug_safe and notes on debug structures
Date: Fri, 24 Jun 2016 18:28:52 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

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
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]