Skip to contentSkip to conversation

[5799] Use sys-queue.h for break/watchpoint managment (Jan Kiszka)

Qemu-devel Anthony Liguori 1 participant 1 message Nov 25, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 5799

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5799
Author:   aliguori
Date:     2008-11-25 22:13:57 +0000 (Tue, 25 Nov 2008)

Log Message:
-----------
Use sys-queue.h for break/watchpoint managment (Jan Kiszka)

This switches cpu_break/watchpoint_* to TAILQ wrappers, simplifying the code and also fixing a use after release issue in cpu_break/watchpoint_remove_all.

Modified Paths:
--------------

    trunk/cpu-defs.h
    trunk/cpu-exec.c
    trunk/exec.c
    trunk/target-alpha/translate.c
    trunk/target-arm/translate.c
    trunk/target-cris/translate.c
    trunk/target-i386/helper.c
    trunk/target-i386/translate.c
    trunk/target-m68k/translate.c
    trunk/target-mips/translate.c
    trunk/target-ppc/translate.c
    trunk/target-sh4/translate.c
    trunk/target-sparc/translate.c

Modified: trunk/cpu-defs.h
===================================================================

cpu-defs.h +5 -4
@@ -28,6 +28,7 @@
 #include <setjmp.h>
 #include <inttypes.h>
 #include "osdep.h"
+#include "sys-queue.h"
 
 #ifndef TARGET_LONG_BITS
 #error TARGET_LONG_BITS must be defined before including this header
@@ -146,14 +147,14 @@
 typedef struct CPUBreakpoint {
     target_ulong pc;
     int flags; /* BP_* */
-    struct CPUBreakpoint *prev, *next;
+    TAILQ_ENTRY(CPUBreakpoint) entry;
 } CPUBreakpoint;
 
 typedef struct CPUWatchpoint {
     target_ulong vaddr;
     target_ulong len_mask;
     int flags; /* BP_* */
-    struct CPUWatchpoint *prev, *next;
+    TAILQ_ENTRY(CPUWatchpoint) entry;
 } CPUWatchpoint;
 
 #define CPU_TEMP_BUF_NLONGS 128
@@ -188,10 +189,10 @@
                                                                         \
     /* from this point: preserved by CPU reset */                       \
     /* ice debug support */                                             \
-    CPUBreakpoint *breakpoints;                                         \
+    TAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints;            \
     int singlestep_enabled;                                             \
                                                                         \
-    CPUWatchpoint *watchpoints;                                         \
+    TAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints;            \
     CPUWatchpoint *watchpoint_hit;                                      \
                                                                         \
     struct GDBRegisterState *gdb_regs;                                  \

Modified: trunk/cpu-exec.c
===================================================================

cpu-exec.c +1 -1
@@ -198,7 +198,7 @@
     CPUWatchpoint *wp;
 
     if (!env->watchpoint_hit)
-        for (wp = env->watchpoints; wp != NULL; wp = wp->next)
+        TAILQ_FOREACH(wp, &env->watchpoints, entry)
             wp->flags &= ~BP_WATCHPOINT_HIT;
 
     if (debug_excp_handler)

Modified: trunk/exec.c
===================================================================

exec.c +24 -60

170 lines not on this page · raw message

Modified: trunk/target-alpha/translate.c
===================================================================

target-alpha/translate.c +2 -2
@@ -2363,8 +2363,8 @@
 
     gen_icount_start();
     for (ret = 0; ret == 0;) {
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == ctx.pc) {
                     gen_excp(&ctx, EXCP_DEBUG, 0);
                     break;

Modified: trunk/target-arm/translate.c
===================================================================

target-arm/translate.c +2 -2
@@ -8677,8 +8677,8 @@
         }
 #endif
 
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == dc->pc) {
                     gen_set_condexec(dc);
                     gen_set_pc_im(dc->pc);

Modified: trunk/target-cris/translate.c
===================================================================

target-cris/translate.c +2 -2
@@ -3189,8 +3189,8 @@
 {
 	CPUBreakpoint *bp;
 
-	if (unlikely(env->breakpoints)) {
-		for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+	if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+		TAILQ_FOREACH(bp, &env->breakpoints, entry) {
 			if (bp->pc == dc->pc) {
 				cris_evaluate_flags (dc);
 				tcg_gen_movi_tl(env_pc, dc->pc);

Modified: trunk/target-i386/helper.c
===================================================================

target-i386/helper.c +1 -1
@@ -1364,7 +1364,7 @@
                 cpu_resume_from_signal(env, NULL);
         }
     } else {
-        for (bp = env->breakpoints; bp != NULL; bp = bp->next)
+        TAILQ_FOREACH(bp, &env->breakpoints, entry)
             if (bp->pc == env->eip) {
                 if (bp->flags & BP_CPU) {
                     check_hw_breakpoints(env, 1);

Modified: trunk/target-i386/translate.c
===================================================================

target-i386/translate.c +2 -2
@@ -7606,8 +7606,8 @@
 
     gen_icount_start();
     for(;;) {
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == pc_ptr) {
                     gen_debug(dc, pc_ptr - dc->cs_base);
                     break;

Modified: trunk/target-m68k/translate.c
===================================================================

target-m68k/translate.c +2 -2
@@ -2999,8 +2999,8 @@
     do {
         pc_offset = dc->pc - pc_start;
         gen_throws_exception = NULL;
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == dc->pc) {
                     gen_exception(dc, dc->pc, EXCP_DEBUG);
                     dc->is_jmp = DISAS_JUMP;

Modified: trunk/target-mips/translate.c
===================================================================

target-mips/translate.c +2 -2
@@ -8286,8 +8286,8 @@
 #endif
     gen_icount_start();
     while (ctx.bstate == BS_NONE) {
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == ctx.pc) {
                     save_cpu_state(&ctx, 1);
                     ctx.bstate = BS_BRANCH;

Modified: trunk/target-ppc/translate.c
===================================================================

target-ppc/translate.c +2 -2
@@ -7562,8 +7562,8 @@
     gen_icount_start();
     /* Set env in case of segfault during code fetch */
     while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) {
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == ctx.nip) {
                     gen_update_nip(&ctx, ctx.nip);
                     gen_helper_raise_debug();

Modified: trunk/target-sh4/translate.c
===================================================================

target-sh4/translate.c +2 -2
@@ -1776,8 +1776,8 @@
         max_insns = CF_COUNT_MASK;
     gen_icount_start();
     while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) {
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (ctx.pc == bp->pc) {
 		    /* We have hit a breakpoint - make sure PC is up-to-date */
 		    tcg_gen_movi_i32(cpu_pc, ctx.pc);

Modified: trunk/target-sparc/translate.c
===================================================================

target-sparc/translate.c +2 -2
@@ -4816,8 +4816,8 @@
         max_insns = CF_COUNT_MASK;
     gen_icount_start();
     do {
-        if (unlikely(env->breakpoints)) {
-            for (bp = env->breakpoints; bp != NULL; bp = bp->next) {
+        if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) {
+            TAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == dc->pc) {
                     if (dc->pc != pc_start)
                         save_state(dc, cpu_cond);