From nobody Tue Feb 10 05:46:13 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1770119616; cv=none; d=zohomail.com; s=zohoarc; b=k6tzGE4jRB7lfb7QeQwFeoBQFlSeI0CPWl66HWvSEMjD7UPZfvxZ8p47Tj78tltsKz5HeTWl2XKoLgC4g4rNyiqbkAWy2pYhxey0XQNATucr80rAig3kRy48vC2kPXPlvn/HnU+ee455n4LlS5nxMrhX/O6A+TPd2FoCCqzzD8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770119616; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3rnOG7bwrBNwvdTMzR0X6nqTtCuNrtf+RkzdzcDauu4=; b=QDnvmbZVZ6bNVh4E29CCL3AIdmW5xm542TwK6IpGlhOFNefRpnHsbM0DYteNP5nVPI+ap9celNwohWLtaLW+rvqjsagjwHdABZT02naII3IDRBhIgnoTw1b1z+hY/NiKOjom8WgwSRIFybJ9Bg6ZHeLAvlNeYE2BZMcd1b2lngU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770119616389858.8412491333693; Tue, 3 Feb 2026 03:53:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vnExH-00084M-H7; Tue, 03 Feb 2026 06:52:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vnEx4-0007xg-44 for qemu-devel@nongnu.org; Tue, 03 Feb 2026 06:52:14 -0500 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vnEx0-0005A0-Bb for qemu-devel@nongnu.org; Tue, 03 Feb 2026 06:52:13 -0500 Received: by mail-ej1-x641.google.com with SMTP id a640c23a62f3a-b87677a8abeso833060866b.1 for ; Tue, 03 Feb 2026 03:52:09 -0800 (PST) Received: from draig.lan ([185.124.0.126]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8dbeffedd3sm998692766b.29.2026.02.03.03.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Feb 2026 03:52:07 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9CB2B60231; Tue, 03 Feb 2026 11:52:02 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1770119529; x=1770724329; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3rnOG7bwrBNwvdTMzR0X6nqTtCuNrtf+RkzdzcDauu4=; b=u7X0/Zcjt6hImDuEKVy6/J9RRSjC5NQwmuHhPFDoH8l4HyOES4nXQORVU1Ab2nMXnB SW6B9mlKbHYsbTVtSny0YZxcKKRFvjg7I4Lxzb/kRd63isG8x+quJw9+UhTjnrko5W3m SIiMzOCNUmph+ljG8dKtGxmd2ugj4iO65gexr4NPaHF+o73mETnBz04yhUn7FmAHqIXO CIqYZvj25YVnUciX0gxbU0/yb0yVtxtYYHFN8ij/yAMnJg2y0rGnGZxWMNa58PPqD6ry WuluYTKdOVi/6/dpfDq/7o9pxVpdXxHDNTRgUF7dV8ip1Btik9pZsPBtoUH7IREySg5/ KJZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770119529; x=1770724329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3rnOG7bwrBNwvdTMzR0X6nqTtCuNrtf+RkzdzcDauu4=; b=DFBdceiLjKKETT0fYlMW4nUqdCiyrwZhTirxl8i6lgZFvtHsJxDBAyy3zaJ9UMZ/XX ZF3AGYV0iQmFPaKkAbpkUpjPpaBIf25ojKHbpttkIt9OGbofhHjwthjCOwHDyNUagZmN 9oLPHAgSz8F0v0BG59grdRaJ4iI6Vkq+43nM4TwT+ZQ4cXc9s5SWTVpUuqtHmN5y4e+j 1FUFd3aJNi3LYD1aT3eZilsk2q5eqn7hVmqrks0jKHlbSO1yynK2b9NciZ++ynKGj2vD Ckr1Vdtf8aC1wdKa7SHKj4YcnJ3NG102RJJ0MS+H8q4q1rv9nsQY5Dah0vm7BOEwY8s+ X5Bg== X-Gm-Message-State: AOJu0YxRl+cnpQyk1eK2ACeS6WS8SzTwhCgV/E9+TP/Y73ON7VUYV/MU RrPXPJiORTZ8LG2hCt48f5HkCmAqzmSnoIN/E48kZMBGE39FZaMEhEA2I/rSr4Wgu3I= X-Gm-Gg: AZuq6aLJGCgVF8pFPl7bLOPnJWpWlliocCQPtOpT/Krah7tjIiM1i74ug9CtbaSpdUZ pghjCw/ilkR8mmfOlhSQNT1wA4BZfQEPN8ovvvS389TgmY1f1blf1xH+sYrhvPNmsLFOZNFjt7E 97kM6H7eihJe5yx8prTOpuLjKCWnqblMH+HKu0VlAvo8JhABtLUb6B1yEtCC8JZ6zUut9XarKHY KTuoIriKMzHVElU2w5M8CZlLo95paxGQti9AxbOaGdHq4yE6fyjGPCyJrm8TpyF6AIAIm1NeBFx HP5JYSHaQsul+joq8K1gw55oo7xez+TprHYo0FtQq3FoS0rXt1+jBw0J5bAaJgZNRXNEGjbDfQ5 5+BP7Q1+Nur4tDrD7A79C5F69TW+KxtlfLht9MggJXmgPo/UPtDhyPEEEkvvyDo1y0JfcTq4GWO MGyA9ukPMVQjbMl5w1lmKnDA== X-Received: by 2002:a17:907:1b03:b0:b87:35fc:ae6e with SMTP id a640c23a62f3a-b8dff69d99bmr912611866b.46.1770119528628; Tue, 03 Feb 2026 03:52:08 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: John Snow , Pierrick Bouvier , qemu-arm@nongnu.org, Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , Nicholas Piggin , Wainer dos Santos Moschetta , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Peter Maydell , Cleber Rosa , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Edgar E. Iglesias" , qemu-s390x@nongnu.org, Thomas Huth , Paolo Bonzini , Akihiko Odaki , Daniel Henrique Barboza , David Hildenbrand , Ilya Leoshkevich , Richard Henderson , Laurent Vivier Subject: [PATCH 06/11] gdbstub: pass GString to gdb_build_stop_packet Date: Tue, 3 Feb 2026 11:51:56 +0000 Message-ID: <20260203115201.2387721-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260203115201.2387721-1-alex.bennee@linaro.org> References: <20260203115201.2387721-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::641; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x641.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1770119618166158500 The other functions we are going to clean-up work variously with there own dynamically allocated GStrings or with the common shared buffer. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- 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 ad= dr, =20 /** * 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. */ =20 -void gdb_build_stop_packet(CPUState *cs); +void gdb_build_stop_packet(GString *buf, CPUState *cs); =20 #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 *use= r_ctx) gdbserver_state.c_cpu =3D cpu; =20 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 =3D 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_c= pu); gdbserver_state.allow_stop_reply =3D 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}; */ =20 -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}; */ =20 -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_TR= AP); - 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, ';'); } --=20 2.47.3