From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G7aZl-0007Pa-3U for qemu-devel@nongnu.org; Mon, 31 Jul 2006 12:25:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G7aZj-0007Oc-9V for qemu-devel@nongnu.org; Mon, 31 Jul 2006 12:25:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G7aZj-0007OY-5U for qemu-devel@nongnu.org; Mon, 31 Jul 2006 12:25:03 -0400 Received: from [147.11.1.11] (helo=mail.wrs.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G7acQ-00018I-8j for qemu-devel@nongnu.org; Mon, 31 Jul 2006 12:27:50 -0400 Received: from ala-mail04.corp.ad.wrs.com (ala-mail04 [147.11.57.145]) by mail.wrs.com (8.13.6/8.13.3) with ESMTP id k6VGP0Bc018788 for ; Mon, 31 Jul 2006 09:25:00 -0700 (PDT) Message-ID: <44CE2EDA.6040100@windriver.com> Date: Mon, 31 Jul 2006 11:24:58 -0500 From: Jason Wessel MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090906090304020407070900" Subject: [Qemu-devel] [PATCH] GDB serial protocol fixes (detach, kill, and initial status query) 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 This is a multi-part message in MIME format. --------------090906090304020407070900 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I have occasionally found that I have killed off gdb, and had no way to recover a debug session to QEMU. Also the detach/kill sequence does not work correctly protocol wise in the QEMU gdb-stub. This patch addresses these problems. I implemented the serial protocol commands the same way as in KGDB. ? = Query state, but also clear the breakpoints. - KGDB/gdb do the same thing so that in case you lose your session or context, gdb always send the "?" command during the connect sequence. This ensures that gdb has a clean slate for breakpoints and run control. D = Detach and clear all breakpoints with return "OK" k = Do the same thing as D for now In the future this can be used to kill the target emulation. But for now it makes gdb and other gdb serial debugger happy. signed-off-by: jason.wessel@windriver.com Thanks, Jason. --------------090906090304020407070900 Content-Type: text/plain; name="gdb_break_remove_cleanup.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb_break_remove_cleanup.patch" Index: qemu/cpu-all.h =================================================================== --- qemu.orig/cpu-all.h +++ qemu/cpu-all.h @@ -768,6 +768,7 @@ void cpu_reset_interrupt(CPUState *env, int cpu_breakpoint_insert(CPUState *env, target_ulong pc); int cpu_breakpoint_remove(CPUState *env, target_ulong pc); +int cpu_breakpoint_remove_all(CPUState *env); void cpu_single_step(CPUState *env, int enabled); void cpu_reset(CPUState *s); Index: qemu/gdbstub.c =================================================================== --- qemu.orig/gdbstub.c +++ qemu/gdbstub.c @@ -580,6 +580,8 @@ static int gdb_handle_packet(GDBState *s /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "S%02x", SIGTRAP); put_packet(s, buf); + /* Remove all the breakpoints when this query is issued. */ + cpu_breakpoint_remove_all(env); break; case 'c': if (*p != '\0') { @@ -603,6 +605,18 @@ static int gdb_handle_packet(GDBState *s vm_start(); #endif return RS_IDLE; + case 'k': + case 'D': + /* Detach packet */ + if (!cpu_breakpoint_remove_all(env)) { +#ifdef CONFIG_USER_ONLY + s->running_state = 1; +#else + vm_start(); +#endif + put_packet(s, "OK"); + break; + } case 's': if (*p != '\0') { addr = strtoul(p, (char **)&p, 16); --------------090906090304020407070900--