Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L2Xd9-0000CE-Uf for qemu-devel@nongnu.org; Tue, 18 Nov 2008 15:57:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L2Xd8-00008V-Iv for qemu-devel@nongnu.org; Tue, 18 Nov 2008 15:57:02 -0500 Received: from [199.232.76.173] (port=35448 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2Xd7-00008G-J2 for qemu-devel@nongnu.org; Tue, 18 Nov 2008 15:57:01 -0500 Received: from savannah.gnu.org ([199.232.41.3]:55275 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L2Xd7-0002El-FR for qemu-devel@nongnu.org; Tue, 18 Nov 2008 15:57:01 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L2Xd6-0001e0-Jn for qemu-devel@nongnu.org; Tue, 18 Nov 2008 20:57:00 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L2Xd6-0001dw-9S for qemu-devel@nongnu.org; Tue, 18 Nov 2008 20:57:00 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Tue, 18 Nov 2008 20:57:00 +0000 Subject: [Qemu-devel] [5746] Introduce BP_CPU as a breakpoint type (Jan Kiszka) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5746 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5746 Author: aliguori Date: 2008-11-18 20:56:59 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Introduce BP_CPU as a breakpoint type (Jan Kiszka) Add another breakpoint/watchpoint type to BP_GDB: BP_CPU. This type is intended for hardware-assisted break/watchpoint emulations like the x86 architecture requires. To keep the highest priority for BP_GDB breakpoints, this type is always inserted at the head of break/watchpoint lists, thus is found first when looking up the origin of a debug interruption. Signed-off-by: Jan Kiszka Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/cpu-all.h trunk/exec.c Modified: trunk/cpu-all.h =================================================================== --- trunk/cpu-all.h 2008-11-18 20:50:36 UTC (rev 5745) +++ trunk/cpu-all.h 2008-11-18 20:56:59 UTC (rev 5746) @@ -768,6 +768,7 @@ #define BP_STOP_BEFORE_ACCESS 0x04 #define BP_WATCHPOINT_HIT 0x08 #define BP_GDB 0x10 +#define BP_CPU 0x20 int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags, CPUBreakpoint **breakpoint); Modified: trunk/exec.c =================================================================== --- trunk/exec.c 2008-11-18 20:50:36 UTC (rev 5745) +++ trunk/exec.c 2008-11-18 20:56:59 UTC (rev 5746) @@ -1302,7 +1302,7 @@ int flags, CPUWatchpoint **watchpoint) { target_ulong len_mask = ~(len - 1); - CPUWatchpoint *wp; + CPUWatchpoint *wp, *prev_wp; /* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */ if ((len != 1 && len != 2 && len != 4 && len != 8) || (addr & ~len_mask)) { @@ -1318,11 +1318,26 @@ wp->len_mask = len_mask; wp->flags = flags; - wp->next = env->watchpoints; - wp->prev = NULL; + /* keep all GDB-injected watchpoints in front */ + if (!(flags & BP_GDB) && env->watchpoints) { + prev_wp = env->watchpoints; + while (prev_wp->next != NULL && (prev_wp->next->flags & BP_GDB)) + prev_wp = prev_wp->next; + } else { + prev_wp = NULL; + } + + /* Insert new watchpoint */ + if (prev_wp) { + wp->next = prev_wp->next; + prev_wp->next = wp; + } else { + wp->next = env->watchpoints; + env->watchpoints = wp; + } if (wp->next) wp->next->prev = wp; - env->watchpoints = wp; + wp->prev = prev_wp; tlb_flush_page(env, addr); @@ -1378,7 +1393,7 @@ CPUBreakpoint **breakpoint) { #if defined(TARGET_HAS_ICE) - CPUBreakpoint *bp; + CPUBreakpoint *bp, *prev_bp; bp = qemu_malloc(sizeof(*bp)); if (!bp) @@ -1387,11 +1402,26 @@ bp->pc = pc; bp->flags = flags; - bp->next = env->breakpoints; - bp->prev = NULL; + /* keep all GDB-injected breakpoints in front */ + if (!(flags & BP_GDB) && env->breakpoints) { + prev_bp = env->breakpoints; + while (prev_bp->next != NULL && (prev_bp->next->flags & BP_GDB)) + prev_bp = prev_bp->next; + } else { + prev_bp = NULL; + } + + /* Insert new breakpoint */ + if (prev_bp) { + bp->next = prev_bp->next; + prev_bp->next = bp; + } else { + bp->next = env->breakpoints; + env->breakpoints = bp; + } if (bp->next) bp->next->prev = bp; - env->breakpoints = bp; + bp->prev = prev_bp; breakpoint_invalidate(env, pc);