Report usermode gdb exit codes
PATCH 1/1 Report usermode gdb exit codes
The attached patch makes qemu report the exit code to the attached gdb when the guest process exits.
Paul
Index: gdbstub.c
===================================================================
RCS file: /cvsroot/qemu/qemu/gdbstub.c,v
retrieving revision 1.25
gdbstub.c +16 -0
@@ -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
gdbstub.h +1 -0
@@ -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
syscall.c +2 -0
@@ -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