Received: from eggs.gnu.org ([2001:4830:134:3::10]:49878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH92E-0004YE-66 for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VH924-0007yS-Fh for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45464 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VH923-0007xS-TC for qemu-devel@nongnu.org; Wed, 04 Sep 2013 05:05:48 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 4 Sep 2013 11:05:08 +0200 Message-Id: <1378285521-3230-29-git-send-email-afaerber@suse.de> In-Reply-To: <1378285521-3230-1-git-send-email-afaerber@suse.de> References: <1378285521-3230-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC qom-cpu 28/41] exec: Change cpu_breakpoint_{insert, remove{, _by_ref, _all}} argument List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio , =?UTF-8?q?Andreas=20F=C3=A4rber?= Use CPUState. Allows to clean up CPUArchState in gdbstub. Signed-off-by: Andreas F=C3=A4rber --- 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 +- 8 files changed, 36 insertions(+), 44 deletions(-) diff --git a/exec.c b/exec.c index cfd0ecb..7ea864a 100644 --- a/exec.c +++ b/exec.c @@ -507,11 +507,10 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int m= ask) #endif =20 /* 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 =3D ENV_GET_CPU(env); CPUBreakpoint *bp; =20 bp =3D g_malloc(sizeof(*bp)); @@ -538,15 +537,14 @@ int cpu_breakpoint_insert(CPUArchState *env, target= _ulong pc, int flags, } =20 /* 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 =3D ENV_GET_CPU(env); CPUBreakpoint *bp; =20 QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) { if (bp->pc =3D=3D pc && bp->flags =3D=3D flags) { - cpu_breakpoint_remove_by_ref(env, bp); + cpu_breakpoint_remove_by_ref(cpu, bp); return 0; } } @@ -557,11 +555,9 @@ int cpu_breakpoint_remove(CPUArchState *env, target_= ulong pc, int flags) } =20 /* Remove a specific breakpoint by reference. */ -void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *brea= kpoint) +void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoi= nt) { #if defined(TARGET_HAS_ICE) - CPUState *cpu =3D ENV_GET_CPU(env); - QTAILQ_REMOVE(&cpu->breakpoints, breakpoint, entry); =20 breakpoint_invalidate(cpu, breakpoint->pc); @@ -571,15 +567,15 @@ void cpu_breakpoint_remove_by_ref(CPUArchState *env= , CPUBreakpoint *breakpoint) } =20 /* 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 =3D ENV_GET_CPU(env); CPUBreakpoint *bp, *next; =20 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 1e0dea4..8bdefe2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -638,7 +638,6 @@ static const int xlat_gdb_type[] =3D { static int gdb_breakpoint_insert(target_ulong addr, target_ulong len, in= t type) { CPUState *cpu; - CPUArchState *env; int err =3D 0; =20 if (kvm_enabled()) { @@ -649,10 +648,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 =3D cpu->env_ptr; - err =3D cpu_breakpoint_insert(env, addr, BP_GDB, NULL); - if (err) + err =3D cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL); + if (err) { break; + } } return err; #ifndef CONFIG_USER_ONLY @@ -675,7 +674,6 @@ static int gdb_breakpoint_insert(target_ulong addr, t= arget_ulong len, int type) static int gdb_breakpoint_remove(target_ulong addr, target_ulong len, in= t type) { CPUState *cpu; - CPUArchState *env; int err =3D 0; =20 if (kvm_enabled()) { @@ -686,10 +684,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 =3D cpu->env_ptr; - err =3D cpu_breakpoint_remove(env, addr, BP_GDB); - if (err) + err =3D cpu_breakpoint_remove(cpu, addr, BP_GDB); + if (err) { break; + } } return err; #ifndef CONFIG_USER_ONLY @@ -711,7 +709,6 @@ static int gdb_breakpoint_remove(target_ulong addr, t= arget_ulong len, int type) static void gdb_breakpoint_remove_all(void) { CPUState *cpu; - CPUArchState *env; =20 if (kvm_enabled()) { kvm_remove_all_breakpoints(gdbserver_state->c_cpu); @@ -719,8 +716,7 @@ static void gdb_breakpoint_remove_all(void) } =20 CPU_FOREACH(cpu) { - env =3D 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 @@ -1604,7 +1600,7 @@ void gdbserver_fork(CPUArchState *env) } close(s->fd); s->fd =3D -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 c3ff709..a26d653 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -412,21 +412,6 @@ void QEMU_NORETURN cpu_abort(CPUArchState *env, cons= t char *fmt, ...) | CPU_INTERRUPT_TGT_EXT_3 \ | CPU_INTERRUPT_TGT_EXT_4) =20 -/* 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 *brea= kpoint); -void cpu_breakpoint_remove_all(CPUArchState *env, int mask); - #if !defined(CONFIG_USER_ONLY) =20 /* memory API */ diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9ef30d3..85ba419 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -600,6 +600,21 @@ void qemu_init_vcpu(CPUState *cpu); */ void cpu_single_step(CPUState *cpu, int enabled); =20 +/* 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 *breakpoi= nt); +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 6feaa50..cadefbe 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3211,7 +3211,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 b80f75b..944c3d7 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2390,7 +2390,7 @@ static void x86_cpu_reset(CPUState *s) memset(env->dr, 0, sizeof(env->dr)); env->dr[6] =3D DR6_FIXED_1; env->dr[7] =3D DR7_FIXED_1; - cpu_breakpoint_remove_all(env, BP_CPU); + cpu_breakpoint_remove_all(s, BP_CPU); cpu_watchpoint_remove_all(s, BP_CPU); =20 #if !defined(CONFIG_USER_ONLY) diff --git a/target-i386/helper.c b/target-i386/helper.c index 69cc374..1cd7688 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -994,7 +994,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 =3D cpu_breakpoint_insert(env, env->dr[index], BP_CPU, + err =3D cpu_breakpoint_insert(cs, env->dr[index], BP_CPU, &env->cpu_breakpoint[index]); } break; @@ -1031,7 +1031,7 @@ void hw_breakpoint_remove(CPUX86State *env, int ind= ex) 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 7f05c3b..54dd2ab 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -305,7 +305,7 @@ static int cpu_post_load(void *opaque, int version_id= ) env->fptags[i] =3D (env->fptag_vmstate >> i) & 1; } =20 - cpu_breakpoint_remove_all(env, BP_CPU); + cpu_breakpoint_remove_all(cs, BP_CPU); cpu_watchpoint_remove_all(cs, BP_CPU); for (i =3D 0; i < DR7_MAX_BP; i++) { hw_breakpoint_insert(env, i); --=20 1.8.1.4