qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, "Michael Walle" <michael@walle.cc>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH qom-cpu v2 30/40] exec: Change cpu_breakpoint_{insert, remove{, _by_ref, _all}} argument
Date: Mon, 10 Mar 2014 01:15:39 +0100	[thread overview]
Message-ID: <1394410549-13751-31-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de>

Use CPUState. Allows to clean up CPUArchState in gdbstub.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 exec.c                 | 20 ++++++++------------
 gdbstub.c              | 20 ++++++++------------
 include/exec/cpu-all.h | 15 ---------------
 include/qom/cpu.h      | 15 +++++++++++++++
 linux-user/main.c      |  2 +-
 target-i386/cpu.c      |  2 +-
 target-i386/helper.c   |  4 ++--
 target-i386/machine.c  |  2 +-
 target-lm32/helper.c   |  9 +++++++--
 9 files changed, 43 insertions(+), 46 deletions(-)

diff --git a/exec.c b/exec.c
index 7af94e9..adc576a 100644
--- a/exec.c
+++ b/exec.c
@@ -617,11 +617,10 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask)
 #endif
 
 /* Add a breakpoint.  */
-int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags,
+int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
                           CPUBreakpoint **breakpoint)
 {
 #if defined(TARGET_HAS_ICE)
-    CPUState *cpu = ENV_GET_CPU(env);
     CPUBreakpoint *bp;
 
     bp = g_malloc(sizeof(*bp));
@@ -648,15 +647,14 @@ int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags,
 }
 
 /* Remove a specific breakpoint.  */
-int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags)
+int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags)
 {
 #if defined(TARGET_HAS_ICE)
-    CPUState *cpu = ENV_GET_CPU(env);
     CPUBreakpoint *bp;
 
     QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
         if (bp->pc == pc && bp->flags == flags) {
-            cpu_breakpoint_remove_by_ref(env, bp);
+            cpu_breakpoint_remove_by_ref(cpu, bp);
             return 0;
         }
     }
@@ -667,11 +665,9 @@ int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags)
 }
 
 /* Remove a specific breakpoint by reference.  */
-void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint)
+void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint)
 {
 #if defined(TARGET_HAS_ICE)
-    CPUState *cpu = ENV_GET_CPU(env);
-
     QTAILQ_REMOVE(&cpu->breakpoints, breakpoint, entry);
 
     breakpoint_invalidate(cpu, breakpoint->pc);
@@ -681,15 +677,15 @@ void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint)
 }
 
 /* Remove all matching breakpoints. */
-void cpu_breakpoint_remove_all(CPUArchState *env, int mask)
+void cpu_breakpoint_remove_all(CPUState *cpu, int mask)
 {
 #if defined(TARGET_HAS_ICE)
-    CPUState *cpu = ENV_GET_CPU(env);
     CPUBreakpoint *bp, *next;
 
     QTAILQ_FOREACH_SAFE(bp, &cpu->breakpoints, entry, next) {
-        if (bp->flags & mask)
-            cpu_breakpoint_remove_by_ref(env, bp);
+        if (bp->flags & mask) {
+            cpu_breakpoint_remove_by_ref(cpu, bp);
+        }
     }
 #endif
 }
diff --git a/gdbstub.c b/gdbstub.c
index cd10781..8afe0b7 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -635,7 +635,6 @@ static const int xlat_gdb_type[] = {
 static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)
 {
     CPUState *cpu;
-    CPUArchState *env;
     int err = 0;
 
     if (kvm_enabled()) {
@@ -646,10 +645,10 @@ static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)
     case GDB_BREAKPOINT_SW:
     case GDB_BREAKPOINT_HW:
         CPU_FOREACH(cpu) {
-            env = cpu->env_ptr;
-            err = cpu_breakpoint_insert(env, addr, BP_GDB, NULL);
-            if (err)
+            err = cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL);
+            if (err) {
                 break;
+            }
         }
         return err;
 #ifndef CONFIG_USER_ONLY
@@ -672,7 +671,6 @@ static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, int type)
 static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)
 {
     CPUState *cpu;
-    CPUArchState *env;
     int err = 0;
 
     if (kvm_enabled()) {
@@ -683,10 +681,10 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)
     case GDB_BREAKPOINT_SW:
     case GDB_BREAKPOINT_HW:
         CPU_FOREACH(cpu) {
-            env = cpu->env_ptr;
-            err = cpu_breakpoint_remove(env, addr, BP_GDB);
-            if (err)
+            err = cpu_breakpoint_remove(cpu, addr, BP_GDB);
+            if (err) {
                 break;
+            }
         }
         return err;
 #ifndef CONFIG_USER_ONLY
@@ -708,7 +706,6 @@ static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, int type)
 static void gdb_breakpoint_remove_all(void)
 {
     CPUState *cpu;
-    CPUArchState *env;
 
     if (kvm_enabled()) {
         kvm_remove_all_breakpoints(gdbserver_state->c_cpu);
@@ -716,8 +713,7 @@ static void gdb_breakpoint_remove_all(void)
     }
 
     CPU_FOREACH(cpu) {
-        env = cpu->env_ptr;
-        cpu_breakpoint_remove_all(env, BP_GDB);
+        cpu_breakpoint_remove_all(cpu, BP_GDB);
 #ifndef CONFIG_USER_ONLY
         cpu_watchpoint_remove_all(cpu, BP_GDB);
 #endif
@@ -1599,7 +1595,7 @@ void gdbserver_fork(CPUArchState *env)
     }
     close(s->fd);
     s->fd = -1;
-    cpu_breakpoint_remove_all(env, BP_GDB);
+    cpu_breakpoint_remove_all(cpu, BP_GDB);
     cpu_watchpoint_remove_all(cpu, BP_GDB);
 }
 #else
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index ea90aee..6bcadb4 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -413,21 +413,6 @@ void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...)
      | CPU_INTERRUPT_TGT_EXT_3   \
      | CPU_INTERRUPT_TGT_EXT_4)
 
