[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/13] Refactor and enhance break/watchpoint API
From: |
Glauber Costa |
Subject: |
Re: [Qemu-devel] [PATCH 02/13] Refactor and enhance break/watchpoint API |
Date: |
Tue, 14 Oct 2008 15:24:01 -0200 |
>
> Index: b/exec.c
> ===================================================================
> --- a/exec.c
> +++ b/exec.c
> @@ -537,7 +537,6 @@ void cpu_exec_init(CPUState *env)
> cpu_index++;
> }
> env->cpu_index = cpu_index;
> - env->nb_watchpoints = 0;
> *penv = env;
> #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
> register_savevm("cpu_common", cpu_index, CPU_COMMON_SAVE_VERSION,
> @@ -1311,107 +1310,150 @@ static void breakpoint_invalidate(CPUSta
> #endif
>
> /* Add a watchpoint. */
> -int cpu_watchpoint_insert(CPUState *env, target_ulong addr, int type)
> +int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,
> + int flags, CPUWatchpoint **watchpoint)
> {
> - int i;
> + CPUWatchpoint *wp;
>
> - for (i = 0; i < env->nb_watchpoints; i++) {
> - if (addr == env->watchpoint[i].vaddr)
> - return 0;
> - }
> - if (env->nb_watchpoints >= MAX_WATCHPOINTS)
> - return -1;
> + wp = qemu_malloc(sizeof(*wp));
> + if (!wp)
> + return -ENOBUFS;
> +
> + wp->vaddr = addr;
> + wp->len = len;
> + wp->flags = flags;
> +
> + wp->next = env->watchpoints;
> + wp->prev = NULL;
> + if (wp->next)
> + wp->next->prev = wp;
> + env->watchpoints = wp;
>
> - i = env->nb_watchpoints++;
> - env->watchpoint[i].vaddr = addr;
> - env->watchpoint[i].type = type;
> tlb_flush_page(env, addr);
> /* FIXME: This flush is needed because of the hack to make memory ops
> terminate the TB. It can be removed once the proper IO trap and
> re-execute bits are in. */
> tb_flush(env);
> Index: b/cpu-defs.h
> +typedef struct CPUBreakpoint {
> + target_ulong pc;
> + int flags; /* BP_* */
> + struct CPUBreakpoint *prev, *next;
> +} CPUBreakpoint;
> +
> +typedef struct CPUWatchpoint {
> + target_ulong vaddr;
> + target_ulong len;
> + int flags; /* BP_* */
> + struct CPUWatchpoint *prev, *next;
> +} CPUWatchpoint;
> +
Most of the time, you are transversing the list in a single direction.
So any particular reason to use a double linked list?
By the way, /me thinks it is about time for us to have a generic
linked list implementation
--
Glauber Costa.
"Free as in Freedom"
http://glommer.net
"The less confident you are, the more serious you have to act."
- [Qemu-devel] [PATCH 00/13] Enhance debugging support - 3rd take, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 01/13] Return appropriate watch message to gdb, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 05/13] Introduce next_cflags, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 06/13] Switch self-modified code recompilation to next_cflags, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 03/13] Set mem_io_vaddr on io_read, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 10/13] Introduce BP_WATCHPOINT_HIT flag, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 12/13] Introduce BP_CPU as a breakpoint type, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 02/13] Refactor and enhance break/watchpoint API, Jan Kiszka, 2008/10/14
- Re: [Qemu-devel] [PATCH 02/13] Refactor and enhance break/watchpoint API,
Glauber Costa <=
- Re: [Qemu-devel] [PATCH 02/13] Refactor and enhance break/watchpoint API, Glauber Costa, 2008/10/14
- [Qemu-devel] [PATCH 13/13] x86: Debug register emulation, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 08/13] Remove premature memop TB terminations, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 07/13] Restore pc on watchpoint hits, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 11/13] Add debug exception hook, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 09/13] qemu: gdbstub: manage CPUs as threads, Jan Kiszka, 2008/10/14
- [Qemu-devel] [PATCH 04/13] Respect length of watchpoints, Jan Kiszka, 2008/10/14