All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
Cc: qemu-devel@nongnu.org,  gustavo.romero@linaro.org,
	richard.henderson@linaro.org,  philmd@linaro.org,
	manos.pitsidianakis@linaro.org,
	 Patryk 'patryk4815' Sondej <patryk.sondej@gmail.com>
Subject: Re: [PATCH] gdbstub: Implement qGDBServerVersion packet
Date: Fri, 02 May 2025 13:53:22 +0100	[thread overview]
Message-ID: <87jz6zw4vx.fsf@draig.linaro.org> (raw)
In-Reply-To: <20250403191340.53343-1-dominik.b.czarnota@gmail.com> (Dominik Czarnota's message of "Thu, 3 Apr 2025 21:13:40 +0200")

Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com> writes:

> 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>

Hmm:

cc -m64 -Ilibuser.a.p -I. -I../.. -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /home/alex/lsrc/qemu.git/linux-headers -isystem linux-headers -iquote . -iquote /home/alex/lsrc/qemu.git -iquote /home/alex/lsrc/qemu.git/include -iquote /home/alex/lsrc/qemu.git/host/include/x86_64 -iquote /home/alex/lsrc/qemu.git/host/include/generic -iquote /home/alex/lsrc/qemu.git/tcg/i386 -pthread -mcx16 -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -fPIE -DCONFIG_USER_ONLY -DCOMPILING_SYSTEM_VS_USER -MD -MQ libuser.a.p/gdbstub_gdbstub.c.o -MF libuser.a.p/gdbstub_gdbstub.c.o.d -o libuser.a.p/gdbstub_gdbstub.c.o -c ../../gdbstub/gdbstub.c
../../gdbstub/gdbstub.c: In function ‘handle_query_gdb_server_version’:
../../gdbstub/gdbstub.c:1603:74: error: implicit declaration of function ‘target_name’ [-Werror=implicit-function-declaration]
 1603 |     g_string_printf(gdbserver_state.str_buf, "name:qemu-%s;version:%s;", target_name(), QEMU_VERSION);
      |                                                                          ^~~~~~~~~~~
../../gdbstub/gdbstub.c:1603:74: error: nested extern declaration of ‘target_name’ [-Werror=nested-externs]
../../gdbstub/gdbstub.c:1603:46: error: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Werror=format=]
 1603 |     g_string_printf(gdbserver_state.str_buf, "name:qemu-%s;version:%s;", target_name(), QEMU_VERSION);
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~
      |                                                                          |
      |                                                                          int
cc1: all warnings being treated as errors

where did target_name() come from and/or go to?

> ---
>  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",

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2025-05-02 12:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 19:13 [PATCH] gdbstub: Implement qGDBServerVersion packet Dominik 'Disconnect3d' Czarnota
2025-05-02 12:53 ` Alex Bennée [this message]
2025-05-19 12:59   ` Alex Bennée
2025-05-19 13:09     ` Dominik Czarnota

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=87jz6zw4vx.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=dominik.b.czarnota@gmail.com \
    --cc=gustavo.romero@linaro.org \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=patryk.sondej@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.