From patchwork Fri Mar 3 02:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658467 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226619wrb; Thu, 2 Mar 2023 19:02:10 -0800 (PST) X-Google-Smtp-Source: AK7set80lZj7CeVSXB80/NwpFaoHZ+q5Wgs2oAdKh3W4/LZP51SVa2CFvYlk97WO/o/aEYlk5mrl X-Received: by 2002:a05:622a:151:b0:3b9:e3fc:5689 with SMTP id v17-20020a05622a015100b003b9e3fc5689mr693804qtw.58.1677812530394; Thu, 02 Mar 2023 19:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812530; cv=none; d=google.com; s=arc-20160816; b=Lxc3TfXa6VPzU/F9KI8ZawAsbMgNUvedL4rf4L4K8dw7K0ZxCri4y7TC4EdhOd1e6t 2w4cI5on3aw51fK0N9l/Ma2nUTZmwrWTOQ16ZqudqtPWDAF5iVlfWAUVrQX4lki6XDxr 1kYznGTScB1F430Fs6fP4OnmZ5DsbkCmM9HYy/G3AXFVSZKCrQOmDOfZO3yoxzXAytd5 yuNE200PPxtXGp1WkR/daUaogODzvfTj2zpnu7SXrboVSzFlQgh7CJqkmWYYqaLmoVI2 DDKL4cBthp1rFCCE/w1rMoVN0fpvsnXm439z1nsv9jlV8otfQjNZWoiKy4iGxCo+WJFf dmMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=i8K3kd1epFLcngP3OVVEwMxdfQQsYRllTEo6D15ORfYX5hAmpOPw98PlA3/ZBmpBD/ TTULjMfiQDYQ9CNm6Ia/RpVwRtz5Foc8cftJh65LoRJ6SCMHFzVHvxp+iL4f+2r3gd5i EPSAWd0ebLFwlRXQazTVmlhYjeR+EUBe0yWGXdwyahV1OY6f4L2HDl4aTPGKYAA2s3lM //TY2pFlpMYFm84UQfbhnR4smVh4WWzjezNIMC4Q6zCGSst8SnqEhtVAAUCbZDcxhsO/ dRgkuYLDtDViG7OseNoOIQvHOA2nQxV8yf0D9dGGK+SfswubAJ3Wm6UfIzgCH8NlxvxX wsWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNoX1P+A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m6-20020a05620a290600b0071d2670ade9si1078921qkp.28.2023.03.02.19.02.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNoX1P+A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée 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é Signed-off-by: Alex Bennée 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, int len); void gdb_memtox(GString *buf, const char *mem, int len); void gdb_read_byte(uint8_t ch); +/* + * 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, bool dump) gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); -#ifdef CONFIG_USER_ONLY - i = gdb_get_char(); - if (i < 0) - return -1; - if (i == '+') + 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; } +/* + * 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; } +bool gdb_got_immediate_ack(void) +{ + int i; + + i = gdb_get_char(); + if (i < 0) { + /* no response, continue anyway */ + return true; + } + + if (i == '+') { + /* 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;