From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "John Snow" <jsnow@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
qemu-arm@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
qemu-ppc@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Cleber Rosa" <crosa@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
qemu-s390x@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Akihiko Odaki" <akihiko.odaki@daynix.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Laurent Vivier" <laurent@vivier.eu>
Subject: Re: [PATCH 06/11] gdbstub: pass GString to gdb_build_stop_packet
Date: Tue, 03 Feb 2026 15:44:24 +0000 [thread overview]
Message-ID: <87ikcdomqv.fsf@draig.linaro.org> (raw)
In-Reply-To: <20260203115201.2387721-7-alex.bennee@linaro.org> ("Alex Bennée"'s message of "Tue, 3 Feb 2026 11:51:56 +0000")
Alex Bennée <alex.bennee@linaro.org> writes:
> The other functions we are going to clean-up work variously with there
their...
> own dynamically allocated GStrings or with the common shared buffer.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> gdbstub/internals.h | 5 ++++-
> gdbstub/gdbstub.c | 4 ++--
> gdbstub/system.c | 4 ++--
> gdbstub/user.c | 8 ++++----
> 4 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/gdbstub/internals.h b/gdbstub/internals.h
> index 3134a6e8eb2..9b25bf58b8e 100644
> --- a/gdbstub/internals.h
> +++ b/gdbstub/internals.h
> @@ -239,9 +239,12 @@ int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr,
>
> /**
> * gdb_build_stop_packet() - craft the stop packet
> + * @buf: GString buffer for building the packet
> * @cs: CPUState
> + *
> + * Craft the Stop/Reply packet when we halt.
> */
>
> -void gdb_build_stop_packet(CPUState *cs);
> +void gdb_build_stop_packet(GString *buf, CPUState *cs);
>
> #endif /* GDBSTUB_INTERNALS_H */
> diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
> index c82fb5ad324..b45eb7c7b2b 100644
> --- a/gdbstub/gdbstub.c
> +++ b/gdbstub/gdbstub.c
> @@ -1432,7 +1432,7 @@ static void handle_v_attach(GArray *params, void *user_ctx)
> gdbserver_state.c_cpu = cpu;
>
> if (gdbserver_state.allow_stop_reply) {
> - gdb_build_stop_packet(cpu);
> + gdb_build_stop_packet(gdbserver_state.str_buf, cpu);
> gdbserver_state.allow_stop_reply = false;
> }
> }
> @@ -2036,7 +2036,7 @@ static void handle_gen_set(GArray *params, void *user_ctx)
> static void handle_target_halt(GArray *params, void *user_ctx)
> {
> if (gdbserver_state.allow_stop_reply) {
> - gdb_build_stop_packet(gdbserver_state.c_cpu);
> + gdb_build_stop_packet(gdbserver_state.str_buf, gdbserver_state.c_cpu);
> gdbserver_state.allow_stop_reply = false;
> gdb_put_strbuf();
> }
> diff --git a/gdbstub/system.c b/gdbstub/system.c
> index 6963c930b01..8ec8b7ea336 100644
> --- a/gdbstub/system.c
> +++ b/gdbstub/system.c
> @@ -668,8 +668,8 @@ void gdb_breakpoint_remove_all(CPUState *cs)
> * T05core:{id};
> */
>
> -void gdb_build_stop_packet(CPUState *cs)
> +void gdb_build_stop_packet(GString *buf, CPUState *cs)
> {
> - g_string_printf(gdbserver_state.str_buf,
> + g_string_printf(buf,
> "T%02xcore:%02x;", GDB_SIGNAL_TRAP, gdb_get_cpu_index(cs));
> }
> diff --git a/gdbstub/user.c b/gdbstub/user.c
> index c7a3ef947ed..a16f37616b1 100644
> --- a/gdbstub/user.c
> +++ b/gdbstub/user.c
> @@ -976,9 +976,9 @@ void gdb_handle_query_xfer_siginfo(GArray *params, void *user_ctx)
> * T05thread:{id};
> */
>
> -void gdb_build_stop_packet(CPUState *cs)
> +void gdb_build_stop_packet(GString *buf, CPUState *cs)
> {
> - g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP);
> - gdb_append_thread_id(cs, gdbserver_state.str_buf);
> - g_string_append_c(gdbserver_state.str_buf, ';');
> + g_string_printf(buf, "T%02xthread:", GDB_SIGNAL_TRAP);
> + gdb_append_thread_id(cs, buf);
> + g_string_append_c(buf, ';');
> }
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2026-02-03 15:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 11:51 [PATCH 00/11] gdbstub/next - bug fixes and cleanups (pre-PR) Alex Bennée
2026-02-03 11:51 ` [PATCH 01/11] meson-buildoptions: Remove duplicated entry of --gdb in the help text Alex Bennée
2026-02-03 11:51 ` [PATCH 02/11] Makefile: add python script dependency for meson-buildoptions.sh Alex Bennée
2026-02-03 11:51 ` [PATCH 03/11] gdbstub: remove the need for goto cleanup Alex Bennée
2026-02-03 22:06 ` Yodel Eldar
2026-02-03 22:14 ` Philippe Mathieu-Daudé
2026-02-03 11:51 ` [PATCH 04/11] gdbstub: extract stop reply message construction Alex Bennée
2026-02-04 4:29 ` Richard Henderson
2026-02-03 11:51 ` [PATCH 05/11] gdbstub/user: localise variables for reading gdb socket Alex Bennée
2026-02-04 4:35 ` Richard Henderson
2026-02-03 11:51 ` [PATCH 06/11] gdbstub: pass GString to gdb_build_stop_packet Alex Bennée
2026-02-03 15:44 ` Alex Bennée [this message]
2026-02-04 4:37 ` Richard Henderson
2026-02-03 11:51 ` [PATCH 07/11] include/gdbstub/syscalls: Add EIO and ENOSYS GDB File-I/O errno values Alex Bennée
2026-02-03 11:51 ` [PATCH 08/11] gdbstub: Export host_to_gdb_errno File-I/O helper function Alex Bennée
2026-02-03 11:51 ` [PATCH 09/11] gdbstub/user-target: Convert host errno to GDB File-I/O errno Alex Bennée
2026-02-03 11:52 ` [PATCH 10/11] include/gdbstub: fix typo Alex Bennée
2026-02-03 12:06 ` Peter Maydell
2026-02-03 11:52 ` [PATCH 11/11] gdbstub/user: rename and use bool for running_state Alex Bennée
2026-02-04 4:38 ` Richard Henderson
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=87ikcdomqv.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=akihiko.odaki@daynix.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=crosa@redhat.com \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=iii@linux.ibm.com \
--cc=jsnow@redhat.com \
--cc=laurent@vivier.eu \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=wainersm@redhat.com \
/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.