Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LAXfw-0006AX-9w for qemu-devel@nongnu.org; Wed, 10 Dec 2008 17:37:00 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LAXfv-0006AF-Dj for qemu-devel@nongnu.org; Wed, 10 Dec 2008 17:36:59 -0500 Received: from [199.232.76.173] (port=41169 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LAXfv-0006AC-A7 for qemu-devel@nongnu.org; Wed, 10 Dec 2008 17:36:59 -0500 Received: from mailout2.zih.tu-dresden.de ([141.30.67.73]:59559) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LAXfu-0000ny-PJ for qemu-devel@nongnu.org; Wed, 10 Dec 2008 17:36:59 -0500 Received: from rmc67-31.zih.tu-dresden.de ([141.30.67.31] helo=server-n) by mailout2.zih.tu-dresden.de with esmtp (Exim 4.63) (envelope-from ) id 1LAXfs-0005xg-Ge for qemu-devel@nongnu.org; Wed, 10 Dec 2008 23:36:56 +0100 Received: from localhost (unknown [77.64.176.217]) by server-n (Postfix) with ESMTP id 13731100A08E for ; Wed, 10 Dec 2008 23:36:55 +0100 (CET) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LT7h14bkH0" Content-Transfer-Encoding: 7bit Message-ID: <18752.17539.868644.941088@tabernacle.localnet> Date: Wed, 10 Dec 2008 23:36:51 +0100 From: Julian Stecklina Subject: [Qemu-devel] [PATCH] Enable monitor commands in GDB stub 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 --LT7h14bkH0 Content-Type: text/plain; charset=us-ascii Content-Description: message body and .signature Content-Transfer-Encoding: 7bit Hello, I have added support for the qRcmd packet to the GDB stub. This lets you issue "monitor foo" in GDB and have it executed in qemu's monitor. A quick test suggests that it works fine, but I am quite new to the qemu codebase, so I don't know if calling 'monitor_handle_command' directly from the GDB stub violates any assumptions. Please keep me CC'd. Regards, -- Julian Stecklina Well, take it from an old hand: the only reason it would be easier to program in C is that you can't easily express complex problems in C, so you don't. - Erik Naggum (in comp.lang.lisp) --LT7h14bkH0 Content-Type: text/x-diff; name="gdb-monitor.diff" Content-Description: Add qRcmd support in GDB stub Content-Disposition: inline; filename="gdb-monitor.diff" Content-Transfer-Encoding: 7bit diff --git a/console.h b/console.h index 6ee40cc..3ae4f86 100644 --- a/console.h +++ b/console.h @@ -192,6 +192,7 @@ extern uint8_t _translate_keycode(const int key); does not need to include console.h */ /* monitor.c */ void monitor_init(CharDriverState *hd, int show_banner); +void monitor_handle_command(const char *cmdline); void term_puts(const char *str); void term_vprintf(const char *fmt, va_list ap); void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); diff --git a/gdbstub.c b/gdbstub.c index 72feac6..a1ad53d 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1290,6 +1290,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) char buf[MAX_PACKET_LENGTH]; uint8_t mem_buf[MAX_PACKET_LENGTH]; uint8_t *registers; + char *monitor_cmd; target_ulong addr, len; #ifdef DEBUG_GDB @@ -1529,7 +1530,16 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) case 'q': case 'Q': /* parse any 'q' packets here */ - if (!strcmp(p,"qemu.sstepbits")) { + if (strncmp(p, "Rcmd,", 5) == 0) { + p += 5; + len = strlen(p) / 2; + monitor_cmd = mem_buf; + hextomem((uint8_t *)monitor_cmd, p, len); + monitor_cmd[len] = 0; + monitor_handle_command(monitor_cmd); + put_packet(s, "OK"); + break; + } else if (!strcmp(p,"qemu.sstepbits")) { /* Query Breakpoint bit definitions */ snprintf(buf, sizeof(buf), "ENABLE=%x,NOIRQ=%x,NOTIMER=%x", SSTEP_ENABLE, diff --git a/monitor.c b/monitor.c index 0d55433..fc21ae3 100644 --- a/monitor.c +++ b/monitor.c @@ -2215,7 +2215,7 @@ static int default_fmt_size = 4; #define MAX_ARGS 16 -static void monitor_handle_command(const char *cmdline) +void monitor_handle_command(const char *cmdline) { const char *p, *pstart, *typestr; char *q; --LT7h14bkH0--