From patchwork Tue Feb 21 22:52:15 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: 655395 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp374151wrb; Tue, 21 Feb 2023 15:03:16 -0800 (PST) X-Google-Smtp-Source: AK7set+zsoWL0qhP0qt2uiZsgeQM2IvjPrBKqanan9ZJfPiD6FqqONTG+68psyutzIJd5DhXLY56 X-Received: by 2002:a05:622a:14cb:b0:3b9:bc8c:c1f8 with SMTP id u11-20020a05622a14cb00b003b9bc8cc1f8mr10604622qtx.3.1677020596773; Tue, 21 Feb 2023 15:03:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677020596; cv=none; d=google.com; s=arc-20160816; b=mkVcqVqsgYAuVlbhpHiPnXHsBb0vbqkbfglZQMCClZYdu8MezdPOkH0bUapErCt1Y7 hiU9d0jj69SceRGW9VybEpdGzJy8qxSzDBK0Bfu8uaNVVPCaItLXqh1YHuoDFcTQRtUt qY4hyV4eAG/accZmRH2J809cQgXCGycgrJ05AiTlUb1lLzyY8XvyLnnLUz3ibepytfd9 z3FUGOCaJCVWCt/BKjHKlqnoTZYPf9Mwx2UTmZAosm3wEvs+OJmni1LEzievuMCgk/nn OAHTbO7tqvz3JNMyTLUlKi/GR0zwExcn3V2fuhBdATokb93hlnzdDEaPUXOThZOtywJL XwQQ== 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=B3nout0t/bB9b3WOA6rURz0GJJBClZpY0Y1XPX42CvU=; b=gr0wIwZawvzVbTxsR5gE35VDEmzme9ic8lkA11i3N94fCfg2cofu0iOIO0j7mPsPYz ChhLri4eWwR2fsc/SU/rMZVO1MQJLJ+gY/aAw/OW15+YzNXDsewi2OKaEW8anjRJtFlB chfunWaYdS7gb531obKmzXY7IW704voAxrDHWSzPa+ZhsjcfH92qaVzQbVlVllxFwIH2 +e9JJjSY0B+Rg2Jo78qHBE9y/pOgBan7TcbzWcmXddg21zGorOTIgWQs2C08SgTHZgMP oF4epzJ/nrW3SzDCkBi1wYArx2vFw5tqz192fgmUrdGBvUEvMuNNM3wln+pRcgSSiW5C Gw5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RA1kyLu9; 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 w20-20020a05620a445400b0073b432b51a6si13261196qkp.276.2023.02.21.15.03.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 15:03:16 -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=RA1kyLu9; 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 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-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_Benn=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_Le_Goater?= , Eduardo Habkost , Bin Meng , Bastian Koppelmann , Palmer Dabbelt , Marcel Apfelbaum , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Rolnik , Aleksandar Rikalo , Paolo Bonzini , =?utf-8?q?Alex_Benn=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 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+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 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;