User-mode GDB stub improvements - handle fork
[qemu] / gdbstub.c
index 452b7d0..2e112b2 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -990,6 +990,56 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
 
     return 4;
 }
+#elif defined (TARGET_ALPHA)
+
+#define NUM_CORE_REGS 65
+
+static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
+{
+    if (n < 31) {
+       GET_REGL(env->ir[n]);
+    }
+    else if (n == 31) {
+       GET_REGL(0);
+    }
+    else if (n<63) {
+       uint64_t val;
+
+       val=*((uint64_t *)&env->fir[n-32]);
+       GET_REGL(val);
+    }
+    else if (n==63) {
+       GET_REGL(env->fpcr);
+    }
+    else if (n==64) {
+       GET_REGL(env->pc);
+    }
+    else {
+       GET_REGL(0);
+    }
+
+    return 0;
+}
+
+static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
+{
+    target_ulong tmp;
+    tmp = ldtul_p(mem_buf);
+
+    if (n < 31) {
+        env->ir[n] = tmp;
+    }
+
+    if (n > 31 && n < 63) {
+        env->fir[n - 32] = ldfl_p(mem_buf);
+    }
+
+    if (n == 64 ) {
+       env->pc=tmp;
+    }
+
+    return 8;
+}
 #else
 
 #define NUM_CORE_REGS 0
@@ -1030,7 +1080,7 @@ static int memtox(char *buf, const char *mem, int len)
     return p - buf;
 }
 
-const char *get_feature_xml(const char *p, const char **newp)
+static const char *get_feature_xml(const char *p, const char **newp)
 {
     extern const char *const xml_builtin[][2];
     size_t len;
@@ -1277,6 +1327,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
             s->c_cpu->active_tc.PC = addr;
 #elif defined (TARGET_CRIS)
             s->c_cpu->pc = addr;
+#elif defined (TARGET_ALPHA)
+            s->c_cpu->pc = addr;
 #endif
         }
         gdb_continue(s);
@@ -1313,6 +1365,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
             s->c_cpu->active_tc.PC = addr;
 #elif defined (TARGET_CRIS)
             s->c_cpu->pc = addr;
+#elif defined (TARGET_ALPHA)
+            s->c_cpu->pc = addr;
 #endif
         }
         cpu_single_step(s->c_cpu, sstep_flags);
@@ -1602,8 +1656,6 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
     return RS_IDLE;
 }
 
-extern void tb_flush(CPUState *env);
-
 void gdb_set_stop_cpu(CPUState *env)
 {
     gdbserver_state->c_cpu = env;
@@ -1944,6 +1996,18 @@ int gdbserver_start(int port)
     gdb_accept();
     return 0;
 }
+
+/* Disable gdb stub for child processes.  */
+void gdbserver_fork(CPUState *env)
+{
+    GDBState *s = gdbserver_state;
+    if (s->fd < 0)
+      return;
+    close(s->fd);
+    s->fd = -1;
+    cpu_breakpoint_remove_all(env, BP_GDB);
+    cpu_watchpoint_remove_all(env, BP_GDB);
+}
 #else
 static int gdb_chr_can_receive(void *opaque)
 {