From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MRwiv-0002tS-DZ for qemu-devel@nongnu.org; Fri, 17 Jul 2009 19:20:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MRwiq-0002rl-EG for qemu-devel@nongnu.org; Fri, 17 Jul 2009 19:20:17 -0400 Received: from [199.232.76.173] (port=38972 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRwiq-0002re-9H for qemu-devel@nongnu.org; Fri, 17 Jul 2009 19:20:12 -0400 Received: from mx20.gnu.org ([199.232.41.8]:38359) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MRwip-0005Jt-PX for qemu-devel@nongnu.org; Fri, 17 Jul 2009 19:20:12 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MRwij-0005ai-SG for qemu-devel@nongnu.org; Fri, 17 Jul 2009 19:20:06 -0400 From: Nathan Froyd Date: Fri, 17 Jul 2009 13:33:22 -0700 Message-Id: <1247862802-13033-7-git-send-email-froydnj@codesourcery.com> In-Reply-To: <1247862802-13033-1-git-send-email-froydnj@codesourcery.com> References: <1247862802-13033-1-git-send-email-froydnj@codesourcery.com> Subject: [Qemu-devel] [PATCH 6/6] gdbstub: add qSymbol handling for TARGET_MIPS List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org QEMU needs to know the address of _mdi_syscall so that breakpoints can be set appropriately. But if QEMU is started from within GDB as: (gdb) target remote | qemu -M mipssim -s -S ... -kernel /dev/null ... (gdb) load then QEMU's ELF loader never gets a chance to grovel through the ELF file to look for the .sdeosabi section. Therefore, the GDB stub needs to know how to ask GDB for the address of _mdi_syscall so that the necessary breakpoint can be set. Signed-off-by: Nathan Froyd --- gdbstub.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index bb38971..d881a66 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1937,6 +1937,35 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) put_packet(s, buf); } break; + } else if (strncmp(p, "Symbol:", 7) == 0) { +#if defined(TARGET_MIPS) && !defined(TARGET_MIPS64) && !defined(CONFIG_USER_ONLY) +#define MDI_SYSCALL_SYMBOL "_mdi_syscall" + if (strncmp(p+7, ":", 1) == 0) { + /* GDB is telling us we can ask for symbols. Look for + _mdi_syscall. */ + memtohex((char *)mem_buf, (const uint8_t *)MDI_SYSCALL_SYMBOL, + strlen(MDI_SYSCALL_SYMBOL)); + mem_buf[strlen(MDI_SYSCALL_SYMBOL)*2] = 0; + snprintf(buf, sizeof(buf), "qSymbol:%s", mem_buf); + put_packet(s, buf); + break; + } else { + /* A response from a previous query. */ + if (*(p+7) != ':') { + addr = strtoull(p+7, (char **)&p, 16); + hextomem(mem_buf, p+1, strlen(MDI_SYSCALL_SYMBOL)*2); + + if (memcmp(mem_buf, MDI_SYSCALL_SYMBOL, + strlen(MDI_SYSCALL_SYMBOL)) == 0) { + install_semihosting_breakpoint(s->c_cpu, addr); + } + } + } + /* All done, regardless of whether we got the right symbol. */ + put_packet(s, "OK"); + break; +#undef MDI_SYSCALL_SYMBOL +#endif } #ifdef CONFIG_USER_ONLY else if (strncmp(p, "Offsets", 7) == 0) { -- 1.6.3.2