qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Froyd <froydnj@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 6/6] gdbstub: add qSymbol handling for TARGET_MIPS
Date: Mon,  3 Aug 2009 07:45:11 -0700	[thread overview]
Message-ID: <1249310711-8873-7-git-send-email-froydnj@codesourcery.com> (raw)
In-Reply-To: <1249310711-8873-1-git-send-email-froydnj@codesourcery.com>

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 <froydnj@codesourcery.com>
---
 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) {
-- 
1.6.3.2

  parent reply	other threads:[~2009-08-03 14:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-03 14:45 [Qemu-devel] [PATCH 0/6] target-mips: add MDI semihosting, v2 Nathan Froyd
2009-08-03 14:45 ` [Qemu-devel] [PATCH 1/6] sysemu: add section_callback argument to ELF loader Nathan Froyd
2009-08-03 14:45 ` [Qemu-devel] [PATCH 2/6] add softmmu_target_strlen Nathan Froyd
2009-08-03 14:45 ` [Qemu-devel] [PATCH 3/6] add implementation of MIPS semihosting Nathan Froyd
2009-08-03 14:45 ` [Qemu-devel] [PATCH 4/6] target-mips: add MDI semihosting support to mipssim machine Nathan Froyd
2009-08-03 14:45 ` [Qemu-devel] [PATCH 5/6] enable --semihosting option for TARGET_MIPS Nathan Froyd
2009-08-03 14:45 ` Nathan Froyd [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-07-17 20:33 [Qemu-devel] [PATCH 0/6] target-mips: add MDI semihosting Nathan Froyd
2009-07-17 20:33 ` [Qemu-devel] [PATCH 6/6] gdbstub: add qSymbol handling for TARGET_MIPS Nathan Froyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1249310711-8873-7-git-send-email-froydnj@codesourcery.com \
    --to=froydnj@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).