From patchwork Thu Jan 5 16:43:12 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: 639315 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp341071pvb; Thu, 5 Jan 2023 09:28:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtupYsX+JWbXJDVXzbLjispy9sG42yfsdeO0mQuGD4sOWOpTZBOo+VqflFvKBTFqXdJOGys X-Received: by 2002:a05:6214:127:b0:52a:3d34:f156 with SMTP id w7-20020a056214012700b0052a3d34f156mr69954079qvs.11.1672939717481; Thu, 05 Jan 2023 09:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672939717; cv=none; d=google.com; s=arc-20160816; b=K5xFr0iKu9u2X6uKBFABr4POtVYsGQpxXMSPVWoyLYdXy9VHDTn/6uBNeFv4Ef2LEI qVBjKpx6CirSF9fwms8SuMvALSFTP+s66UZDfj+yGI0U+HEHVIrtkOBiDY71Bj/yfvyY swbQ0NFKd4LBkueQ8l8/aFIBlVZBIe8vewY/H2KwyuhQ0Xlwbemt1Essc2Bi5q+GC7XI Ge694e4wqEcluK2WS2P7L/tb28WhjdW0ePUULCeIBePu5RSquXjz2g98wefhDocFwYun +QMFFX1CIWeQynLppgtZDOrpKcmKuTXHvXwTLpgt1ddU5GZYdu2VtO7UNbPo/JVH/zRP oRFA== 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=tQSx+09nLzhSfINVlmlSsVlVWwh5VHah16/HRlU/6+s=; b=oBLwp7VjEMr/AJf25zjbMgC5wRYnSecTHBAPHVfgR5bStSm1NDB27kRDvSyZ9+T/pk mf+KCVRynpb3PUIppV1nkQjkY5SQonNYsNuZQUjXaNKzPDqxVNzqCwUXWeVcgyaf518Z Y6j0MAtwYqyQJD69hmfXieLB4iOvwjQ+DAI/pz8Qs2lR4mzmMovC995sFrYcm66+K4pK F+O/sPzNKx6XVkyGVbENLf3O866newivMvvuCgE8m7sByDXjg12DB3/F3YVp1pMvb2wU M4kF8r0i1hj5vhYgIy7yrzxdQMlQ9BvvXKi0uLM2ecU/wCgxcbz1bo+ClTRw5PLRayyK tJaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mZjwh923; 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 jo27-20020a056214501b00b004796ba3f0cbsi19249054qvb.136.2023.01.05.09.28.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 09:28:37 -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=mZjwh923; 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 1pDTLT-0007bY-Vh; Thu, 05 Jan 2023 11:44:00 -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 1pDTLH-0007EC-Nz for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:49 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTKy-000719-Rw for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:47 -0500 Received: by mail-wm1-x32e.google.com with SMTP id ay40so28484944wmb.2 for ; Thu, 05 Jan 2023 08:43:28 -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=tQSx+09nLzhSfINVlmlSsVlVWwh5VHah16/HRlU/6+s=; b=mZjwh923HJ3Yck8Q1EvJXmtWKTzqbJNYrjHfnFnQgw9sUdysbvZMXi+Jo3vsfJLF7R 5OL65eclnzT1hQYPVtegKq+w3bsygwnUbMDtKAZf2AMk/ScYaTzUu271+SLTBSnAi0RW 6+R/caZ/IPuwLU1czAc0pL4hMvofLWGepJb0h0I+tQJa2rwxUUpE4TEZ/79Fah0uV29R y2GnHwKXZI8cPfZ8x6PPY1Hj+wOLfhhPtW5Tz6VQ1XFieON92rZgnKhkL6ULEMnvpE5I xGsctN1NyXpUSikAiipV8dcbLH4aCtQgZtNBJLAdylF8eaZ+ul0SxF900uvARj5D+cD4 +j0A== 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=tQSx+09nLzhSfINVlmlSsVlVWwh5VHah16/HRlU/6+s=; b=TAx2dsPSRKDC/1/wot8QknaFM+dOkBGj/dQdxEHCpqErgGUtDcEmVOecvzZScaf2BE UHz3Tn4nbOSEQsUlzuKb3B6oiyI9QnZZgye8yGxHWeEtzpJr0PqBgBIHoWua3zaOUdui m/GbPtUSGi0wP3Rk3hXyc4PsXyvWKhcGJemxv3cXHeYvKy24epe1aygq5psapZt7pIsD w1trQD/Y7+pJudrB9v8mgGV2FpK9XitvS/2q3XaaSZdpPp66fE8CvQkQK1r2rrJHykDw BWvj53YOPaUH1k6h9Roc0X3q8APGslKv18/CaUssP7+HWVTRaTJRjJ6k7gK77w0aHOov gaag== X-Gm-Message-State: AFqh2kqHevuiDxiCOI0B9XdmQh0dxYCEMRmVZ/X6NEYD80tU6254q8JW w/roBjzZW8Q7qM1iLhZNHkt4YA== X-Received: by 2002:a05:600c:4a9b:b0:3d1:dc6f:b1a4 with SMTP id b27-20020a05600c4a9b00b003d1dc6fb1a4mr45015263wmp.5.1672937007331; Thu, 05 Jan 2023 08:43:27 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id m18-20020a05600c4f5200b003c71358a42dsm3993488wmq.18.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 3F2B81FFC5; 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 13/21] gdbstub: specialise handle_query_attached Date: Thu, 5 Jan 2023 16:43:12 +0000 Message-Id: <20230105164320.2164095-14-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::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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 In both user and softmmu cases we are just replying with a constant. If the linker is paying attention it may even be able to sort optimise the call. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- gdbstub/internals.h | 4 +++- gdbstub/gdbstub.c | 15 ++------------- gdbstub/softmmu.c | 5 +++++ gdbstub/user.c | 5 +++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 8d260e2481..646d2c4e82 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -150,7 +150,7 @@ int gdb_continue_partial(char *newstates); void gdb_put_buffer(const uint8_t *buf, int len); /* - * Command handlers - either softmmu or user only + * Command handlers - either specialised or softmmu or user only */ void gdb_init_gdbserver_state(void); @@ -179,6 +179,8 @@ void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ +void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 76c24b7cb6..0d90685c72 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -46,12 +46,6 @@ #include "internals.h" -#ifdef CONFIG_USER_ONLY -#define GDB_ATTACHED "0" -#else -#define GDB_ATTACHED "1" -#endif - #ifndef CONFIG_USER_ONLY static int phy_memory_mode; #endif @@ -1672,11 +1666,6 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) gdbserver_state.str_buf->len, true); } -static void handle_query_attached(GArray *params, void *user_ctx) -{ - gdb_put_packet(GDB_ATTACHED); -} - static void handle_query_qemu_supported(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "sstepbits;sstep"); @@ -1786,12 +1775,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { }, #endif { - .handler = handle_query_attached, + .handler = gdb_handle_query_attached, .cmd = "Attached:", .cmd_startswith = 1 }, { - .handler = handle_query_attached, + .handler = gdb_handle_query_attached, .cmd = "Attached", }, { diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 534370081d..19fcb3be7d 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -442,6 +442,11 @@ void gdb_handle_query_rcmd(GArray *params, void *user_ctx) * Execution state helpers */ +void gdb_handle_query_attached(GArray *params, void *user_ctx) +{ + gdb_put_packet("1"); +} + void gdb_continue(void) { if (!runstate_needs_reset()) { diff --git a/gdbstub/user.c b/gdbstub/user.c index fa19ec5263..a668b16952 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -343,6 +343,11 @@ void gdbserver_fork(CPUState *cpu) * Execution state helpers */ +void gdb_handle_query_attached(GArray *params, void *user_ctx) +{ + gdb_put_packet("0"); +} + void gdb_continue(void) { gdbserver_user_state.running_state = 1;