All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] Add GDB qAttached support
@ 2013-03-05 16:03 Fabien Chouteau
  2013-03-05 16:03 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Fabien Chouteau
  2013-03-10  8:06 ` [Qemu-devel] [PATCH 1/2] Add GDB qAttached support Jan Kiszka
  0 siblings, 2 replies; 10+ messages in thread
From: Fabien Chouteau @ 2013-03-05 16:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: jan.kiszka

With this patch GDB will issue a "detach" command at the end of a
debugging session instead of a "kill". This behavior can be inverted
with the new option -gdb-not-attached.

This patch implements the requirement described in Jan Kiszka's patch:
"gdbstub: Do not kill target in system emulation mode". The patch can
therefore be reverted.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
---
 gdbstub.c              |   13 ++++++++++++-
 include/exec/gdbstub.h |    2 ++
 qemu-options.hx        |    7 +++++++
 vl.c                   |    3 +++
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gdbstub.c b/gdbstub.c
index e414ad9..c0686a9 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -32,7 +32,6 @@
 #include "monitor/monitor.h"
 #include "char/char.h"
 #include "sysemu/sysemu.h"
-#include "exec/gdbstub.h"
 #endif
 
 #define MAX_PACKET_LENGTH 4096
@@ -41,6 +40,9 @@
 #include "qemu/sockets.h"
 #include "sysemu/kvm.h"
 #include "qemu/bitops.h"
+#include "exec/gdbstub.h"
+
+static bool gdb_attached = true;
 
 #ifndef TARGET_CPU_MEMORY_RW_DEBUG
 static inline int target_memory_rw_debug(CPUArchState *env, target_ulong addr,
@@ -2491,6 +2493,10 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
             break;
         }
 #endif
+        if (strncmp(p, "Attached", 8) == 0) {
+            put_packet(s, gdb_attached ? "1" : "0");
+            break;
+        }
         /* Unrecognised 'q' command.  */
         goto unknown_command;
 
@@ -3055,3 +3061,8 @@ int gdbserver_start(const char *device)
     return 0;
 }
 #endif
+
+void gdb_set_attached(bool attached)
+{
+    gdb_attached = attached;
+}
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index ba20afa..b2d3b13 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -50,4 +50,6 @@ int gdbserver_start(const char *port);
 /* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */
 extern const char *const xml_builtin[][2];
 
+void gdb_set_attached(bool attached);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 6f9334a..026d3eb 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2988,6 +2988,13 @@ property must be set.  These objects are placed in the
 '/objects' path.
 ETEXI
 
+DEF("gdb-not-attached", 0, QEMU_OPTION_gdb_not_attached,
+    "-gdb-not-attached\n"
+    "                Do not set Gdb remote server in attached mode.\n"
+    "                When exiting debugging session, Gdb will send a 'kill'\n"
+    "                command instead of a 'detach'.\n",
+    QEMU_ARCH_ALL)
+
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
 @end table
diff --git a/vl.c b/vl.c
index c03edf1..ccd7405 100644
--- a/vl.c
+++ b/vl.c
@@ -3815,6 +3815,9 @@ int main(int argc, char **argv, char **envp)
                     exit(1);
                 }
                 break;
+            case QEMU_OPTION_gdb_not_attached:
+                gdb_set_attached(false);
+                break;
             default:
                 os_parse_cmd_args(popt->index, optarg);
             }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 0/2] Add GDB qAttached support
@ 2013-03-12 14:31 Fabien Chouteau
  2013-03-12 14:31 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Fabien Chouteau
  0 siblings, 1 reply; 10+ messages in thread
From: Fabien Chouteau @ 2013-03-12 14:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: jan.kiszka

Fabien Chouteau (2):
  Add GDB qAttached support
  Revert "gdbstub: Do not kill target in system emulation mode"

 gdbstub.c              |   40 +++++++++++++++++++++++++++++++++++++---
 include/exec/gdbstub.h |    2 ++
 qemu-options.hx        |   17 +++++++++++++++++
 vl.c                   |    3 +++
 4 files changed, 59 insertions(+), 3 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [Qemu-trivial] [PATCH 1/2] Add GDB qAttached support
@ 2015-01-31  9:28 Jan Kiszka
  2015-01-31  9:29 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Jan Kiszka
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2015-01-31  9:28 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel

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

From: Jan Kiszka <jan.kiszka@siemens.com>

With this patch QEMU handles qAttached request from gdb. When QEMU
replies 1, GDB sends a "detach" command at the end of a debugging
session otherwise GDB sends "kill".

The default value for qAttached is 1 on system emulation and 0 on user
emulation.

Based on original version by Fabien Chouteau.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Long pending in my queue. Hope we can finally get these two in via
trivial (that's what they are).

 gdbstub.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gdbstub.c b/gdbstub.c
index e4a1a79..da3e7cb 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -41,6 +41,12 @@
 #include "qemu/sockets.h"
 #include "sysemu/kvm.h"
 
+#ifdef CONFIG_USER_ONLY
+#define GDB_ATTACHED "0"
+#else
+#define GDB_ATTACHED "1"
+#endif
+
 static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr,
                                          uint8_t *buf, int len, bool is_write)
 {
@@ -1187,6 +1193,10 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
             put_packet_binary(s, buf, len + 1);
             break;
         }
+        if (strncmp(p, "Attached", 8) == 0) {
+            put_packet(s, GDB_ATTACHED);
+            break;
+        }
         /* Unrecognised 'q' command.  */
         goto unknown_command;
 
-- 
2.1.4


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-31  9:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-05 16:03 [Qemu-devel] [PATCH 1/2] Add GDB qAttached support Fabien Chouteau
2013-03-05 16:03 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Fabien Chouteau
2013-03-05 16:07   ` Jan Kiszka
2013-03-05 16:30     ` Fabien Chouteau
2013-03-10  8:06 ` [Qemu-devel] [PATCH 1/2] Add GDB qAttached support Jan Kiszka
2013-03-11 11:22   ` Fabien Chouteau
2013-03-11 11:36     ` Jan Kiszka
2013-03-11 11:59       ` Fabien Chouteau
  -- strict thread matches above, loose matches on Subject: below --
2013-03-12 14:31 [Qemu-devel] [PATCH 0/2] " Fabien Chouteau
2013-03-12 14:31 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Fabien Chouteau
2015-01-31  9:28 [Qemu-trivial] [PATCH 1/2] Add GDB qAttached support Jan Kiszka
2015-01-31  9:29 ` [Qemu-devel] [PATCH 2/2] Revert "gdbstub: Do not kill target in system emulation mode" Jan Kiszka

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.