Re: [Qemu-devel] [PATCH 28/37] Move debug exception handling out of cpu_exec

2011-03-07 Thread Jan Kiszka
On 2011-03-07 02:52, TeLeMan wrote:
 This patch breaks the support for x86 hardware breakpoints because
 cpu_resume_from_signal() and raise_exception_env() are used in
 breakpoint_handler().

Yeah, unfortunately true. The TCG bits of this refactoring have to be
moved back. Will fix.

Thanks,
Jan



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 28/37] Move debug exception handling out of cpu_exec

2011-03-07 Thread Jan Kiszka
On 2011-03-07 09:26, Jan Kiszka wrote:
 On 2011-03-07 02:52, TeLeMan wrote:
 This patch breaks the support for x86 hardware breakpoints because
 cpu_resume_from_signal() and raise_exception_env() are used in
 breakpoint_handler().
 
 Yeah, unfortunately true. The TCG bits of this refactoring have to be
 moved back. Will fix.

This seems to do the trick, but I haven't tested all scenarios yet.

Jan

---

diff --git a/cpu-exec.c b/cpu-exec.c
index b03b3a7..0333617 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -196,6 +196,30 @@ static inline TranslationBlock *tb_find_fast(void)
 return tb;
 }
 
+static CPUDebugExcpHandler *debug_excp_handler;
+
+CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler)
+{
+CPUDebugExcpHandler *old_handler = debug_excp_handler;
+
+debug_excp_handler = handler;
+return old_handler;
+}
+
+static void cpu_handle_debug_exception(CPUState *env)
+{
+CPUWatchpoint *wp;
+
+if (!env-watchpoint_hit) {
+QTAILQ_FOREACH(wp, env-watchpoints, entry) {
+wp-flags = ~BP_WATCHPOINT_HIT;
+}
+}
+if (debug_excp_handler) {
+debug_excp_handler(env);
+}
+}
+
 /* main execution loop */
 
 volatile sig_atomic_t exit_request;
@@ -263,6 +287,9 @@ int cpu_exec(CPUState *env1)
 if (env-exception_index = EXCP_INTERRUPT) {
 /* exit request from the cpu execution loop */
 ret = env-exception_index;
+if (ret == EXCP_DEBUG) {
+cpu_handle_debug_exception(env);
+}
 break;
 } else {
 #if defined(CONFIG_USER_ONLY)
diff --git a/cpus.c b/cpus.c
index 0f1ae50..d41a0ce 100644
--- a/cpus.c
+++ b/cpus.c
@@ -166,29 +166,8 @@ static bool all_cpu_threads_idle(void)
 return true;
 }
 
-static CPUDebugExcpHandler *debug_excp_handler;
-
-CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler)
-{
-CPUDebugExcpHandler *old_handler = debug_excp_handler;
-
-debug_excp_handler = handler;
-return old_handler;
-}
-
-static void cpu_handle_debug_exception(CPUState *env)
+static void cpu_handle_guest_debug(CPUState *env)
 {
-CPUWatchpoint *wp;
-
-if (!env-watchpoint_hit) {
-QTAILQ_FOREACH(wp, env-watchpoints, entry) {
-wp-flags = ~BP_WATCHPOINT_HIT;
-}
-}
-if (debug_excp_handler) {
-debug_excp_handler(env);
-}
-
 gdb_set_stop_cpu(env);
 qemu_system_debug_request();
 #ifdef CONFIG_IOTHREAD
@@ -836,7 +815,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
 if (cpu_can_run(env)) {
 r = kvm_cpu_exec(env);
 if (r == EXCP_DEBUG) {
-cpu_handle_debug_exception(env);
+cpu_handle_guest_debug(env);
 }
 }
 qemu_kvm_wait_io_event(env);
@@ -1106,7 +1085,7 @@ bool cpu_exec_all(void)
 r = tcg_cpu_exec(env);
 }
 if (r == EXCP_DEBUG) {
-cpu_handle_debug_exception(env);
+cpu_handle_guest_debug(env);
 break;
 }
 } else if (env-stop || env-stopped) {
-- 
1.7.1



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 28/37] Move debug exception handling out of cpu_exec

2011-03-07 Thread TeLeMan
On Mon, Mar 7, 2011 at 16:54, Jan Kiszka jan.kis...@web.de wrote:
 On 2011-03-07 09:26, Jan Kiszka wrote:
 On 2011-03-07 02:52, TeLeMan wrote:
 This patch breaks the support for x86 hardware breakpoints because
 cpu_resume_from_signal() and raise_exception_env() are used in
 breakpoint_handler().

 Yeah, unfortunately true. The TCG bits of this refactoring have to be
 moved back. Will fix.

 This seems to do the trick, but I haven't tested all scenarios yet.
Tested, x86 hardware breakpoints become working.
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Qemu-devel] [PATCH 28/37] Move debug exception handling out of cpu_exec

2011-03-06 Thread TeLeMan
This patch breaks the support for x86 hardware breakpoints because
cpu_resume_from_signal() and raise_exception_env() are used in
breakpoint_handler().
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html