From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DPhZB-00043E-68 for qemu-devel@nongnu.org; Sun, 24 Apr 2005 09:54:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DPhZ9-00040n-N2 for qemu-devel@nongnu.org; Sun, 24 Apr 2005 09:54:32 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DPhZ9-0003jy-Im for qemu-devel@nongnu.org; Sun, 24 Apr 2005 09:54:31 -0400 Received: from [65.74.133.9] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DPham-0007vl-Ki for qemu-devel@nongnu.org; Sun, 24 Apr 2005 09:56:12 -0400 From: Paul Brook Date: Sun, 24 Apr 2005 14:52:46 +0100 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_uS6aCfYuex2CfJY" Message-Id: <200504241452.46443.paul@codesourcery.com> Subject: [Qemu-devel] [patch] Report usermode gdb exit codes Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Boundary-00=_uS6aCfYuex2CfJY Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline The attached patch makes qemu report the exit code to the attached gdb when the guest process exits. Paul --Boundary-00=_uS6aCfYuex2CfJY Content-Type: text/x-diff; charset="us-ascii"; name="patch.qemu_gdb_exit" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch.qemu_gdb_exit" Index: gdbstub.c =================================================================== RCS file: /cvsroot/qemu/qemu/gdbstub.c,v retrieving revision 1.25 diff -u -p -r1.25 gdbstub.c --- gdbstub.c 24 Apr 2005 10:07:11 -0000 1.25 +++ gdbstub.c 24 Apr 2005 13:42:02 -0000 @@ -656,6 +656,22 @@ 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]; + + if (gdbserver_fd < 0) + return; + + s = &gdbserver_state; + + snprintf(buf, sizeof(buf), "W%02x", code); + put_packet(s, buf); +} + #else static int gdb_can_read(void *opaque) { Index: gdbstub.h =================================================================== RCS file: /cvsroot/qemu/qemu/gdbstub.h,v retrieving revision 1.1 diff -u -p -r1.1 gdbstub.h --- gdbstub.h 17 Apr 2005 19:16:13 -0000 1.1 +++ gdbstub.h 24 Apr 2005 13:42:02 -0000 @@ -5,6 +5,7 @@ #ifdef CONFIG_USER_ONLY int gdb_handlesig (CPUState *, int); +void gdb_exit(CPUState *, int); #endif int gdbserver_start(int); Index: linux-user/syscall.c =================================================================== RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.59 diff -u -p -r1.59 syscall.c --- linux-user/syscall.c 23 Apr 2005 18:25:41 -0000 1.59 +++ linux-user/syscall.c 24 Apr 2005 13:42:02 -0000 @@ -1603,6 +1603,7 @@ long do_syscall(void *cpu_env, int num, #ifdef HAVE_GPROF _mcleanup(); #endif + gdb_exit(cpu_env, arg1); /* XXX: should free thread stack and CPU env */ _exit(arg1); ret = 0; /* avoid warning */ @@ -2409,6 +2410,7 @@ long do_syscall(void *cpu_env, int num, #ifdef __NR_exit_group /* new thread calls */ case TARGET_NR_exit_group: + gdb_exit(cpu_env, arg1); ret = get_errno(exit_group(arg1)); break; #endif --Boundary-00=_uS6aCfYuex2CfJY--