From nobody Tue Feb 10 23:14:49 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=1677812530; cv=none; d=zohomail.com; s=zohoarc; b=Elr/gRev++qamn6tya0LOmsR+rkMlwjZ7NW2IbDFSwicQEXVtWmmdhJDu7ZpY5fpLhdMh9SZn79mOCbVAdSpcAaEwE5kPZP5Yh3J8B1UBBSidwPfm4oFnDxVd1CCf1JSezvQwcXL7zO6AT6HcSyUoSCFw5DFKnmeMrwNzAYUckQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812530; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=Nf2QnjnnP9cIk/R8ETMsfU95cHrN+Ab/pvVHx+w7xjGDGZAdirVjWHJGWv20f/SMjPbQ4tNHdFbJoshW1smTyHRxxvb4UR7Ai5fufzwFqdEnCdml+Q4DLvzfgwsVyaAf9MjdNC0ncOlCSD8UngF+MnA/oMMpbBB0dMfDOP83rJE= 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 1677812530862962.1026986787225; Thu, 2 Mar 2023 19:02:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcm-0007VA-Qt; Thu, 02 Mar 2023 21:58:24 -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 1pXvck-0007TV-3c for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvci-0001q5-4C for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304041plf.12 for ; Thu, 02 Mar 2023 18:58:19 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812298; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=tNoX1P+AvR2lfZ4RIfaACCRNfL9YBFi+v/pdn6GOD03pA1IIjwvKKxQ3iKrA80f4BF J5WwOV6pM5Kj9QTT70nAUfY0WH5Tc516ekin8mh3QCWHY8AdGRLQPQbg0G66Ex7bQ21J jM1AFPM+UO53i8BLwOHJKtJInML/xDmdZr/ziZ6OndFdJd+QDRPd1kl9nboE7sAhe0l8 igyzZV4XHK8Sn8WWVtKhscG9b/g2r+NYQhRxDrYj8RjGgfLvzWWhsxERBfsSLQ8epUxZ GAntPsDBp1XwW+/P98RL2NAy2PoxIXLLNnkFz7OeaBMm9Ifpunggak3jVwtx/t6mAX2v NUQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812298; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=pTkFutbMFcMGy6eYG4CJDOUKD1Ys3pijNvpMLWVIeHs03n5imELxuXnfqr9HRNdciw zaAx/H3DEIbnD1jbTAuAp9wk/rWSO1XMKhcWy+KGa1d+M0JYxqRCJz+urik4AiOrAdv9 NVygwydpvf7szQjzH/Go/WS2UCkZaJnrgqXMP4DsRGid0JjjHxEwyHA1jKGB1UMAg5gl xb4L+9Am3UtxE5sNZC7V6ZDGxE0wHfzTkBRegaDyBWSBmZ+y3cUt8nBIXTnMdq7PfOOK GRNJ0o3EiIaUJ//qS8DM1LvUehthACX9L1spsboIpnwdIqUU6gRA6qQM8P1ZlC8K/J7K 6Maw== X-Gm-Message-State: AO0yUKUYs2yivZjZFb6H+5Atj6+tIgReU+LSu9qTz7jZS1iUrtzox59R Rh8N925aTCIScAvSloscVO5+frypBcrv2iVX9+Q= X-Google-Smtp-Source: AK7set+C8yuP3ChTB87Wruq6OzVesocnlGQhYv0w6RYLjDNbbSHYohoXrAZGnFH4vk5AyC2y4+kucw== X-Received: by 2002:a17:902:e842:b0:19e:4173:38b3 with SMTP id t2-20020a170902e84200b0019e417338b3mr611153plg.46.1677812298579; Thu, 02 Mar 2023 18:58:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 13/29] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Thu, 2 Mar 2023 18:57:49 -0800 Message-Id: <20230303025805.625589-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: 1677812531680100005 From: Alex Benn=C3=A9e 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. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e Message-Id: <20230302190846.2593720-14-alex.bennee@linaro.org> --- 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 6bd6a05657..6534e373cb 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -110,6 +110,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 6907bdc99c..0476ee7039 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 6796761fd9..04e75449a2 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -55,6 +55,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 23b2e726f6..0c8cd028b1 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -54,6 +54,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