All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gdbstub: Implement qGDBServerVersion packet
@ 2025-04-03 19:13 Dominik 'Disconnect3d' Czarnota
  2025-05-02 12:53 ` Alex Bennée
  0 siblings, 1 reply; 4+ messages in thread
From: Dominik 'Disconnect3d' Czarnota @ 2025-04-03 19:13 UTC (permalink / raw)
  To: qemu-devel
  Cc: alex.bennee, gustavo.romero, richard.henderson, philmd,
	manos.pitsidianakis, Dominik 'Disconnect3d' Czarnota,
	Patryk 'patryk4815' Sondej

This commit adds support for the `qGDBServerVersion` packet to the qemu
gdbstub  which could be used by clients to detect the QEMU version
(and, e.g., use a workaround for known bugs).

This packet is not documented/standarized by GDB but it was implemented
by LLDB gdbstub [0] and is helpful for projects like Pwndbg [1].

This has been implemented by Patryk, who I included in Co-authored-by
and who asked me to send the patch.

[0] https://lldb.llvm.org/resources/lldbgdbremote.html#qgdbserverversion
[1] https://github.com/pwndbg/pwndbg/issues/2648

Co-authored-by: Patryk 'patryk4815' Sondej <patryk.sondej@gmail.com>
Signed-off-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
---
 gdbstub/gdbstub.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 282e13e163..8d616a7f52 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -1582,6 +1582,16 @@ static void handle_query_threads(GArray *params, void *user_ctx)
     gdbserver_state.query_cpu = gdb_next_attached_cpu(gdbserver_state.query_cpu);
 }
 
+static void handle_query_gdb_server_version(GArray *params, void *user_ctx)
+{
+#if defined(CONFIG_USER_ONLY)
+    g_string_printf(gdbserver_state.str_buf, "name:qemu-%s;version:%s;", target_name(), QEMU_VERSION);
+#else
+    g_string_printf(gdbserver_state.str_buf, "name:qemu-system-%s;version:%s;", target_name(), QEMU_VERSION);
+#endif
+    gdb_put_strbuf();
+}
+
 static void handle_query_first_threads(GArray *params, void *user_ctx)
 {
     gdbserver_state.query_cpu = gdb_first_attached_cpu();
@@ -1827,6 +1837,10 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = {
         .handler = handle_query_threads,
         .cmd = "sThreadInfo",
     },
+    {
+        .handler = handle_query_gdb_server_version,
+        .cmd = "GDBServerVersion",
+    },
     {
         .handler = handle_query_first_threads,
         .cmd = "fThreadInfo",
-- 
2.30.2



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

end of thread, other threads:[~2025-05-19 13:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-03 19:13 [PATCH] gdbstub: Implement qGDBServerVersion packet Dominik 'Disconnect3d' Czarnota
2025-05-02 12:53 ` Alex Bennée
2025-05-19 12:59   ` Alex Bennée
2025-05-19 13:09     ` Dominik Czarnota

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.