From patchwork Thu Jan 5 16:43:11 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: 639279 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp324347pvb; Thu, 5 Jan 2023 08:53:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXvlTbpL8OiY0bJf3EFNW6iirRHh0g/TOO3VB7Wa1fmBwyPlkLT7APE30jIQiD+3dM7FJDGG X-Received: by 2002:a05:6214:5713:b0:4e8:178d:7ec7 with SMTP id lt19-20020a056214571300b004e8178d7ec7mr17106950qvb.26.1672937626261; Thu, 05 Jan 2023 08:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672937626; cv=none; d=google.com; s=arc-20160816; b=eYIMpqKKtGu96Uvuet7O4hIa3naqqW0lMXZr/dXY1VP7KEDxA5yQbqcwPXlVt/Gvoi lWWFSyOzklaC993Zc07lqxcLYm9PzZhiWbuatrxQbPgkk26R7Qi+SP2cN932AdNNtTux D9sDkunzjAQuuaFBsV82Oq0QA2VUgG0Ulodv+RCvirnU1rVumNMCORuEds13X47jEew+ f6ooduCVT1XArphDZCroofHtyAXMSzSIIR7cZW/z9vXTbw1OYxNpIDXMeYLevvL70ui2 s4j8VNZicvQ+QiX7KphjeXtqJqLJKzyKofCvIm1iwHmhPwLiLZgymdUPz/uRMF4jU5u1 b1ng== 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=nQQTwgIF254LM7i6IkejsXBJ/YrsdmrSipPbKMfkzUs=; b=EK8ezneZf7zf9ukjqr0utRAl/jLcVj6PHKLAPLTUJg563d8bX2SCgfPtZ9/PohMu8J IlQbVwQmSkwGeuL4D+rcwwojtyPbrKK7s5ghngsyEn3Y4VQ8xIe1IQhrpQ6Q8aVFEEb8 bdSQ+yUg/D+XdLg5DXB8DVIvTxmfrUebMve1Mejyrfsi3/hZXnZ1mXCe6dBV4zuLNYNA fCsiigCgvAntnVhy59caBTLcYDfxQEGEIe7NYfuGoCM2iDuCGFT7paTePpgI7RZGlRYC 2f7ypDdgcLgjR5CONR2r2rjr5UTxOYIVqbzvQnbjXqmHXY6BTX6Lnc5wxc6mgCPWcz0v ouOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tKk141vR; 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 j23-20020a37ef17000000b006fabaf6b03bsi18553964qkk.676.2023.01.05.08.53.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 08:53:46 -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=tKk141vR; 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 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) 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-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) 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) From: =?utf-8?q?Alex_Benn=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_Benn=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_Le_?= =?utf-8?q?Goater?= , 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_Mathieu-Daud?= =?utf-8?q?=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 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+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. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé 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, 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 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, 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 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; } +/* + * 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; } +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;