From patchwork Mon Aug 3 14:45:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 30597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 8A47CB6F31 for ; Tue, 4 Aug 2009 03:05:29 +1000 (EST) Received: from localhost ([127.0.0.1]:48798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MY0yR-0001By-Ly for incoming@patchwork.ozlabs.org; Mon, 03 Aug 2009 13:05:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXytM-0007W5-Ip for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:52:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXytH-0007UO-OW for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:51:59 -0400 Received: from [199.232.76.173] (port=47670 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXytH-0007UB-1g for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:51:55 -0400 Received: from mx20.gnu.org ([199.232.41.8]:47635) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MXytG-0006Wr-Jw for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:51:54 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXytF-0001g4-Pc for qemu-devel@nongnu.org; Mon, 03 Aug 2009 10:51:54 -0400 Received: (qmail 16872 invoked from network); 3 Aug 2009 14:45:13 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Aug 2009 14:45:13 -0000 From: Nathan Froyd To: qemu-devel@nongnu.org Date: Mon, 3 Aug 2009 07:45:11 -0700 Message-Id: <1249310711-8873-7-git-send-email-froydnj@codesourcery.com> X-Mailer: git-send-email 1.6.3.2 In-Reply-To: <1249310711-8873-1-git-send-email-froydnj@codesourcery.com> References: <1249310711-8873-1-git-send-email-froydnj@codesourcery.com> X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 6/6] gdbstub: add qSymbol handling for TARGET_MIPS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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 ff4c86c..ab2ce07 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) {