-/* Breakpoint/watchpoint flags */
-#define BP_MEM_READ           0x01
-#define BP_MEM_WRITE          0x02
-#define BP_MEM_ACCESS         (BP_MEM_READ | BP_MEM_WRITE)
-#define BP_STOP_BEFORE_ACCESS 0x04
-#define BP_WATCHPOINT_HIT     0x08
-#define BP_GDB                0x10
-#define BP_CPU                0x20
-
-int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags,
-                          CPUBreakpoint **breakpoint);
-int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags);
-void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint);
-void cpu_breakpoint_remove_all(CPUArchState *env, int mask);
-
 #if !defined(CONFIG_USER_ONLY)
 
 /* memory API */
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 4127438..86698dd 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -595,6 +595,21 @@ void qemu_init_vcpu(CPUState *cpu);
  */
 void cpu_single_step(CPUState *cpu, int enabled);
 
+/* Breakpoint/watchpoint flags */
+#define BP_MEM_READ           0x01
+#define BP_MEM_WRITE          0x02
+#define BP_MEM_ACCESS         (BP_MEM_READ | BP_MEM_WRITE)
+#define BP_STOP_BEFORE_ACCESS 0x04
+#define BP_WATCHPOINT_HIT     0x08
+#define BP_GDB                0x10
+#define BP_CPU                0x20
+
+int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
+                          CPUBreakpoint **breakpoint);
+int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags);
+void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint);
+void cpu_breakpoint_remove_all(CPUState *cpu, int mask);
+
 int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
                           int flags, CPUWatchpoint **watchpoint);
 int cpu_watchpoint_remove(CPUState *cpu, vaddr addr,
diff --git a/linux-user/main.c b/linux-user/main.c
index 725d1ad..d20981d 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3451,7 +3451,7 @@ CPUArchState *cpu_copy(CPUArchState *env)
     QTAILQ_INIT(&cpu->watchpoints);
 #if defined(TARGET_HAS_ICE)
     QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
-        cpu_breakpoint_insert(new_env, bp->pc, bp->flags, NULL);
+        cpu_breakpoint_insert(new_cpu, bp->pc, bp->flags, NULL);
     }
     QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {
         cpu_watchpoint_insert(new_cpu, wp->vaddr, (~wp->len_mask) + 1,
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6320b7a..9f9e8b1 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2469,7 +2469,7 @@ static void x86_cpu_reset(CPUState *s)
     memset(env->dr, 0, sizeof(env->dr));
     env->dr[6] = DR6_FIXED_1;
     env->dr[7] = DR7_FIXED_1;
-    cpu_breakpoint_remove_all(env, BP_CPU);
+    cpu_breakpoint_remove_all(s, BP_CPU);
     cpu_watchpoint_remove_all(s, BP_CPU);
 
     env->tsc_adjust = 0;
diff --git a/target-i386/helper.c b/target-i386/helper.c
index dd6d824..ad61062 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -999,7 +999,7 @@ void hw_breakpoint_insert(CPUX86State *env, int index)
     switch (hw_breakpoint_type(env->dr[7], index)) {
     case DR7_TYPE_BP_INST:
         if (hw_breakpoint_enabled(env->dr[7], index)) {
-            err = cpu_breakpoint_insert(env, env->dr[index], BP_CPU,
+            err = cpu_breakpoint_insert(cs, env->dr[index], BP_CPU,
                                         &env->cpu_breakpoint[index]);
         }
         break;
@@ -1036,7 +1036,7 @@ void hw_breakpoint_remove(CPUX86State *env, int index)
     switch (hw_breakpoint_type(env->dr[7], index)) {
     case DR7_TYPE_BP_INST:
         if (hw_breakpoint_enabled(env->dr[7], index)) {
-            cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[index]);
+            cpu_breakpoint_remove_by_ref(cs, env->cpu_breakpoint[index]);
         }
         break;
     case DR7_TYPE_DATA_WR:
diff --git a/target-i386/machine.c b/target-i386/machine.c
index d49398c..ed159a8 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -320,7 +320,7 @@ static int cpu_post_load(void *opaque, int version_id)
         env->fptags[i] = (env->fptag_vmstate >> i) & 1;
     }
 
-    cpu_breakpoint_remove_all(env, BP_CPU);
+    cpu_breakpoint_remove_all(cs, BP_CPU);
     cpu_watchpoint_remove_all(cs, BP_CPU);
     for (i = 0; i < DR7_MAX_BP; i++) {
         hw_breakpoint_insert(env, i);
diff --git a/target-lm32/helper.c b/target-lm32/helper.c
index 8633375..8be5bed 100644
--- a/target-lm32/helper.c
+++ b/target-lm32/helper.c
@@ -53,16 +53,21 @@ hwaddr lm32_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
 
 void lm32_breakpoint_insert(CPULM32State *env, int idx, target_ulong address)
 {
-    cpu_breakpoint_insert(env, address, BP_CPU, &env->cpu_breakpoint[idx]);
+    LM32CPU *cpu = lm32_env_get_cpu(env);
+
+    cpu_breakpoint_insert(CPU(cpu), address, BP_CPU,
+                          &env->cpu_breakpoint[idx]);
 }
 
 void lm32_breakpoint_remove(CPULM32State *env, int idx)
 {
+    LM32CPU *cpu = lm32_env_get_cpu(env);
+
     if (!env->cpu_breakpoint[idx]) {
         return;
     }
 
-    cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[idx]);
+    cpu_breakpoint_remove_by_ref(CPU(cpu), env->cpu_breakpoint[idx]);
     env->cpu_breakpoint[idx] = NULL;
 }
 
-- 
1.8.4.5

  parent reply	other threads:[~2014-03-10  0:16 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10  0:15 [Qemu-devel] [PATCH qom-cpu v2 00/40] QOM CPUState, part 13: Emptying CPU_COMMON Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 01/40] target-alpha: Clean up ENV_GET_CPU() usage Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 02/40] target-arm: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 03/40] target-i386: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 04/40] target-ppc: " Andreas Färber
