From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JUmTI-00064N-Gv for qemu-devel@nongnu.org; Thu, 28 Feb 2008 12:23:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JUmTG-00063G-Ir for qemu-devel@nongnu.org; Thu, 28 Feb 2008 12:23:03 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JUmTF-000630-VC for qemu-devel@nongnu.org; Thu, 28 Feb 2008 12:23:02 -0500 Received: from miranda.se.axis.com ([193.13.178.8]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JUmTF-0004ig-Fe for qemu-devel@nongnu.org; Thu, 28 Feb 2008 12:23:01 -0500 Received: from axis.com (edgar.se.axis.com [10.93.151.1]) by miranda.se.axis.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id m1SHMuUH016839 for ; Thu, 28 Feb 2008 18:22:56 +0100 Date: Thu, 28 Feb 2008 20:22:30 +0100 From: "Edgar E. Iglesias" Message-ID: <20080228192230.GJ7782@edgar.se.axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] gdbstub: Debug user-mode signals 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 Hello, This patch makes it possible to debug signal handlers when simulating programs in user-mode. Without it, the session aborts as soon as a signal is delivered. On CRIS I still cannot get GDB to unwind the stack beyond the signals return trampoline, but I'm pretty sure it's related to some error in the way I setup the trampoline in linux-user/signal.c. Tested on ARM and CRIS. Comments? Ok to check it in? Best regards -- Edgar E. Iglesias Axis Communications AB Index: gdbstub.c =================================================================== RCS file: /sources/qemu/qemu/gdbstub.c,v retrieving revision 1.75 diff -u -p -b -u -p -r1.75 gdbstub.c --- gdbstub.c 28 Feb 2008 08:28:31 -0000 1.75 +++ gdbstub.c 28 Feb 2008 17:15:33 -0000 @@ -65,6 +65,7 @@ typedef struct GDBState { int line_csum; uint8_t last_packet[4100]; int last_packet_len; + int signal; #ifdef CONFIG_USER_ONLY int fd; int running_state; @@ -121,6 +122,16 @@ int use_gdb_syscalls(void) return gdb_syscall_mode == GDB_SYS_ENABLED; } +/* Resume execution. */ +static inline void gdb_continue(GDBState *s) +{ +#ifdef CONFIG_USER_ONLY + s->running_state = 1; +#else + vm_start(); +#endif +} + static void put_buffer(GDBState *s, const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY @@ -908,11 +919,11 @@ static int gdb_handle_packet(GDBState *s env->pc = addr; #endif } -#ifdef CONFIG_USER_ONLY - s->running_state = 1; -#else - vm_start(); -#endif + gdb_continue(s); + return RS_IDLE; + case 'C': + s->signal = strtoul(p, (char **)&p, 16); + gdb_continue(s); return RS_IDLE; case 's': if (*p != '\0') { @@ -935,11 +946,7 @@ static int gdb_handle_packet(GDBState *s #endif } cpu_single_step(env, 1); -#ifdef CONFIG_USER_ONLY - s->running_state = 1; -#else - vm_start(); -#endif + gdb_continue(s); return RS_IDLE; case 'F': { @@ -961,11 +968,7 @@ static int gdb_handle_packet(GDBState *s if (type == 'C') { put_packet(s, "T02"); } else { -#ifdef CONFIG_USER_ONLY - s->running_state = 1; -#else - vm_start(); -#endif + gdb_continue(s); } } break; @@ -1294,6 +1297,8 @@ gdb_handlesig (CPUState *env, int sig) return sig; } } + sig = s->signal; + s->signal = 0; return sig; }