All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wessel <jason.wessel@windriver.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] GDB serial protocol fixes (detach, kill, and initial status query)
Date: Mon, 31 Jul 2006 11:24:58 -0500	[thread overview]
Message-ID: <44CE2EDA.6040100@windriver.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]


I have occasionally found that I have killed off gdb, and had no way to 
recover a debug session to QEMU.  Also the detach/kill sequence does not 
work correctly protocol wise in the QEMU gdb-stub.  This patch addresses 
these problems.

I implemented the serial protocol commands the same way as in KGDB.

? = Query state, but also clear the breakpoints.
      - KGDB/gdb do the same thing so that in case you lose your
        session or context, gdb always send the "?" command during the
        connect sequence.  This ensures that gdb has a clean slate
        for breakpoints and run control.

D = Detach and clear all breakpoints with return "OK"

k = Do the same thing as D for now
      In the future this can be used to kill the target
      emulation.  But for now it makes gdb and other gdb serial debugger
      happy.

signed-off-by: jason.wessel@windriver.com

Thanks,
Jason.

[-- Attachment #2: gdb_break_remove_cleanup.patch --]
[-- Type: text/plain, Size: 1436 bytes --]

Index: qemu/cpu-all.h
===================================================================
--- qemu.orig/cpu-all.h
+++ qemu/cpu-all.h
@@ -768,6 +768,7 @@ void cpu_reset_interrupt(CPUState *env, 
 
 int cpu_breakpoint_insert(CPUState *env, target_ulong pc);
 int cpu_breakpoint_remove(CPUState *env, target_ulong pc);
+int cpu_breakpoint_remove_all(CPUState *env);
 void cpu_single_step(CPUState *env, int enabled);
 void cpu_reset(CPUState *s);
 
Index: qemu/gdbstub.c
===================================================================
--- qemu.orig/gdbstub.c
+++ qemu/gdbstub.c
@@ -580,6 +580,8 @@ static int gdb_handle_packet(GDBState *s
         /* TODO: Make this return the correct value for user-mode.  */
         snprintf(buf, sizeof(buf), "S%02x", SIGTRAP);
         put_packet(s, buf);
+        /* Remove all the breakpoints when this query is issued. */
+        cpu_breakpoint_remove_all(env);
         break;
     case 'c':
         if (*p != '\0') {
@@ -603,6 +605,18 @@ static int gdb_handle_packet(GDBState *s
         vm_start();
 #endif
 	return RS_IDLE;
+    case 'k':
+    case 'D':
+        /* Detach packet */
+        if (!cpu_breakpoint_remove_all(env)) {
+#ifdef CONFIG_USER_ONLY
+            s->running_state = 1;
+#else
+            vm_start();
+#endif
+            put_packet(s, "OK");
+            break;
+        }
     case 's':
         if (*p != '\0') {
             addr = strtoul(p, (char **)&p, 16);

                 reply	other threads:[~2006-07-31 16:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=44CE2EDA.6040100@windriver.com \
    --to=jason.wessel@windriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.