From patchwork Thu Mar 2 19:08:33 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: 658142 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp67293wrb; Thu, 2 Mar 2023 11:16:00 -0800 (PST) X-Google-Smtp-Source: AK7set8r3VfcA2ePjPwHti3IpAYOjvai3qEZBtn1PxHRCIok7zYd1EoggZ2TNIyY9hbJAox+pECG X-Received: by 2002:ac8:5dd1:0:b0:3bf:daae:7ee3 with SMTP id e17-20020ac85dd1000000b003bfdaae7ee3mr18667462qtx.53.1677784559870; Thu, 02 Mar 2023 11:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677784559; cv=none; d=google.com; s=arc-20160816; b=DvTTCpVVmzY/DgZ570FjZPMztPubJh86R9Y47ikcxSvhSjJgxEBR5iv7/kqM0Yc45X 3bsBZMTCnW0T+Nsm6WnnAxbaXRwJ5yfEmGcPDwOIt9X9EpcOY3+DViT8Ed/eQI91Giek AD3fIMT6HuC9mkJuj9sIkkj9rp76Sk81WG2Ugp7+3MkYffWcv3Rc8T9DgW0Tdc8WXOmD TNUIJTd3abTGWG1Lfq4D+H24PHMQTrmiKNuh12pCHsNS2l2U1QtoO2I2UNOsYIBR2Hem 0WgXNo5ya0DS/KLVFv3xKNDi/cx9HstyuT4Ex5vl8hjfE/L4KyCglY0PzOZjFSWpSRZy x+Qw== 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=AkhUerl9HMLvEw3fit+pxInPqsKmIKwDU7RamZamxD0=; b=nAHoMgE0O/AxppKbMPEcDogz4o4PlKq/U5t+j94iU5AbhpHKKqXtzk/gX1rslv1D9y Ux0ae5PjJua2YMkFcpDrSfdW8U1JzWSCIl9kCjeuQnzadGFkL44vQH3vNnp0gn1FqlHy qat+UisdA9pw02QwnrrgEbMuDkPnox/X1sLmhY8r95Hri1lNtIVuGfJfLzqs0552cgSz ibwPg8XXcMXNUCWb9a6tmES02CWnmZWMkcf1Do2OV5Gj3UYVmwN9PMft/vXxoy0wcnpb u8s2l1IGv5xq6jsmZM+JWvPNQ9WQ17QBVXEcB17+Y0dr2fHErmXntAlh1Mv7GucN0opi XkZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QkLv0+eO; 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 d13-20020ac85acd000000b003b9ed29d2b6si230605qtd.563.2023.03.02.11.15.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 11:15:59 -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=QkLv0+eO; 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 1pXoNq-0006Zo-5U; Thu, 02 Mar 2023 14:14:30 -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 1pXoNo-0006Wg-7N for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:28 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNi-0000je-AD for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:24 -0500 Received: by mail-wm1-x32c.google.com with SMTP id az36so305636wmb.1 for ; Thu, 02 Mar 2023 11:14:21 -0800 (PST) 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=AkhUerl9HMLvEw3fit+pxInPqsKmIKwDU7RamZamxD0=; b=QkLv0+eOtAYCwCmJedftemEobTPSKKWvlpHZPjXtS7Xt5Lnp+ADQ5od30gQc1GVZw2 wsXL89hlobRtsFSDDpyOztNZudx7fTiJ7s7lbpCIkVIk6/fxQGrYlnnzUpEidVPeX2Jv D5Xqc6dl09R6aPu3+rQGcFtfcdK0ZpCTZsxvl5qIbu3x/rCY1NVzOaXV/B4x4un/Uzye OKzcdm1s1OZcVQ1j4lIjJTI1RwAsvHj5WXgNI5n+Zx7eqqY2pMAQqztn6hVnjcjXwinc Cbpwkx6mo7EfIG9yf4QtWIGku5RUKJDxCpSbRNTFK2ncpyW7HUOdwcKfxby6v0V+cMGo o83w== 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=AkhUerl9HMLvEw3fit+pxInPqsKmIKwDU7RamZamxD0=; b=XhQawkGkaitlf/SaK8hhwLJNxpoE6885z+TV038YA9Ri/fKG4SUi60bNy6AacEpTrU /1WHIva/IWD6EkOsSQSLG+G1pZExfsCDwlqEpZ0l1/IXaEvziLcaYp/Bt3dRWdXI7D85 dyrUia6toeJ+B9ZkW0cUuWDAfihh2v5LHzVtU3h5gXNMeoiaYZHv3g3KNuRiOm4+fEcn yqQ8owf7QK2JQfHLi3PlnbdBIYOFUYGo6G0cymoyXCJWDREubWqHqBqbgdEL7v4Wc/aC 87dCCnJ6MB9O+knFzViXRir+osQOitZVMsK2t5pEb0yl4BLMY/Nq5re5ZV/RxZYTNyD8 DyEA== X-Gm-Message-State: AO0yUKUUlDHAzx1DR9jLJJjgqpM3eIwxJuA0Q5BYLVWL8mPEe5IDpdsW 0kSDEswJyojg22K7+CVOXfQSmw== X-Received: by 2002:a05:600c:755:b0:3ea:d620:57a0 with SMTP id j21-20020a05600c075500b003ead62057a0mr8022303wmn.3.1677784460520; Thu, 02 Mar 2023 11:14:20 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p8-20020a05600c2e8800b003e2066a6339sm404744wmn.5.2023.03.02.11.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:20 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 679A51FFC2; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Palmer Dabbelt , Laurent Vivier , nicolas.eder@lauterbach.com, Ilya Leoshkevich , kvm@vger.kernel.org, "Edgar E. Iglesias" , David Gibson , Max Filippov , Sunil Muthuswamy , qemu-s390x@nongnu.org, Stafford Horne , Bin Meng , Marek Vasut , Greg Kurz , Song Gao , Aleksandar Rikalo , Liu Zhiwei , Alistair Francis , Chris Wulff , qemu-riscv@nongnu.org, Michael Rolnik , qemu-arm@nongnu.org, Cleber Rosa , Artyom Tarasenko , Marcel Apfelbaum , Eduardo Habkost , Yoshinori Sato , Alexandre Iooss , Daniel Henrique Barboza , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , mads@ynddal.dk, Mark Cave-Ayland , qemu-ppc@nongnu.org, Richard Henderson , John Snow , Xiaojuan Yang , Thomas Huth , Paolo Bonzini , Mahmoud Mandour , Aurelien Jarno , Bastian Koppelmann , Yanan Wang , David Hildenbrand , Taylor Simpson , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v4 13/26] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Thu, 2 Mar 2023 19:08:33 +0000 Message-Id: <20230302190846.2593720-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302190846.2593720-1-alex.bennee@linaro.org> References: <20230302190846.2593720-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.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 --- 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;