From patchwork Tue Mar 7 21:21:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 659858 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2606768wrb; Tue, 7 Mar 2023 13:25:49 -0800 (PST) X-Google-Smtp-Source: AK7set8v6rq+fViIdUzH3opU4KUoGG4a0yp7C7hE++dmgW3W5FWItNr1MNbe4GOLGhVQEgNPnF6C X-Received: by 2002:a05:622a:48d:b0:3c0:40c1:8408 with SMTP id p13-20020a05622a048d00b003c040c18408mr1218993qtx.63.1678224349257; Tue, 07 Mar 2023 13:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678224349; cv=none; d=google.com; s=arc-20160816; b=IjQX1nz0O5EobKSlrL8CUD+gp9q7UpGlR2WJDPmtwyFHmMPRHUPf/UZ2MRHlstg2gx BC5uiF7AhF/mdoD1u0TePDT9G2An+nErr6ziaSX7frMhXb34GC8yufjmE/9N3u1JufMF sjb7COBKSkjnSYz0OExGXuS9G0kmrvPwTvdTAqsRbYTM1Z5sFP88o5PfdJ4EdiHmUJBY mxlOy+Cm3r+U02LmMiHyLgxPBesum/9njcSC7fITNOXzmCUnhDrT00nYgOQHHC7+eaOg U1INEEb2SSD9ydOTenwrOItSB940kwuXXXpIPve7LDGxd5kyAVgcp5Ha/jwfNFr1hb5Z ELbw== 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=Y9uK4DB/9AQ/WafaUijeMaeKXdnxqc/WLSOPO7lES7c=; b=nmRiSxQdrIm0QREfgNdBVFBxgtkg2SjGLVnZiC/ABQwaDqp9z3Kub5AO2IqWB7xBly b1wnRcETX8UrZq1B6rld+gz/EeVmJ5tciJTXzZB0m4pNvlez297w35ZN+Yv8Eh2HvZhW EQvcolQRd1PyljQsW92l8pDe771FX3KAvGpEKuHeBV1mCsZM5DA8ocWAp0m6x45QrlRS Kvafkqh0NkZh9ApwIMK6lYzBcXGQZdz6MD+OFj83kKalMgIElFyx4AlipViugzjuLbGu 3xgWTUuFyVvBmDVBStSf4mZxJDsOtGj4j7dsk+/6xKSt24MnI1lLhl1Gg7KU3csNbxhZ iopQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bEX5EvQN; 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 194-20020a370acb000000b007061c7f865bsi9743291qkk.5.2023.03.07.13.25.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Mar 2023 13:25:49 -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=bEX5EvQN; 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 1pZeku-0001la-TK; Tue, 07 Mar 2023 16:21:57 -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 1pZekn-0001gg-Q8 for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:21:50 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZekl-00082z-1A for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:21:49 -0500 Received: by mail-wr1-x42e.google.com with SMTP id l25so13529203wrb.3 for ; Tue, 07 Mar 2023 13:21:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678224105; 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=Y9uK4DB/9AQ/WafaUijeMaeKXdnxqc/WLSOPO7lES7c=; b=bEX5EvQN/n/tCNul7fyazxvOEDcLkPethvwnYPrkPhsLs+GspPbZS+uL4ASe9T1dK+ 6YraEQ85P4EFzyCWnMY643z8PzQyTXauuqMI3z420K5fQi5PjzrtCybaq6dTzqbLo+cD 12s90gcQPhQxUN478URW64UJ8FfOJmtP13QbK0MA1nmdQ6X2vaWn3i3LolIBs2xXorAm y5JKa8I68GZAEPKUwj9N6/+kpGD9A/mvqcqiSjbFaaTeiVVgouoOXII3CFrAVrazG5iK xwwB2hMJdGaQ6w3kIh+3xpni48VkddIOaPHv+4/xl+UsyBB6LPk4D1NmvBzIhiKHpmW1 leyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678224105; 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=Y9uK4DB/9AQ/WafaUijeMaeKXdnxqc/WLSOPO7lES7c=; b=2SKNthLChe6QvX1o3u0XVw1XDNfVZtnJt4+v9WgkttQ1reSlW/Arbdx8Gze06bfTl0 QBVl/r95okumx7YCpEqp9YL8hJrv9CWA3tGj+LQ448kqr6PnQ5YZTVD2+JkCpCr0vYRR BB2dzYRlRzO0JjZocHDeRNrBbv19T4y8eU8hOmzQs9Pvqrho3EscfkAffEY18RGn177S L5FvOQ8GCSuJDB9bFuYaY+BxnLQB6gPUWk+47vvKyi8vQLUF5t5mldNthaPT4GptnGEa ST80rAL6HIctu58//XU3ZA0OXlt2bC8zmxh3ZgH+a7XgB7vs8oZ9H7CIOtWN89BLvrJX IjWg== X-Gm-Message-State: AO0yUKVS75OduWyS/uIq0K5uy48qsvgXX1I2R8JKOjEyo4lPRrE2HLVU 9yLuQDQ5TShLaCwTyTvX8zxQBw== X-Received: by 2002:a5d:6689:0:b0:2c9:993a:ec2a with SMTP id l9-20020a5d6689000000b002c9993aec2amr10772901wru.40.1678224105362; Tue, 07 Mar 2023 13:21:45 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id d1-20020a5d4f81000000b002c54e26bca5sm13400517wru.49.2023.03.07.13.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 13:21:44 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E16891FFC2; Tue, 7 Mar 2023 21:21:40 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 13/30] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Tue, 7 Mar 2023 21:21:22 +0000 Message-Id: <20230307212139.883112-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307212139.883112-1-alex.bennee@linaro.org> References: <20230307212139.883112-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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 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> Message-Id: <20230303025805.625589-14-richard.henderson@linaro.org> 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;