]> Git Repo - qemu.git/commitdiff
GDB exit status for semihosting
authorPaul Brook <[email protected]>
Wed, 16 Jun 2010 12:03:51 +0000 (13:03 +0100)
committerPaul Brook <[email protected]>
Wed, 16 Jun 2010 12:03:51 +0000 (13:03 +0100)
Report exit status to GDB when a semihosted application exits.

Signed-off-by: Paul Brook <[email protected]>
arm-semi.c
gdbstub.c
gdbstub.h
m68k-semi.c

index 5239ffc8c46a79b73a02dd27d9b6c9a97c596a24..0687b03006ac198bdd5b6871cedb19d3ab41248a 100644 (file)
@@ -459,6 +459,7 @@ uint32_t do_arm_semihosting(CPUState *env)
             return 0;
         }
     case SYS_EXIT:
+        gdb_exit(env, 0);
         exit(0);
     default:
         fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr);
index 474ed8aeaefdc5c1db322723c31d7c2f14d4d703..c1852c243fbcec4f473372a226bfb9308b5f6e08 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2373,6 +2373,26 @@ static void gdb_read_byte(GDBState *s, int ch)
     }
 }
 
+/* Tell the remote gdb that the process has exited.  */
+void gdb_exit(CPUState *env, int code)
+{
+  GDBState *s;
+  char buf[4];
+
+  s = gdbserver_state;
+  if (!s) {
+      return;
+  }
+#ifdef CONFIG_USER_ONLY
+  if (gdbserver_fd < 0 || s->fd < 0) {
+      return;
+  }
+#endif
+
+  snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code);
+  put_packet(s, buf);
+}
+
 #ifdef CONFIG_USER_ONLY
 int
 gdb_queuesig (void)
@@ -2436,20 +2456,6 @@ gdb_handlesig (CPUState *env, int sig)
   return sig;
 }
 
-/* Tell the remote gdb that the process has exited.  */
-void gdb_exit(CPUState *env, int code)
-{
-  GDBState *s;
-  char buf[4];
-
-  s = gdbserver_state;
-  if (gdbserver_fd < 0 || s->fd < 0)
-    return;
-
-  snprintf(buf, sizeof(buf), "W%02x", code);
-  put_packet(s, buf);
-}
-
 /* Tell the remote gdb that the process has exited due to SIG.  */
 void gdb_signalled(CPUState *env, int sig)
 {
index 54d753cfd41484d5799aa4e239d75e843daffd7d..219abdab0e16315f7d34b9ab6ba19825719fc208 100644 (file)
--- a/gdbstub.h
+++ b/gdbstub.h
@@ -17,10 +17,10 @@ typedef void (*gdb_syscall_complete_cb)(CPUState *env,
 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *env);
+void gdb_exit(CPUState *, int);
 #ifdef CONFIG_USER_ONLY
 int gdb_queuesig (void);
 int gdb_handlesig (CPUState *, int);
-void gdb_exit(CPUState *, int);
 void gdb_signalled(CPUState *, int);
 void gdbserver_fork(CPUState *);
 #endif
index 48e3bd38be6a290c737e6c55f4376b9283b4f857..d16bc671c6c7f39f92a31a79f47cbf26523a4c04 100644 (file)
@@ -172,6 +172,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
     args = env->dregs[1];
     switch (nr) {
     case HOSTED_EXIT:
+        gdb_exit(env, env->dregs[0]);
         exit(env->dregs[0]);
     case HOSTED_OPEN:
         if (use_gdb_syscalls()) {
This page took 0.033716 seconds and 4 git commands to generate.