2014-03-12 22:56   ` Stuart Brady
2014-03-12 23:53     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 05/40] target-s390x: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 06/40] target-sparc: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 07/40] target-unicore32: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 08/40] target-xtensa: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 09/40] cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook Andreas Färber
2014-03-10  7:52   ` Paolo Bonzini
2014-03-11 23:47     ` Andreas Färber
2014-03-12 17:58       ` Paolo Bonzini
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 10/40] cpu: Move mem_io_{pc, vaddr} fields from CPU_COMMON to CPUState Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 11/40] cpu: Move can_do_io field " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 12/40] cpu: Move icount_extra " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 13/40] cpu: Move icount_decr " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 14/40] cpu: Move tb_jmp_cache " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 15/40] cpu: Move jmp_env " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 16/40] cpu: Move exception_index " Andreas Färber
2014-03-11 22:29   ` Andreas Färber
2014-03-13  0:56     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 17/40] cpu: Move opaque " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 18/40] cpu: Move watchpoint fields " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 19/40] cpu: Move breakpoints field " Andreas Färber
2014-03-12 23:08   ` Stuart Brady
2014-03-12 23:59     ` Andreas Färber
2014-03-13  0:40       ` Stuart Brady
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 20/40] exec: Change tlb_fill() argument " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 21/40] cpu-exec: Change cpu_loop_exit() " Andreas Färber
2014-03-11 22:35   ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 22/40] translate-all: Change cpu_restore_state() " Andreas Färber
2014-03-11 15:02   ` Max Filippov
2014-03-11 23:23     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 23/40] translate-all: Change cpu_restore_state_from_tb() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 24/40] translate-all: Change tb_check_watchpoint() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 25/40] translate-all: Change cpu_io_recompile() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 26/40] translate-all: Change tb_gen_code() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 27/40] translate-all: Change tb_flush_jmp_cache() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 28/40] target-ppc: Use PowerPCCPU in PowerPCCPUClass::handle_mmu_fault hook Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 29/40] exec: Change cpu_watchpoint_{insert, remove{, _by_ref, _all}} argument Andreas Färber
2014-03-10  0:15 ` Andreas Färber [this message]
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 31/40] cpu-exec: Change cpu_resume_from_signal() argument to CPUState Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 32/40] cputlb: Change tlb_unprotect_code_phys() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 33/40] exec: Change memory_region_section_get_iotlb() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 34/40] exec: Change cpu_abort() " Andreas Färber
2014-03-12 23:28   ` Andreas Färber
2014-03-13  0:59     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 35/40] target-cris: Replace DisasContext::env field with CRISCPU Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 36/40] target-microblaze: Replace DisasContext::env field with MicroBlazeCPU Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 37/40] cputlb: Change tlb_flush_page() argument to CPUState Andreas Färber
2014-03-11 15:05   ` Max Filippov
2014-03-13  0:33     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 38/40] cputlb: Change tlb_flush() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 39/40] cputlb: Change tlb_set_page() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 40/40] user-exec: Change exception_action() " Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394410549-13751-31-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=michael@walle.cc \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).