From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E62EC677F1 for ; Tue, 21 Feb 2023 23:03:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUbeS-0006aO-M4; Tue, 21 Feb 2023 18:02: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 1pUbe7-0006No-9W for qemu-devel@nongnu.org; Tue, 21 Feb 2023 18:02:08 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUbe2-0006D1-Mq for qemu-devel@nongnu.org; Tue, 21 Feb 2023 18:02:01 -0500 Received: by mail-wr1-x433.google.com with SMTP id v3so5971194wrp.2 for ; Tue, 21 Feb 2023 15:01:58 -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=B3nout0t/bB9b3WOA6rURz0GJJBClZpY0Y1XPX42CvU=; b=RA1kyLu9oFH+P4+AwgJstTyE42cB4cL+vo3UoZiuLw8V91KTS+gOeUIZEPSBOwxTDu II0FQMmY0t+pt+qIMptmOx8Wx9hDxw4ygfc0aEzk9QoNl3eW4nfuqbWzMKQE8+T0vxOY xruV7kwMij7B0fOlBIlhx9uSvSkFtH/K59jtkJVHN2NWmombQKjhBq6hwOta+gnwPRNQ /WGO7yn76SfTEh6xNttjrIBAm7ggyOBQgeilE5/op/CdE2/eCj9i+5Skc2t2bDTtVe4e fFLD0Qhxx4XN/HuyZv48CjcyYTGKLp/3zRS9e00rCz1BiJRf6JfYaBub7Pgr6QRmQNDU ghAA== 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=B3nout0t/bB9b3WOA6rURz0GJJBClZpY0Y1XPX42CvU=; b=zRs84T2AJ3F6xIKB0lydZ7rLhCl5JViYbNOUbw5fUVDtNDOuVWM2lyYegmq9Vaif5N dxm14MbGIocMW6XhL1EPZjAEOSpLwKAOXLdReJpBm/WSi94KtMVoovGcbb5HkCtOQ91f Cd15QONKTHRjMJTiEHN12swCRtGkBDO2Sdx5s4GPdaR0PQwaPZc88eAX/mXWtXQ9UQTH Phwml89mUIPDor6PoIiS9h6SOQwT6jwAV/dAlcD7hfocBoJx3f1xSOTg3oYFP85F8Km3 jp6AGgOJN3vh5Ej2xUI05XpLfdAhlqYxa4MiB886XOo0bLQEdhHntn4ykxvAiULlczYw /biQ== X-Gm-Message-State: AO0yUKUNVnq14Hj9GuYv6XVQLu5Lo1adaLvTSTkSVWRp3KNr9SEaAsWY KFMxmwNDW7kHlk08Vo7+IZImgQ== X-Google-Smtp-Source: AK7set8zG1yCoqKGQfmjNL5uVl4SWm6wBWKQjWlB2OawZ64Iu0Q7Fk52y3JxXv7+GcVzTkjB8Ljdtw== X-Received: by 2002:a05:6000:c1:b0:2c5:5308:859c with SMTP id q1-20020a05600000c100b002c55308859cmr3857811wrx.18.1677020516626; Tue, 21 Feb 2023 15:01:56 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n5-20020adffe05000000b002c5539171d1sm8289828wrr.41.2023.02.21.15.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 15:01:56 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F39C51FFC2; Tue, 21 Feb 2023 22:52:28 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Yoshinori Sato , nicolas.eder@lauterbach.com, Stafford Horne , Daniel Henrique Barboza , Mahmoud Mandour , Taylor Simpson , mads@ynddal.dk, Marek Vasut , Artyom Tarasenko , Alistair Francis , qemu-ppc@nongnu.org, Yanan Wang , Sunil Muthuswamy , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Eduardo Habkost , Bin Meng , Bastian Koppelmann , Palmer Dabbelt , Marcel Apfelbaum , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Rolnik , Aleksandar Rikalo , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno , Xiaojuan Yang , Richard Henderson , Peter Maydell , Alexandre Iooss , Chris Wulff , Jiaxun Yang , David Gibson , "Edgar E. Iglesias" , Greg Kurz , David Hildenbrand , Song Gao , Ilya Leoshkevich , Max Filippov , Mark Cave-Ayland Subject: [PATCH v3 12/24] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Tue, 21 Feb 2023 22:52:15 +0000 Message-Id: <20230221225227.3735319-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221225227.3735319-1-alex.bennee@linaro.org> References: <20230221225227.3735319-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.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=unavailable 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 a3dd629ee8..3912d0de38 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -108,6 +108,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 79674b8bea..0232e62ea4 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 1c9e070e57..33a0701cea 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; -- 2.39.1