]> git.proxmox.com Git - qemu.git/commitdiff
first part of single stepping support
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 29 Jul 2003 20:50:33 +0000 (20:50 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 29 Jul 2003 20:50:33 +0000 (20:50 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@342 c046a42c-6fe2-441c-8c8c-71466251a162

cpu-all.h
exec.c
gdbstub.c

index 787a054a485d7c7cdb8c4ee41ec6ef3c2d73d89d..cde8451dd03bd30f1f83d6407e7342c0f604a612 100644 (file)
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -315,6 +315,7 @@ void cpu_interrupt(CPUState *s, int mask);
 
 int cpu_breakpoint_insert(CPUState *env, uint32_t pc);
 int cpu_breakpoint_remove(CPUState *env, uint32_t pc);
+void cpu_single_step(CPUState *env, int enabled);
 
 /* gdb stub API */
 extern int gdbstub_fd;
diff --git a/exec.c b/exec.c
index fc0a0cf7af91fe78b0cdf61b7d66b36183138596..5ea2163258ef097248fabec99ddc0b06c5bd5bf3 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -617,7 +617,8 @@ static void tb_reset_jump_recursive(TranslationBlock *tb)
     tb_reset_jump_recursive2(tb, 1);
 }
 
-/* add a breakpoint */
+/* add a breakpoint. EXCP_DEBUG is returned by the CPU loop if a
+   breakpoint is reached */
 int cpu_breakpoint_insert(CPUState *env, uint32_t pc)
 {
 #if defined(TARGET_I386)
@@ -659,6 +660,20 @@ int cpu_breakpoint_remove(CPUState *env, uint32_t pc)
 #endif
 }
 
+/* enable or disable single step mode. EXCP_DEBUG is returned by the
+   CPU loop after each instruction */
+void cpu_single_step(CPUState *env, int enabled)
+{
+#if defined(TARGET_I386)
+    if (env->singlestep_enabled != enabled) {
+        env->singlestep_enabled = enabled;
+        /* must flush all the translated code to avoid inconsistancies */
+        tb_flush();
+    }
+#endif
+}
+
+
 /* mask must never be zero */
 void cpu_interrupt(CPUState *env, int mask)
 {
index d255eab6d548d4e67e2a6a712c916e21fe1c9eaf..61cb6b1ab5f0acca7a3ff7e22dcf091805e76ada 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -324,6 +324,24 @@ int cpu_gdbstub(void *opaque, int (*main_loop)(void *opaque), int port)
             snprintf(buf, sizeof(buf), "S%02x", ret);
             put_packet(buf);
             break;
+        case 's':
+            env = cpu_gdbstub_get_env(opaque);
+            if (*p != '\0') {
+                addr = strtoul(p, (char **)&p, 16);
+#if defined(TARGET_I386)
+                env->eip = addr;
+#endif
+            }
+            cpu_single_step(env, 1);
+            ret = main_loop(opaque);
+            cpu_single_step(env, 0);
+            if (ret == EXCP_DEBUG)
+                ret = SIGTRAP;
+            else
+                ret = 0;
+            snprintf(buf, sizeof(buf), "S%02x", ret);
+            put_packet(buf);
+            break;
         case 'g':
             env = cpu_gdbstub_get_env(opaque);
             registers = (void *)mem_buf;