[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [RFC 4/7] break/watchpoints: store inside array
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-arm] [RFC 4/7] break/watchpoints: store inside array |
Date: |
Fri, 17 Jun 2016 19:15:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
On 17/06/2016 18:33, Alex Bennée wrote:
> @@ -807,18 +807,17 @@ int cpu_watchpoint_insert_with_ref(CPUState *cpu, vaddr
> addr, vaddr len,
> wp->flags = flags;
> wp->ref = ref;
> } else {
> - wp = g_malloc(sizeof(*wp));
> -
> - wp->vaddr = addr;
> - wp->len = len;
> - wp->flags = flags;
> - wp->ref = ref;
> + CPUWatchpoint watch;
> + watch.vaddr = addr;
> + watch.len = len;
> + watch.flags = flags;
> + watch.ref = ref;
>
> /* keep all GDB-injected watchpoints in front */
> if (flags & BP_GDB) {
> - g_array_prepend_val(cpu->watchpoints, wp);
> + g_array_prepend_val(cpu->watchpoints, watch);
> } else {
> - g_array_append_val(cpu->watchpoints, wp);
> + g_array_append_val(cpu->watchpoints, watch);
> }
Please define "watch" outside the "if", so that the "then" side can do just
*wp = watch;
and there is less duplication.
Paolo