From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JweBB-00065b-PC for qemu-devel@nongnu.org; Thu, 15 May 2008 10:11:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JweBA-00064O-Hc for qemu-devel@nongnu.org; Thu, 15 May 2008 10:11:33 -0400 Received: from [199.232.76.173] (port=47128 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JweB9-000643-VH for qemu-devel@nongnu.org; Thu, 15 May 2008 10:11:32 -0400 Received: from mail.windriver.com ([147.11.1.11]:50473 helo=mail.wrs.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JweB9-0003TG-1b for qemu-devel@nongnu.org; Thu, 15 May 2008 10:11:31 -0400 Received: from ALA-MAIL03.corp.ad.wrs.com (ala-mail03 [147.11.57.144]) by mail.wrs.com (8.13.6/8.13.6) with ESMTP id m4FEBTfw000016 for ; Thu, 15 May 2008 07:11:29 -0700 (PDT) From: Jason Wessel Date: Thu, 15 May 2008 09:11:29 -0500 Message-Id: <1210860693-22245-2-git-send-email-jason.wessel@windriver.com> In-Reply-To: <1210860693-22245-1-git-send-email-jason.wessel@windriver.com> References: <1210860693-22245-1-git-send-email-jason.wessel@windriver.com> Subject: [Qemu-devel] [PATCH 1/5] gdbstub: replace singlestep q packets with qRcmd packets 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 At the gdbserial protocol level, using the qRcmd packets allows gdb to use the "monitor" command to access the controls for single stepping behavior. Now you can use a gdb "monitor" command instead of a gdb "maintenance" command. The qemu docs were updated to reflect this change. Signed-off-by: Jason Wessel --- gdbstub.c | 82 +++++++++++++++++++++++++++++++++++++++++---------------- qemu-doc.texi | 34 +++++++++++------------ 2 files changed, 75 insertions(+), 41 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9a361e3..4bc7999 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -239,6 +239,27 @@ static int put_packet(GDBState *s, char *buf) return 0; } +static void monitor_output(GDBState *s, const char *msg) +{ + char *buf; + int len = strlen(msg); + + buf = malloc(len * 2 + 2); + buf[0] = 'O'; + memtohex(buf + 1, msg, len); + put_packet(s, buf); + free(buf); +} + +static void monitor_help(GDBState *s) +{ + monitor_output(s, "gdbstub specific monitor commands:\n"); + monitor_output(s, "s_show -- Show gdbstub Single Stepping variables\n"); + monitor_output(s, "set s_step <0|1> -- Single Stepping enabled\n"); + monitor_output(s, "set s_irq <0|1> -- Single Stepping with qemu irq handlers enabled\n"); + monitor_output(s, "set s_timer <0|1> -- Single Stepping with qemu timers enabled\n"); +} + #if defined(TARGET_I386) #ifdef TARGET_X86_64 @@ -943,6 +964,42 @@ static void cpu_gdb_write_registers(CPUState *env, uint8_t *mem_buf, int size) #endif +static void gdb_rcmd(GDBState *s, const char *p, char *buf, char *mem_buf) +{ + int len = strlen(p); + + if ((len % 2) != 0) { + put_packet(s, "E01"); + return; + } + hextomem(mem_buf, p, len); + mem_buf[(len >> 1)] = 0; + + if (!strcmp(mem_buf, "s_show")) { + sprintf(buf, "s_step == %i\n", (sstep_flags & SSTEP_ENABLE) != 0); + monitor_output(s, buf); + sprintf(buf, "s_irq == %i\n", (sstep_flags & SSTEP_NOIRQ) == 0); + monitor_output(s, buf); + sprintf(buf, "s_timer == %i\n", (sstep_flags & SSTEP_NOTIMER) == 0); + monitor_output(s, buf); + } else if (!strcmp(mem_buf, "s_step 1")) { + sstep_flags |= SSTEP_ENABLE; + } else if (!strcmp(mem_buf, "s_step 0")) { + sstep_flags &= ~SSTEP_ENABLE; + } else if (!strcmp(mem_buf, "s_irq 1")) { + sstep_flags &= ~SSTEP_NOIRQ; + } else if (!strcmp(mem_buf, "s_irq 0")) { + sstep_flags |= SSTEP_NOIRQ; + } else if (!strcmp(mem_buf, "s_timer 1")) { + sstep_flags &= ~SSTEP_NOTIMER; + } else if (!strcmp(mem_buf, "s_timer 0")) { + sstep_flags |= SSTEP_NOTIMER; + } else if (!strcmp(mem_buf, "help") || !strcmp(mem_buf, "?")) { + monitor_help(s); + } + put_packet(s, "OK"); +} + static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) { const char *p; @@ -1113,29 +1170,8 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) } break; case 'q': - case 'Q': - /* parse any 'q' packets here */ - if (!strcmp(p,"qemu.sstepbits")) { - /* Query Breakpoint bit definitions */ - sprintf(buf,"ENABLE=%x,NOIRQ=%x,NOTIMER=%x", - SSTEP_ENABLE, - SSTEP_NOIRQ, - SSTEP_NOTIMER); - put_packet(s, buf); - break; - } else if (strncmp(p,"qemu.sstep",10) == 0) { - /* Display or change the sstep_flags */ - p += 10; - if (*p != '=') { - /* Display current setting */ - sprintf(buf,"0x%x", sstep_flags); - put_packet(s, buf); - break; - } - p++; - type = strtoul(p, (char **)&p, 16); - sstep_flags = type; - put_packet(s, "OK"); + if (!strncmp(p, "Rcmd,", 5)) { + gdb_rcmd(s, p + 5, buf, mem_buf); break; } #ifdef CONFIG_LINUX_USER diff --git a/qemu-doc.texi b/qemu-doc.texi index cca483c..11c7058 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -1950,32 +1950,30 @@ Use @code{set architecture i8086} to dump 16 bit code. Then use Advanced debugging options: -The default single stepping behavior is step with the IRQs and timer service routines off. It is set this way because when gdb executes a single step it expects to advance beyond the current instruction. With the IRQs and and timer service routines on, a single step might jump into the one of the interrupt or exception vectors instead of executing the current instruction. This means you may hit the same breakpoint a number of times before executing the instruction gdb wants to have executed. Because there are rare circumstances where you want to single step into an interrupt vector the behavior can be controlled from GDB. There are three commands you can query and set the single step behavior: +The default single stepping behavior is to step with the IRQs and timer service routines off. It is set this way because when gdb executes a single step it expects to advance beyond the current instruction. With the IRQs and and timer service routines on, a single step might jump into the one of the interrupt or exception vectors instead of executing the current instruction. This means you may hit the same breakpoint a number of times before executing the instruction gdb wants execute. Because there are rare circumstances where you want to single step into an interrupt vector the behavior can be controlled from GDB. There are several commands you use to query and set the single step behavior while inside gdb: @table @code -@item maintenance packet qqemu.sstepbits +@item monitor s_show -This will display the MASK bits used to control the single stepping IE: +This will display the values of the single stepping controls IE: @example -(gdb) maintenance packet qqemu.sstepbits -sending: "qqemu.sstepbits" -received: "ENABLE=1,NOIRQ=2,NOTIMER=4" +(gdb) monitor s_show +s_step == 1 +s_irq == 0 +s_timer == 0 @end example -@item maintenance packet qqemu.sstep +@item monitor s_step <0|1> -This will display the current value of the mask used when single stepping IE: +Turn off or on the single stepping feature all together, which is defaulted to on. @example -(gdb) maintenance packet qqemu.sstep -sending: "qqemu.sstep" -received: "0x7" +(gdb) monitor s_step 1 +(gdb) monitor s_step 0 @end example -@item maintenance packet Qqemu.sstep=HEX_VALUE +@item monitor s_irq <0|1> -This will change the single step mask, so if wanted to enable IRQs on the single step, but not timers, you would use: -@example -(gdb) maintenance packet Qqemu.sstep=0x5 -sending: "qemu.sstep=0x5" -received: "OK" -@end example +Turn off or on the the irq processing when single stepping, which is defaulted to off. +@item monitor s_timer <0|1> + +Turn off or on the the timer processing when single stepping, which is defaulted to off. @end table @node pcsys_os_specific -- 1.5.5.1