From nobody Wed Feb 11 06:15:32 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=1672937626; cv=none; d=zohomail.com; s=zohoarc; b=Tab0p4ppmjzmXm+9yE5hN5m571nywZFBGOGOOnNpTKr+jIsIFvRVM4oenJ1NaFStefK4E+A016ocI8YKI1ZwVgyV3ZrYtMmsDmBsUlhjcKTKk/rsgeop6U1IpbBQk8kPoOcOEnygPA9Y+vhMdkGGjY1w/4/m++h+51pA2C8OYeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672937626; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nQQTwgIF254LM7i6IkejsXBJ/YrsdmrSipPbKMfkzUs=; b=LJC1DkmjeyHf8JE0uGrQipKMkZeNJxtw0fHm03RnDR2Oc2V+R1FEEoE9owoYIx5ZBoliHj1nO3tqao9HnHi6JtGn6DVguCAUP5TlnwyScG5VMp6+J6emUywfQkzzsEp9r1Ziw/WQkBm03zDhOgvIAJQxIz0rz6zJ+W7VdbXasOA= 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 1672937626976301.15227881629573; Thu, 5 Jan 2023 08:53:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pDTLQ-0007OU-6E; Thu, 05 Jan 2023 11:43:56 -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 1pDTLD-0007Bk-3G for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:45 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTKx-0006w8-OG for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:42 -0500 Received: by mail-wm1-x331.google.com with SMTP id ja17so28447623wmb.3 for ; Thu, 05 Jan 2023 08:43:27 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id iv14-20020a05600c548e00b003b47b80cec3sm3432195wmb.42.2023.01.05.08.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 08:43:25 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2FC341FFC4; Thu, 5 Jan 2023 16:43:21 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=nQQTwgIF254LM7i6IkejsXBJ/YrsdmrSipPbKMfkzUs=; b=tKk141vR37auRMUWBkfgf9VuhgmW2DfhDmaVtRXuIuIQcrb2M2tc9JdlubfSxNVYpr KHfQm0IVaLuHf/cMtARZhp2VPPsUqOXKciWn9ALB11hecwzS0RQ9W+pKi//oCFSf7Rn5 bt5ZmZRh79/OVis4UmB/FD9fwAyu0QOSyG6EDDwmwrvVV5vxPnZxM6C2FgNv4GRO/TVx NTqC81kG0bhAhP5yVBUMOf1fYearayEtZfcKEd+DVD7zbawLzSlsbLseC4nNC4NSTB49 DLztlgON6xQE99rMUOVKC3uZaD6e1NIeOfqXinvZ7h2HXCLRG0t+IHmdwk9PLtktIfCo DMEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nQQTwgIF254LM7i6IkejsXBJ/YrsdmrSipPbKMfkzUs=; b=OLj4kInyzh+2GKND7KyFmk2cVbDiptDol55UdYvMcM/dIRIDfDoropPz4C/1sI6UYZ NWVQI0tAXBtRpNRq82BuccTicd8NO0wlc0lN11gXD2jZ/iCXyjPLR+Rehp/fBcvCyA4F IucVaDYcfcEFRUImQ7mQCwToNifZruBPfKvpeyHX9e9ohLL6UnMa+y0hlmLpF1cNFeMV WWJTyav+Q7/Mi5xiF1LnFyAIzzLD54n8kmcokvRqdjGwAYl3s8CmnZ4ehjlBu63bJfUm ixyhkNukOvmGPBPpBKZQQYy49BQvqD2cKCia+LmKBTo6Eodz6df4VMxFeJ9li1BOKm1a n+YQ== X-Gm-Message-State: AFqh2kpB5Lw3Q+uKg+ARigxTcPMan0xe/umSXOoZly+xLzDt5xdtdh8s vwC1dUuAglNCYbGV7V8fkTzBiA== X-Google-Smtp-Source: AMrXdXujCCZUHbCSkPFO5beUiAxXgapd3KKjcpRYj8jMaWKa+N0keNjtPqO4PIa+1M3aDsD2OlY3rg== X-Received: by 2002:a05:600c:600a:b0:3d1:ed41:57c0 with SMTP id az10-20020a05600c600a00b003d1ed4157c0mr40317094wmb.30.1672937006946; Thu, 05 Jan 2023 08:43:26 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org, alex.bennee@gmail.com Cc: David Hildenbrand , Sunil Muthuswamy , Aurelien Jarno , Michael Rolnik , Aleksandar Rikalo , Greg Kurz , Ilya Leoshkevich , Thomas Huth , qemu-ppc@nongnu.org, Laurent Vivier , Max Filippov , Yanan Wang , Marek Vasut , Stafford Horne , Peter Maydell , Daniel Henrique Barboza , Palmer Dabbelt , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Taylor Simpson , Marcel Apfelbaum , Alexandre Iooss , Chris Wulff , Richard Henderson , Eduardo Habkost , Song Gao , Mark Cave-Ayland , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Artyom Tarasenko , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Alistair Francis , "Edgar E. Iglesias" , Bastian Koppelmann , Jiaxun Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng , Mahmoud Mandour , David Gibson , Yoshinori Sato , Xiaojuan Yang , qemu-arm@nongnu.org Subject: [PATCH v2 12/21] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Thu, 5 Jan 2023 16:43:11 +0000 Message-Id: <20230105164320.2164095-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230105164320.2164095-1-alex.bennee@linaro.org> References: <20230105164320.2164095-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::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1672937628663100003 We unfortunately handle the checking of packet acknowledgement differently for user and softmmu modes. Abstract the user mode stuff behind gdb_got_immediate_ack with a stub for softmmu. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- gdbstub/internals.h | 15 +++++++++++++++ gdbstub/gdbstub.c | 10 ++-------- gdbstub/softmmu.c | 8 ++++++++ gdbstub/user.c | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 568b432220..8d260e2481 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -106,6 +106,21 @@ void gdb_memtohex(GString *buf, const uint8_t *mem, in= t len); void gdb_memtox(GString *buf, const char *mem, int len); void gdb_read_byte(uint8_t ch); =20 +/* + * Packet acknowledgement - we handle this slightly differently + * between user and softmmu mode, mainly to deal with the differences + * between the flexible chardev and the direct fd approaches. + * + * We currently don't support a negotiated QStartNoAckMode + */ + +/** + * gdb_got_immediate_ack() - check ok to continue + * + * Returns true to continue, false to re-transmit for user only, the + * softmmu stub always returns true. + */ +bool gdb_got_immediate_ack(void); /* utility helpers */ CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 4bf99783a6..76c24b7cb6 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -239,15 +239,9 @@ int gdb_put_packet_binary(const char *buf, int len, bo= ol dump) gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); =20 -#ifdef CONFIG_USER_ONLY - i =3D gdb_get_char(); - if (i < 0) - return -1; - if (i =3D=3D '+') + if (gdb_got_immediate_ack()) { break; -#else - break; -#endif + } } return 0; } diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index ee5daad0cf..534370081d 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -58,6 +58,14 @@ int gdb_get_cpu_index(CPUState *cpu) return cpu->cpu_index + 1; } =20 +/* + * We check the status of the last message in the chardev receive code + */ +bool gdb_got_immediate_ack(void) +{ + return true; +} + /* * GDB Connection management. For system emulation we do all of this * via our existing Chardev infrastructure which allows us to support diff --git a/gdbstub/user.c b/gdbstub/user.c index 4898f16c90..fa19ec5263 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -57,6 +57,25 @@ int gdb_get_char(void) return ch; } =20 +bool gdb_got_immediate_ack(void) +{ + int i; + + i =3D gdb_get_char(); + if (i < 0) { + /* no response, continue anyway */ + return true; + } + + if (i =3D=3D '+') { + /* received correctly, continue */ + return true; + } + + /* anything else, including '-' then try again */ + return false; +} + void gdb_put_buffer(const uint8_t *buf, int len) { int ret; --=20 2.34.1