From e90096763d74b1126cf502c2d710d64df5ecbb63 Mon Sep 17 00:00:00 2001 From: bellard Date: Tue, 26 Apr 2005 20:42:36 +0000 Subject: report user mode gdb exit codes (Paul Brook) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1401 c046a42c-6fe2-441c-8c8c-71466251a162 --- gdbstub.c | 16 ++++++++++++++++ gdbstub.h | 1 + linux-user/syscall.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index eb30627080..527d2e926e 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -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) { diff --git a/gdbstub.h b/gdbstub.h index 63b88dadc5..7b42596f15 100644 --- a/gdbstub.h +++ b/gdbstub.h @@ -5,6 +5,7 @@ #ifdef CONFIG_USER_ONLY int gdb_handlesig (CPUState *, int); +void gdb_exit(CPUState *, int); #endif int gdbserver_start(int); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b00ce90cbf..0a4f07e31d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1603,6 +1603,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, #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, long arg1, long arg2, long arg3, #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 -- cgit v1.2.3