[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/15] Introduce BP_CPU as a breakpoint type
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH 14/15] Introduce BP_CPU as a breakpoint type |
Date: |
Mon, 23 Jun 2008 16:33:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
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 <address@hidden>
---
cpu-all.h | 1 +
exec.c | 46 ++++++++++++++++++++++++++++++++++++++--------
2 files changed, 39 insertions(+), 8 deletions(-)
Index: b/cpu-all.h
===================================================================
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -804,6 +804,7 @@ void cpu_reset_interrupt(CPUState *env,
#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);
Index: b/exec.c
===================================================================
--- a/exec.c
+++ b/exec.c
@@ -1146,7 +1146,7 @@ int cpu_watchpoint_insert(CPUState *env,
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) || (addr & ~len_mask))
@@ -1160,11 +1160,26 @@ int cpu_watchpoint_insert(CPUState *env,
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);
@@ -1220,7 +1235,7 @@ int cpu_breakpoint_insert(CPUState *env,
CPUBreakpoint **breakpoint)
{
#if defined(TARGET_HAS_ICE)
- CPUBreakpoint *bp;
+ CPUBreakpoint *bp, *prev_bp;
bp = qemu_malloc(sizeof(*bp));
if (!bp)
@@ -1229,11 +1244,26 @@ int cpu_breakpoint_insert(CPUState *env,
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);
- [Qemu-devel] [PATCH 0/15] Enhance debugging support, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 8/15] Respect length of watchpoints, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 2/15] Introduce SSTEP_INTERNAL, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 12/15] Introduce BP_WATCHPOINT_HIT flag, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 5/15] Return appropriate watch message to gdb, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 6/15] Refactor and enhance break/watchpoint API - v5, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 14/15] Introduce BP_CPU as a breakpoint type,
Jan Kiszka <=
- [Qemu-devel] [PATCH 1/15] Convert remaining __builtin_expect to likely/unlikely, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 7/15] Extend mem_write_* to mem_access_*, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 13/15] Add debug exception hook, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 3/15] Replace CF_SINGLE_INSN with SSTEP_INTERNAL - v2, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 15/15] x86: Debug register emulation, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 10/15] Remove premature memop TB terminations, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 9/15] Restore pc on watchpoint hits, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 11/15] Improve debugging of SMP guests - v2, Jan Kiszka, 2008/06/23
- [Qemu-devel] [PATCH 4/15] Remove unused TB cflags, Jan Kiszka, 2008/06/23