From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784331; cv=none; d=zohomail.com; s=zohoarc; b=Qszy9JPqx4GXf/WLQ/RbSghugtE2s/yRA48tc3X63nh8GFqqZG5c+muAfzkRXG6aHluiZo5jEjDIJpn9mZVu1uQ/mElcb2+jbYmBiCTLLeFR6PCU6GqJ3J5BwlAE4Mk+PKvVdFQmPWGhRMyI47AYb/sAO7twWBEbdlkh2H29Vbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784331; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D+nP4isH1Rrpm6PqB1T+HNbs6D4vVCidZRr16ayiLa8=; b=De1oUwpNzKGHJM8Grx1UayRnaw5OVZRSf80YSFD9Vic2QY63sdIjvkRBitYXvSzl03wgz5nlMNP8o59f4ltEGVO/pz+vk0PKnAp+nkCzZBCea3wOYQzNEH8fz4gjPuMLGAelFP6Cvkv+iwPVOMaOxUzTehBozk13lHJOU5Bz2yo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784331573778.3942526589956; Thu, 2 Mar 2023 11:12:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIQ-0007G0-9Z; Thu, 02 Mar 2023 14:08:54 -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 1pXoIO-0007FI-Sl for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:08:52 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIL-0004UR-FK for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:08:52 -0500 Received: by mail-wr1-x430.google.com with SMTP id r18so157795wrx.1 for ; Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t16-20020a05600001d000b002c558869934sm132379wrx.81.2023.03.02.11.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:47 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id ADBDB1FFB8; Thu, 2 Mar 2023 19:08:46 +0000 (GMT) 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=D+nP4isH1Rrpm6PqB1T+HNbs6D4vVCidZRr16ayiLa8=; b=C8aZU5/+SOu04bkd57XceuBmV7tZOD+f1/mF7iOMVtDvuDNscWG36vSMh9/QEXfPid /IY3FeU3A5JOhNMGE0wMEbdjydW1l82q/Sa4HYhjfbBlOxjY7t1KKnPZwr6aksBFlnvs luzv4y4KuE/Ldlt+ZSpgu7eRI9RiWJWQhA5UoogKN8ZMfYG6DaG3tdC0m7df+U96SdET ywPwEa1b7fvO41l9nOFINl8fAq9jlyaWai3/n8okkGmfi9G3B33cqzPDXwVsh/N/Post xv/NFiTil6yZPXCWn1+YvSRmNLaaCG2li3J1WX2FF05ooIezAcbgstJzstRMSawW/jQW Y0KA== 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=D+nP4isH1Rrpm6PqB1T+HNbs6D4vVCidZRr16ayiLa8=; b=8El6Wpx29GrPNKKoD7CrSMuscbzsTyqTxWItWtMRhpdzDuPoT+VpvdixylhGKRi9Nh N1/exuREzgUYxrTQGQ+Z61rmENdq0ExC6u8ns7G0tZotApfjbwPWeNBVHAqTJOb+QHbp 6U/VbL+SYLJS6YJmSsczjHzjRz6hqlxxcPOc4wjQ8m1jOzzMHc52gR10+R4RdNnP/Bnd yVxaNktAxt2WQzZEzZIryA2DOjRFM2FvO/vyg12ozgtUEwAaBjhxruzovk8AFSUCy2cF 388a0pu6I9edmcfU/idQMsjc+E/vsWq6Kwol+Io3s67CrKaH7o2AdUMrLaFyrSBn5cI1 2eBw== X-Gm-Message-State: AO0yUKXgJcH+wcPF2GfMr3SFizsHmhR4TuQt4dyg9G6g4WfdiG0S0O++ YhelHMSowubAjxUzbmpiBAP/Rw== X-Google-Smtp-Source: AK7set+ta6+3ud/gF0jnyTLJkaZ5IY9mbR9X5ZMEfl1uB1UaNOrlAHGNvqkoHumDtiNkldmP643lkg== X-Received: by 2002:a5d:4d52:0:b0:2ca:8ae5:ea2 with SMTP id a18-20020a5d4d52000000b002ca8ae50ea2mr8364567wru.40.1677784127722; Thu, 02 Mar 2023 11:08:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= , Bin Meng Subject: [PATCH v4 01/26] gdbstub/internals.h: clean up include guard Date: Thu, 2 Mar 2023 19:08:21 +0000 Message-Id: <20230302190846.2593720-2-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784332681100003 Use something more specific to avoid name clashes. Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b23999f951..7df0e11c47 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -6,8 +6,8 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ =20 -#ifndef _INTERNALS_H_ -#define _INTERNALS_H_ +#ifndef GDBSTUB_INTERNALS_H +#define GDBSTUB_INTERNALS_H =20 #include "exec/cpu-common.h" =20 @@ -16,4 +16,4 @@ int gdb_breakpoint_insert(CPUState *cs, int type, vaddr a= ddr, vaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); void gdb_breakpoint_remove_all(CPUState *cs); =20 -#endif /* _INTERNALS_H_ */ +#endif /* GDBSTUB_INTERNALS_H */ --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784199; cv=none; d=zohomail.com; s=zohoarc; b=hHxttPlOL5U0Clp3OKCRY9CnhyXzEANraIlR66/Kc4kzTpAc7UzVuxEtUgPpg03Y1zhtPtFtQrJ52Od906fOw9wOJ78oDb7WYUkpx9+KJQumPw7uDPYOR3Tzbdrp0/knE0F8EnUNS0UV62qwZ7emjaUsARSHKV7EFmZzriKwsN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784199; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Si6MP0w0kGRFapnvD61w58cvDvKawe1zAULmS0tNy6s=; b=a/MmlIFOynkEj2X0nKnIttQtCJv0bRBOLrMFw8KecWrsCrMIQBGqQueQ5KeAj0mYreO/b25HdcpkpRVxkfWuRm1cOH03jIu2fBNsib8+WUQ6wzwXSMxJylY5Lc3DnLLDiFhhHUwN1zlPiZkW5QJUo0gB6tW1pBp2VsMhj5/jyRU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784199133511.8652761802149; Thu, 2 Mar 2023 11:09:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIU-0007LB-QH; Thu, 02 Mar 2023 14:08:58 -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 1pXoIR-0007Hw-UG for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:08:55 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIL-0004Uk-ML for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:08:55 -0500 Received: by mail-wm1-x32f.google.com with SMTP id j3so294411wms.2 for ; Thu, 02 Mar 2023 11:08:49 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h17-20020a05600c351100b003e4326a6d53sm4241899wmq.35.2023.03.02.11.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:47 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C8E001FFBA; Thu, 2 Mar 2023 19:08:46 +0000 (GMT) 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=Si6MP0w0kGRFapnvD61w58cvDvKawe1zAULmS0tNy6s=; b=g6Bnc2Hhm4jlpLwn6MTGYvT0xExBpOEV0SSTTKBA3gzEuOFGPVcc6MQZZ2Qg5Y3Rhl uDaYgpifyMoONDe6/I7pmdkoxUYs64GhJXZdr3nA7YFEyBrFLHVBKQKLe9dJ7KSIgFJf 0aqKSKvQnwR2H+Tpujvx+C3fnvTOrMjINEnjEpYihwOOXFoWIpoMkqVnOqvWRejErRTW GM5qoWA5kDDGH4lAUk2XkrcTdXT0xtJdyOoqeRR6zuQWXDX8GXzcfDzu7hgP3bsagFO7 b7FKmGJJFUiIY+QMXHabflo3vobE1Sb/V6y5BfNCJUboAdZZUywWWRrSXuy5CWPAvF7d 9WBg== 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=Si6MP0w0kGRFapnvD61w58cvDvKawe1zAULmS0tNy6s=; b=xdrSb+4kwN8FcZhEBBEhutyRkDtKB930IPw5LQZc+LCWtz5TN2CrRmokqvmYqyTbGV TAdT9JqK0Co+QdMK654XrAMOkr11qL75chCcE/ustC/jbPnfAak9BH1keEWYa18pfHi9 1dL+DRLP4fjbEKcvTSTK406xodGMnlIV8XCc7HsAvsA55qujCmXc8ff4NfjyZcKjEmBF HvvIl/Jpk+R/Ws6fZx+tvIqFypliWBOWDm/DFy/c3A27wUfR/AX6FvqvyikPYAuU3wA6 Q4zxrT7U5kKzrxSbVmVs2YAo9I1IdR+y59yb+C1imK4KCfX+WRtN2+n5+FevUlNcr7+9 3CmA== X-Gm-Message-State: AO0yUKUGC7e+v8hStZTyXd7rFqzkygy2Xbni6P8222xykLWnUtffyCvR SA72Nw76CFerIfmOtXG9DmQV+A== X-Google-Smtp-Source: AK7set9eJprV0p7JRLIRr/68JuEcV3uLTkeyYm96s+M5+q4UW2E6CjnTkANW5zuqIUHzGwOOmK8ltw== X-Received: by 2002:a05:600c:3b11:b0:3e5:4fb9:ea60 with SMTP id m17-20020a05600c3b1100b003e54fb9ea60mr2376003wms.9.1677784127936; Thu, 02 Mar 2023 11:08:47 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 02/26] gdbstub: fix-up copyright and license files Date: Thu, 2 Mar 2023 19:08:22 +0000 Message-Id: <20230302190846.2593720-3-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784201577100001 When I started splitting gdbstub apart I was a little too boilerplate with my file headers. Fix up to carry over Fabrice's copyright and the LGPL license header. Fixes: ae7467b1ac (gdbstub: move breakpoint logic to accel ops) Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- gdbstub/softmmu.c | 3 ++- gdbstub/user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 129575e510..05db6f8a9f 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -4,9 +4,10 @@ * Debug integration depends on support from the individual * accelerators so most of this involves calling the ops helpers. * + * Copyright (c) 2003-2005 Fabrice Bellard * Copyright (c) 2022 Linaro Ltd * - * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-License-Identifier: LGPL-2.0+ */ =20 #include "qemu/osdep.h" diff --git a/gdbstub/user.c b/gdbstub/user.c index 484bd8f461..09a18fb23b 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -3,9 +3,10 @@ * * We know for user-mode we are using TCG so we can call stuff directly. * + * Copyright (c) 2003-2005 Fabrice Bellard * Copyright (c) 2022 Linaro Ltd * - * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-License-Identifier: LGPL-2.0+ */ =20 #include "qemu/osdep.h" --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784252; cv=none; d=zohomail.com; s=zohoarc; b=d2olzLTjEvF6pBkT7/HV41JZ3ySEDXOl34R4NNikubHljYG3oPe7CDaQljIfGAWkcv7C7mveWXQbcmTsiYFxf1OB7Ym00MQpAsV7qBOj+ZoXcXDkAn4IV33V9M4mwwa3eVpyhDAZeR+UFA8ZevM9mnU7xqALM+wQ3IL+yh0PKvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784252; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vpN9HZmBiUU2swb5foi3aRB2Xz7IiTbLS73Qjjs5Gno=; b=ij+WMREgdfIzlZ8TRtU5Sv3Hf8iqc2PFqPu7hmsRWMK7kdhdaBxSrak5ncarbsGcyPxZ0YzX4qyM+6wi/vW9W9UJGmJS/JsQX0Fv6YOiSx+fgaygiprf/0YRrjS/GE4fuZ7QFxpMy7RSf2ggdCamWFJaDSCwvKOPVJFDzBvXWyk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784252119572.6334762442779; Thu, 2 Mar 2023 11:10:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIV-0007NE-SM; Thu, 02 Mar 2023 14:08:59 -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 1pXoIT-0007KI-RS for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:08:57 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIM-0004VH-9P for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:08:57 -0500 Received: by mail-wr1-x429.google.com with SMTP id g3so132621wri.6 for ; Thu, 02 Mar 2023 11:08:49 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x8-20020a1c7c08000000b003eb2e33f327sm6700116wmc.2.2023.03.02.11.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:47 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E33201FFBB; Thu, 2 Mar 2023 19:08:46 +0000 (GMT) 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=vpN9HZmBiUU2swb5foi3aRB2Xz7IiTbLS73Qjjs5Gno=; b=X6ZpukbXB7ZQFc1ZKHqIcOrN4oUK5G/8vtg+7hvGOx4U57/FqhUHa5xkh0ATKgmuAz bVpNTe20/S+d5VqJiweBYfKEYdadM1ook/Q194p9EbRxNm5CXT+Y9eGQ5qzxY5MSDCFV QBYYyfW/1y6yV5SjCj3PGhaiWVrru80L5WWqRcyfyIbWfZW8cjCZdoEpy3ZUFrXAr5J0 Nq8sm2b6TPMo4q8nuUZ7v/o+QGqmDNn6C/dThABzyzE6qr5dE/WPmq9xUdGb99Uv35QL /44TeseRvDIZWTOQ/hCTTRPI0HCC/CaNYOPAK9iJcnmLlyz+TU/GwELecI8eQwqAosOF PAZA== 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=vpN9HZmBiUU2swb5foi3aRB2Xz7IiTbLS73Qjjs5Gno=; b=ai1JGlvz/0B0ACUw7ydyLMcpoQ38XuN5sKOKNNjnkQR1F4ev3B3SRda4k3Aa+4XxOP 2zU1dOURAhVf9srXLgIg6GaZTy3mr+j3BSsyO8P1WiHJfEXxWN8MKWgE1if5iDO4Pnza 4O9vftFDTjypToqsii3RPrJ9GjB14UB6VBGQtAFWwMduRzOmU4F5dghu0CksGV4sqJIY ZzwirzQItjc9t8DzNuqQhH5RDHW87h7DY4Dpwvk6uiOZJU5e2idweENkL1HAZxCLLPNl NsrLcV9+s7J/pq71baWROQpxficUn81g1PnjuRvphAKF3xbwDlO7KNmMHrNwbG8URYGm 9pkg== X-Gm-Message-State: AO0yUKUhDhUDI1iCtbIn4jMHerJnUbMlmdM0Hf/+g6iW+kW5ZEQAL5md 0sSaMuvBf3AMoGxA+gbybA24TQ== X-Google-Smtp-Source: AK7set/v7x1LqejxyJQY3tLZfGvFHQz1CzgOGP8zxK8uPbd5BSOymIpa0zLlvGeYomEwHDqsj8k0Jg== X-Received: by 2002:a5d:4e86:0:b0:2c7:fc61:1676 with SMTP id e6-20020a5d4e86000000b002c7fc611676mr8634371wru.7.1677784128871; Thu, 02 Mar 2023 11:08:48 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 03/26] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs Date: Thu, 2 Mar 2023 19:08:23 +0000 Message-Id: <20230302190846.2593720-4-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784254055100003 From: Philippe Mathieu-Daud=C3=A9 Prototypes using gdb_syscall_complete_cb() or gdb_?et_reg_cb() don't depend on "cpu.h", thus are not target-specific. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20221214143659.62133-1-philmd@linaro.org> Signed-off-by: Alex Benn=C3=A9e --- include/exec/gdbstub.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index f667014888..1636fb3841 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -71,9 +71,6 @@ struct gdb_timeval { uint64_t tv_usec; /* microsecond */ } QEMU_PACKED; =20 -#ifdef NEED_CPU_H -#include "cpu.h" - typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int e= rr); =20 /** @@ -126,6 +123,7 @@ int gdb_handlesig(CPUState *, int); void gdb_signalled(CPUArchState *, int); void gdbserver_fork(CPUState *); #endif + /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); @@ -133,6 +131,9 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, int num_regs, const char *xml, int g_pos); =20 +#ifdef NEED_CPU_H +#include "cpu.h" + /* * The GDB remote protocol transfers values in target byte order. As * the gdbstub may be batching up several register values we always --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784289; cv=none; d=zohomail.com; s=zohoarc; b=EH3VBx5o+MLIQDvIh9OQAcRGZxDfK0QtR9zNXiscofJoHhP7g49voDHqh4arb1C03ekimOurmO6ghqxTkuUDc2JNQqKNiHG8aT41DY02SnHu+EsDjfcxh/J/rhPU9PTFXi50OU+wQkWqS1EZrs7tlwPu9+TIEEd7NM7FCoEX0g0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784289; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=62eIWH+UgNDIO9tL0abCF5DS6hbxUYuKBS98TK1uNAY=; b=fB56dxvLdxLEMiAqUOZAuSet/625ufT+rb94K0Oivs/Pi21Wr5Xc6QlqZmgQkjI/DuREJr0fNsZIei7X9IBHAG/vORQax5p4MpQ2wZSuPgxHvq8+Yigh5rIF4+IEVhluLyCggE9yz7WBxDGA3YwaT1oIHcpAcO5GBrG8TK9SyUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784289764852.2215898464611; Thu, 2 Mar 2023 11:11:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoId-0007VB-25; Thu, 02 Mar 2023 14:09:07 -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 1pXoIa-0007SQ-JF for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:04 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIO-0004Wr-ET for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:04 -0500 Received: by mail-wm1-x32d.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso2504464wmi.4 for ; Thu, 02 Mar 2023 11:08:52 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a10-20020a5d508a000000b002c54241b4fesm125929wrt.80.2023.03.02.11.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 07E891FFBC; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=62eIWH+UgNDIO9tL0abCF5DS6hbxUYuKBS98TK1uNAY=; b=Y2EwnqrCp+qDTcFz1EW3YC21JHlRf1J8aYrGwA16D/IrPQ+aPQqDJHH+7FThelkDFB 8P/fukV7yJd4T0msEj12mSBV5ljzbAuK6Sg3R+g9QsoN5jpHqQxlkHkrKYLjXCAIuFRL 5S5C5B39krQZ0rFy9pIr/itagrEREMhfC3EVUx+d4tsUUzcbvDECSEuEHxCVWJS8GDxC gXYle4/apt0EhZXe174MMqRCyJIGjlK8TLBqhbQwZEZaz/OdMjUChqu5R1h8exkjYA67 CeV9ATLtLKGKbS65+050zb/YnCyfCHofOiHTJPzr5sRxrbwBNYOAwmSee/eKW7BsEBor vDBw== 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=62eIWH+UgNDIO9tL0abCF5DS6hbxUYuKBS98TK1uNAY=; b=CGZkwARR1wekI2s0p3uJ/nsItRrbBH7CVr7piLsdTPpPPwWiGjtzNTkdog+Pi0tfjr mKHOdPYhSjYg1UCKE0L1375wUZNBrvPOGTEAteO6ONtAfgXx7/GfFfxFyx+yXlOHI2zD uGwpAb+VRKHNxcDiomy1+RlpwxsgtBZY9PJn7l+F9Fh66zN7pR1pfN+wb+k0cA9jNPo0 e9SiSk7eghAJqoEXOtn682+XU9zzdxnNKY9j6oAw/HiiKiDW7u71AVq+9KYAppHtQe0T 3dF0aPSEhhBhkbB9YD1pLXCTaEQZPA9PZW+d7hSfY0VFF+XdNS6fx7R6yCdQx3KwcT5W 1ZGQ== X-Gm-Message-State: AO0yUKVjHMx8mK3Jlgs5TPKwjvFVaLTLckcn2cPAVqUJfUjNLDoHG6aB +IU3cQbTZhtf1t3vV7BxKrKpbA== X-Google-Smtp-Source: AK7set+DZpUV+fLm5EmXNvZFeuE5OsROlq+aBaJRW0JmuEXUuessAEZ306eoy59qqadcmgINWU/Wgg== X-Received: by 2002:a05:600c:170a:b0:3eb:37ce:4c3d with SMTP id c10-20020a05600c170a00b003eb37ce4c3dmr4634014wmn.38.1677784130856; Thu, 02 Mar 2023 11:08:50 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 04/26] gdbstub: clean-up indent on gdb_exit Date: Thu, 2 Mar 2023 19:08:24 +0000 Message-Id: <20230302190846.2593720-5-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784290527100001 Otherwise checkpatch will throw a hissy fit on the later patches that split this function up. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Daniel Henrique Barboza Reviewed-by: Richard Henderson --- gdbstub/gdbstub.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index fb9c49e0fd..63b56f0027 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -3021,27 +3021,27 @@ static void gdb_read_byte(uint8_t ch) /* Tell the remote gdb that the process has exited. */ void gdb_exit(int code) { - char buf[4]; + char buf[4]; =20 - if (!gdbserver_state.init) { - return; - } + if (!gdbserver_state.init) { + return; + } #ifdef CONFIG_USER_ONLY - if (gdbserver_state.socket_path) { - unlink(gdbserver_state.socket_path); - } - if (gdbserver_state.fd < 0) { - return; - } + if (gdbserver_state.socket_path) { + unlink(gdbserver_state.socket_path); + } + if (gdbserver_state.fd < 0) { + return; + } #endif =20 - trace_gdbstub_op_exiting((uint8_t)code); + trace_gdbstub_op_exiting((uint8_t)code); =20 - snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(buf); + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + put_packet(buf); =20 #ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&gdbserver_state.chr, true); + qemu_chr_fe_deinit(&gdbserver_state.chr, true); #endif } =20 --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784341; cv=none; d=zohomail.com; s=zohoarc; b=ZGUZaCTGLHZFXZx8knCP096boLLIjIrs6r+DlUoJTnz//R4ueBywge7w4wkfcyMgDq1nR8a5+89coSFUObCaa1mmav2YpVKwDr9/bBtVx2u7ePbA9M06/CraPi4Vqmf6RtjvRUszuZXqqgCHuh64zPGrJc7080BztmzdYFXyQ0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784341; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0VnUmt7qfbdjJswH/byMgVhjPRUgQaVzwcTJc8xq4ac=; b=Pv+FkpOJJ7uWqGpbMMpjCIOLSDq8hcCrdxyNaYvAaUGDVn1FLNix/fJE2S6yaMAFDHeKTCmgVPFSHfuMg5hytjIhOACIvJnVvq1kXb56z4wvtu61zflsasOk7kSrvs5jXG0fSiA1pjTgdezmsND3sdiAQDWUeQz7tWSW0Du3m1Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167778434142587.64877521440383; Thu, 2 Mar 2023 11:12:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIZ-0007RO-97; Thu, 02 Mar 2023 14:09:03 -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 1pXoIX-0007P2-76 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:01 -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 1pXoIN-0004Vm-Ng for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:00 -0500 Received: by mail-wm1-x331.google.com with SMTP id j3so294449wms.2 for ; Thu, 02 Mar 2023 11:08:50 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o10-20020a05600c164a00b003e20cf0408esm328831wmn.40.2023.03.02.11.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 232F51FFBD; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=0VnUmt7qfbdjJswH/byMgVhjPRUgQaVzwcTJc8xq4ac=; b=QSkntCo8//QHM+qN2ra4aI8hdkWC+ht0pBvtV383mIUzalM5SwPcmcZfLUyAf9WYae 6xRvwgRL/BefaIVvH5sxpRloJtVY4fWPd48n0K4MAM2YjV8IMjaDeiv4VEcq4bz58ljQ okzFyfaO4pxrNnk5QcuyBhLHG1PKN3BxQ7acuYBVQNY6tuoroKGOU8JqhyC75XCTL+zd 6KBTecHx/arxunAFc4rRJd+EEp/CkjufYmAhWPOK+K9aZlLtFtagG3rMtasSL83kxSkd rcaiCnJDqE2NvCMwnaAWPYO3Qxtj0yWqj/vqXixwY3NzKN/qVNPI6y2TKGBrYMY8aGU/ P2lw== 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=0VnUmt7qfbdjJswH/byMgVhjPRUgQaVzwcTJc8xq4ac=; b=BVZ7VLvpHKGN82YSZKuCFwIxA8vvXULY3X7SetWoOYm4+qjHi+rLXtz8nlDfdOAMyK GtuhRcS4AXJW3Ii5KU8Xlp4gj5YxAHMcy8WlECPE7do1ZAk5TD07/Ihldfqk9JVitsDQ Nx/iFHwi3z2d/9Sh4uth55nnkwgEBRpUUppf3fAULE2LZyuG+Lr70h/y7/dJlWEOCOSz Y8jrU9UA8V8AmsoMIxefHhRUPn26zaJXkn80KL0VIituUcA5KU5zF5R4U/4hPo/W8HC6 VRSAwqXKr3fsbLN3TXcDtrqB03ovJI2tOho9kLtYC6j71BSVf+s9TGP5HPLHjAYcH2tX wnJw== X-Gm-Message-State: AO0yUKWj7hjQTvlesAiFBKRDQmXMBaTyT6DH0I1MbbG0Yf9IYOLid3Qv mXVCMe9FjGkAMdBmrUbXgXZ+MQ== X-Google-Smtp-Source: AK7set9jLa15pVk9h+VS90mNQ/EzlL9CbZ10zFu9ShNxHjncJQlY3cx5qMvRKMMj39b4FkvcLDkmAQ== X-Received: by 2002:a05:600c:a45:b0:3ea:f883:180 with SMTP id c5-20020a05600c0a4500b003eaf8830180mr8878958wmq.7.1677784129606; Thu, 02 Mar 2023 11:08:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 05/26] gdbstub: define separate user/system structures Date: Thu, 2 Mar 2023 19:08:25 +0000 Message-Id: <20230302190846.2593720-6-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784342795100003 In preparation for moving user/softmmu specific bits from the main gdbstub file we need to separate the connection details into a user/softmmu state. As these will eventually be defined in their own files we move them out of the common GDBState structure. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - split into gdbserver_[user|system]_state now to avoid later hoop jumping --- gdbstub/gdbstub.c | 94 ++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 63b56f0027..1e6f8978b5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -341,6 +341,22 @@ enum RSState { RS_CHKSUM1, RS_CHKSUM2, }; + +#ifdef CONFIG_USER_ONLY +typedef struct { + int fd; + char *socket_path; + int running_state; +} GDBUserState; +static GDBUserState gdbserver_user_state; +#else +typedef struct { + CharBackend chr; + Chardev *mon_chr; +} GDBSystemState; +static GDBSystemState gdbserver_system_state; +#endif + typedef struct GDBState { bool init; /* have we been initialised? */ CPUState *c_cpu; /* current CPU for step/continue ops */ @@ -353,14 +369,6 @@ typedef struct GDBState { int line_csum; /* checksum at the end of the packet */ GByteArray *last_packet; int signal; -#ifdef CONFIG_USER_ONLY - int fd; - char *socket_path; - int running_state; -#else - CharBackend chr; - Chardev *mon_chr; -#endif bool multiprocess; GDBProcess *processes; int process_num; @@ -412,15 +420,17 @@ static int get_char(void) int ret; =20 for(;;) { - ret =3D recv(gdbserver_state.fd, &ch, 1, 0); + ret =3D recv(gdbserver_user_state.fd, &ch, 1, 0); if (ret < 0) { - if (errno =3D=3D ECONNRESET) - gdbserver_state.fd =3D -1; - if (errno !=3D EINTR) + if (errno =3D=3D ECONNRESET) { + gdbserver_user_state.fd =3D -1; + } + if (errno !=3D EINTR) { return -1; + } } else if (ret =3D=3D 0) { - close(gdbserver_state.fd); - gdbserver_state.fd =3D -1; + close(gdbserver_user_state.fd); + gdbserver_user_state.fd =3D -1; return -1; } else { break; @@ -479,7 +489,7 @@ static inline void gdb_continue(void) { =20 #ifdef CONFIG_USER_ONLY - gdbserver_state.running_state =3D 1; + gdbserver_user_state.running_state =3D 1; trace_gdbstub_op_continue(); #else if (!runstate_needs_reset()) { @@ -508,7 +518,7 @@ static int gdb_continue_partial(char *newstates) cpu_single_step(cpu, gdbserver_state.sstep_flags); } } - gdbserver_state.running_state =3D 1; + gdbserver_user_state.running_state =3D 1; #else int flag =3D 0; =20 @@ -560,7 +570,7 @@ static void put_buffer(const uint8_t *buf, int len) int ret; =20 while (len > 0) { - ret =3D send(gdbserver_state.fd, buf, len, 0); + ret =3D send(gdbserver_user_state.fd, buf, len, 0); if (ret < 0) { if (errno !=3D EINTR) return; @@ -572,7 +582,7 @@ static void put_buffer(const uint8_t *buf, int len) #else /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&gdbserver_state.chr, buf, len); + qemu_chr_fe_write_all(&gdbserver_system_state.chr, buf, len); #endif } =20 @@ -2094,7 +2104,8 @@ static void handle_query_rcmd(GArray *params, void *u= ser_ctx) len =3D len / 2; hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); - qemu_chr_be_write(gdbserver_state.mon_chr, gdbserver_state.mem_buf->da= ta, + qemu_chr_be_write(gdbserver_system_state.mon_chr, + gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len); put_packet("OK"); } @@ -3027,10 +3038,10 @@ void gdb_exit(int code) return; } #ifdef CONFIG_USER_ONLY - if (gdbserver_state.socket_path) { - unlink(gdbserver_state.socket_path); + if (gdbserver_user_state.socket_path) { + unlink(gdbserver_user_state.socket_path); } - if (gdbserver_state.fd < 0) { + if (gdbserver_user_state.fd < 0) { return; } #endif @@ -3041,7 +3052,7 @@ void gdb_exit(int code) put_packet(buf); =20 #ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&gdbserver_state.chr, true); + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); #endif } =20 @@ -3077,7 +3088,7 @@ gdb_handlesig(CPUState *cpu, int sig) char buf[256]; int n; =20 - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return sig; } =20 @@ -3095,15 +3106,15 @@ gdb_handlesig(CPUState *cpu, int sig) } /* put_packet() might have detected that the peer terminated the connection. */ - if (gdbserver_state.fd < 0) { + if (gdbserver_user_state.fd < 0) { return sig; } =20 sig =3D 0; gdbserver_state.state =3D RS_IDLE; - gdbserver_state.running_state =3D 0; - while (gdbserver_state.running_state =3D=3D 0) { - n =3D read(gdbserver_state.fd, buf, 256); + gdbserver_user_state.running_state =3D 0; + while (gdbserver_user_state.running_state =3D=3D 0) { + n =3D read(gdbserver_user_state.fd, buf, 256); if (n > 0) { int i; =20 @@ -3114,9 +3125,9 @@ gdb_handlesig(CPUState *cpu, int sig) /* XXX: Connection closed. Should probably wait for another connection before continuing. */ if (n =3D=3D 0) { - close(gdbserver_state.fd); + close(gdbserver_user_state.fd); } - gdbserver_state.fd =3D -1; + gdbserver_user_state.fd =3D -1; return sig; } } @@ -3130,7 +3141,7 @@ void gdb_signalled(CPUArchState *env, int sig) { char buf[4]; =20 - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } =20 @@ -3145,7 +3156,7 @@ static void gdb_accept_init(int fd) gdbserver_state.processes[0].attached =3D true; gdbserver_state.c_cpu =3D gdb_first_attached_cpu(); gdbserver_state.g_cpu =3D gdbserver_state.c_cpu; - gdbserver_state.fd =3D fd; + gdbserver_user_state.fd =3D fd; gdb_has_xml =3D false; } =20 @@ -3277,7 +3288,7 @@ int gdbserver_start(const char *port_or_path) if (port > 0 && gdb_accept_tcp(gdb_fd)) { return 0; } else if (gdb_accept_socket(gdb_fd)) { - gdbserver_state.socket_path =3D g_strdup(port_or_path); + gdbserver_user_state.socket_path =3D g_strdup(port_or_path); return 0; } =20 @@ -3289,11 +3300,11 @@ int gdbserver_start(const char *port_or_path) /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - close(gdbserver_state.fd); - gdbserver_state.fd =3D -1; + close(gdbserver_user_state.fd); + gdbserver_user_state.fd =3D -1; cpu_breakpoint_remove_all(cpu, BP_GDB); cpu_watchpoint_remove_all(cpu, BP_GDB); } @@ -3487,21 +3498,22 @@ int gdbserver_start(const char *device) NULL, NULL, &error_abort); monitor_init_hmp(mon_chr, false, &error_abort); } else { - qemu_chr_fe_deinit(&gdbserver_state.chr, true); - mon_chr =3D gdbserver_state.mon_chr; + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); + mon_chr =3D gdbserver_system_state.mon_chr; reset_gdbserver_state(); } =20 create_processes(&gdbserver_state); =20 if (chr) { - qemu_chr_fe_init(&gdbserver_state.chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&gdbserver_state.chr, gdb_chr_can_receive, + qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, + gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL, &gdbserver_state, NULL, true); } gdbserver_state.state =3D chr ? RS_IDLE : RS_INACTIVE; - gdbserver_state.mon_chr =3D mon_chr; + gdbserver_system_state.mon_chr =3D mon_chr; gdbserver_state.current_syscall_cb =3D NULL; =20 return 0; --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784344; cv=none; d=zohomail.com; s=zohoarc; b=F++K5vxwVuro5845fYnr8egj9WoyIaOvtdRhkm0Kw2eBAL+E5davMiTlZ+7Q1hP/BRh+mJ8xkAVZGFKlJsPH2aqRnxC1GDY8Ux8PV0zka3c3w/Ks4nslgEgP+6t4DrDz5rLIQl1QoYDwvAzOxWVdfryDBE0b8vR+KNGsMe8gwLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784344; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ffhXR90TVSQnNHTvhKRNefIM4mYQZlD8n+lh28Il+5U=; b=Fh+kqm8vw1qrkQkmC9DDcCXmbaJI0BjuUVbw2MMNdIl8Y5TlH461K0RZLh5GJDcRWyPP8GZOPEybdTN/un98Fe4FxSijVf53zHSrDAHbWRzId3v7RZw/f85gCzs/f9SbfwabBYqFHPfMceyE+VFUQCd+OfwFcHlJBhjqa+V12/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784344527713.1221756161342; Thu, 2 Mar 2023 11:12:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIZ-0007Rt-VX; Thu, 02 Mar 2023 14:09:03 -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 1pXoIY-0007Qq-ID for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:02 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIN-0004WA-Qf for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:02 -0500 Received: by mail-wr1-x42e.google.com with SMTP id g3so132682wri.6 for ; Thu, 02 Mar 2023 11:08:51 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f9-20020adfdb49000000b002c59c6abc10sm115801wrj.115.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3E7901FFBE; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=ffhXR90TVSQnNHTvhKRNefIM4mYQZlD8n+lh28Il+5U=; b=JfTTt2YCfJVrPhi7siSMIrk9/oCHPtVzmIfNVnF2IKJ8ahWHpRsGUoaBwl7kBHskWy ZBhVBc49Zrfxr4MxIFZ/OjBJk52s7AkdqTyyyzmyVYh75Y8DyxcsiXmyw87UlsRxHXBn ppuVfhF+k+oR2X9HsQjWeLR/EF9ROr9KmOpYZ3OAWOynwlakrimJT4Kj9EqpqbUtLzAq YqywemGGb1zVogr2CjiVSxiPOfE7Pgi6fEXKGGq6tzy09zWYrTNH11f9pVDWscdu8WTo tuJKh+x+AcB2LZOmV3hBDTY/CDqtlSxyaX8LhcLwvqL1wC9zssntvu+95Vf9EdFte8Yw b7jQ== 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=ffhXR90TVSQnNHTvhKRNefIM4mYQZlD8n+lh28Il+5U=; b=QeLI1zYO7mNxj0xltUt2ammK8jBjl6qMfTsZ4KFZIxrcj6lLbT+AEG3ZPpbsLO+XLG X/TP0PhWIJhz0uvUu+5s1FiNuK3a0ICAIMhgdMLAO78yBmAf0EOV+zwocJoNMNwGButQ cD8WbmIriYHhXVkDuRPxzex5k55kFWMkSWv+YNaT2Q9uH/zn8alghkgMtyl8mHf3P8NV iIsxlZMOwmf8L9oui7tFhceL1PJHRoEJpEkYMgjRoFCX+YwvbS4DYpwgRDhuRwkBv7Eo 6ZivZ2Hb8PRJ61JIU8Km931idR+PHS+iTugAFPeOh6vD4eEJHxcFKeSmF2v2loypeQLv /6Gw== X-Gm-Message-State: AO0yUKVATA8bUIf+SDnMHf1Gqdd9lLrl4Z9CmM/jmBHDVAqWDsRdidle H4p8XtBMRHW9YXaVIwask+hDTA== X-Google-Smtp-Source: AK7set+zt5nNBDnpxALDca4/tHaihplVbBGjp2gAIRRccOGPEVHSHVyfgHbc6nz6I5XxJoxKe8LvkQ== X-Received: by 2002:adf:e98e:0:b0:2c5:9c7a:866 with SMTP id h14-20020adfe98e000000b002c59c7a0866mr7862710wrm.51.1677784129988; Thu, 02 Mar 2023 11:08:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 06/26] gdbstub: move GDBState to shared internals header Date: Thu, 2 Mar 2023 19:08:26 +0000 Message-Id: <20230302190846.2593720-7-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784346866100004 We are about to split softmmu and user mode helpers into different files. To facilitate this we will need to share access to the GDBState between those files. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - as we split user/system state earlier we can remove the #define hack --- gdbstub/internals.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 42 ------------------------------------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 7df0e11c47..32daaf73a3 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -11,6 +11,56 @@ =20 #include "exec/cpu-common.h" =20 +#define MAX_PACKET_LENGTH 4096 + +/* + * Shared structures and definitions + */ + +typedef struct GDBProcess { + uint32_t pid; + bool attached; + + char target_xml[1024]; +} GDBProcess; + +enum RSState { + RS_INACTIVE, + RS_IDLE, + RS_GETLINE, + RS_GETLINE_ESC, + RS_GETLINE_RLE, + RS_CHKSUM1, + RS_CHKSUM2, +}; + +typedef struct GDBState { + bool init; /* have we been initialised? */ + CPUState *c_cpu; /* current CPU for step/continue ops */ + CPUState *g_cpu; /* current CPU for other ops */ + CPUState *query_cpu; /* for q{f|s}ThreadInfo */ + enum RSState state; /* parsing state */ + char line_buf[MAX_PACKET_LENGTH]; + int line_buf_index; + int line_sum; /* running checksum */ + int line_csum; /* checksum at the end of the packet */ + GByteArray *last_packet; + int signal; + bool multiprocess; + GDBProcess *processes; + int process_num; + char syscall_buf[256]; + gdb_syscall_complete_cb current_syscall_cb; + GString *str_buf; + GByteArray *mem_buf; + int sstep_flags; + int supported_sstep_flags; +} GDBState; + +/* + * Break/Watch point support - there is an implementation for softmmu + * and user mode. + */ bool gdb_supports_guest_debug(void); int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 1e6f8978b5..ef506faa8e 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -41,8 +41,6 @@ #include "hw/boards.h" #endif =20 -#define MAX_PACKET_LENGTH 4096 - #include "qemu/sockets.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" @@ -325,23 +323,6 @@ typedef struct GDBRegisterState { struct GDBRegisterState *next; } GDBRegisterState; =20 -typedef struct GDBProcess { - uint32_t pid; - bool attached; - - char target_xml[1024]; -} GDBProcess; - -enum RSState { - RS_INACTIVE, - RS_IDLE, - RS_GETLINE, - RS_GETLINE_ESC, - RS_GETLINE_RLE, - RS_CHKSUM1, - RS_CHKSUM2, -}; - #ifdef CONFIG_USER_ONLY typedef struct { int fd; @@ -357,29 +338,6 @@ typedef struct { static GDBSystemState gdbserver_system_state; #endif =20 -typedef struct GDBState { - bool init; /* have we been initialised? */ - CPUState *c_cpu; /* current CPU for step/continue ops */ - CPUState *g_cpu; /* current CPU for other ops */ - CPUState *query_cpu; /* for q{f|s}ThreadInfo */ - enum RSState state; /* parsing state */ - char line_buf[MAX_PACKET_LENGTH]; - int line_buf_index; - int line_sum; /* running checksum */ - int line_csum; /* checksum at the end of the packet */ - GByteArray *last_packet; - int signal; - bool multiprocess; - GDBProcess *processes; - int process_num; - char syscall_buf[256]; - gdb_syscall_complete_cb current_syscall_cb; - GString *str_buf; - GByteArray *mem_buf; - int sstep_flags; - int supported_sstep_flags; -} GDBState; - static GDBState gdbserver_state; =20 static void init_gdbserver_state(void) --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784204; cv=none; d=zohomail.com; s=zohoarc; b=CGhYF/EqV9ucn6EidRCgcYBCIZnGvPZeRrGzuBbI2qKBfnhxqwNVLMh5tDwI+X2f5BOqZI+hLNr+ey2GF9WJa1QuWYXlnabIjJ+DHqIurG5o3I1uvlTk1cA5qC54MIE72TmqEI9wpGqOmBq1Q0wqkAgcYQSg0WI2SFl9LnO7Eco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784204; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qHG5a70mU/vdhEiN0TqoaDRVD6IGcOS4m6Ff3FRj3Ls=; b=CyuacJIDPNxGUUzhtiTzf7nihHulKJYFU+afJwc+p0ufMdXeiXvx0JaRSZ3Bab/T/qH8WtdzaUDNsQM28OY3RFFFZTfBq7bjRiyyI8kHs1laaO6+TnHqHEOlN8XMI1AyE88+nCuhpttffaOuVtundYs1Zd/ZWiS3Z3wFp/Ry9fo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784204181806.02084451844; Thu, 2 Mar 2023 11:10:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIY-0007Qg-Gk; Thu, 02 Mar 2023 14:09:02 -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 1pXoIW-0007OA-RH for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:00 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIN-0004Vt-Gy for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:00 -0500 Received: by mail-wr1-x42b.google.com with SMTP id h14so142065wru.4 for ; Thu, 02 Mar 2023 11:08:50 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id s4-20020adff804000000b002c705058773sm135258wrp.74.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 773D71FFBF; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=qHG5a70mU/vdhEiN0TqoaDRVD6IGcOS4m6Ff3FRj3Ls=; b=eam2nW5gIEG2rWFxXwZdk6Yl1SSbmX88rua4KYH8TdKEItiEx9DfKp/vx3K7u3+atP vjwW56bGByb9DjVP9B2EC9W0+R+FEVVQy6evbThDWlhIgT8H4YEFVcl5Zp5Wcy5VVPMr dVZKHKCbQOq84QYqfCx1IfxGaz/78cswscf6YtZv+KX1Yc+9oKvJEb5uGDBZQ/orUaUh GC/d2qEMlzf6euaI5bE8Jfu6O93K9LywpHQq9vk1c/97BkAUzywPFdsBDLFQ+Os8bXeY hW1LYtm/TzU/fI6Bs+b3jNoXjL84MMp06eJlJzcJBT/lFlvDazZjAbpkDv1PO6CkUmQc C56g== 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=qHG5a70mU/vdhEiN0TqoaDRVD6IGcOS4m6Ff3FRj3Ls=; b=1hs9XMm/e2VfaDbcGPe21y8e4UnDhJky+ePEgLiDvxfz8bvjx5FUxYH39ac8imA/iN Yy2eoXxMf3qLGPIMtBF9bXsPSq5QWXWwOYnUwfPN0pOaoQNBJKQ4T5brsvWyUzdxUrum PdQKAkNbln2snTA+SLxuwq2F9vGU/Xs+RCknuVAmEtnDvpMLMMqGakGUxlomfc0i6PXo yYSyQnPztrI5gOzN3L9QVqZMeK6U7YG7SeqZECbKTajLYWutKQRL7iYO/0TpiO4Fenp9 O6pRj1fHKVeKKachCLJXygAiqPcj49sMh5tE/U65+ueshLMYa3oY9g2mXhmQDrVYy0tg lV9Q== X-Gm-Message-State: AO0yUKWpDhQd2Xn8MljYk7n3RlOxsJ8Grs+gO0qhAsi0sISk8TRl5Fxt xhuTnIL/mpk5KdcxoZqwwT2nzA== X-Google-Smtp-Source: AK7set+ijy+wfmm0t+lHwHdvuAMd2zr8nB4g5ncbWLHaDQaJOPKO2+HLEVtgfbLh2AnFouDTYUvcFg== X-Received: by 2002:a5d:60d2:0:b0:2c5:587e:75ba with SMTP id x18-20020a5d60d2000000b002c5587e75bamr7564414wrt.55.1677784129808; Thu, 02 Mar 2023 11:08:49 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 07/26] includes: move tb_flush into its own header Date: Thu, 2 Mar 2023 19:08:27 +0000 Message-Id: <20230302190846.2593720-8-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784204852100001 This aids subsystems (like gdbstub) that want to trigger a flush without pulling target specific headers. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v2 - actually include the header and rename to tb-flush.h - better kerneldoc style comment for the function v4 - update MAINTAINERS --- MAINTAINERS | 1 + include/exec/exec-all.h | 1 - include/exec/tb-flush.h | 26 ++++++++++++++++++++++++++ linux-user/user-internals.h | 1 + accel/stubs/tcg-stub.c | 1 + accel/tcg/tb-maint.c | 1 + accel/tcg/translate-all.c | 1 + cpu.c | 1 + gdbstub/gdbstub.c | 2 ++ hw/ppc/spapr_hcall.c | 1 + plugins/core.c | 1 + plugins/loader.c | 2 +- target/alpha/sys_helper.c | 1 + target/riscv/csr.c | 1 + 14 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 include/exec/tb-flush.h diff --git a/MAINTAINERS b/MAINTAINERS index 76662969d7..234800e3dc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -136,6 +136,7 @@ F: docs/devel/decodetree.rst F: docs/devel/tcg* F: include/exec/cpu*.h F: include/exec/exec-all.h +F: include/exec/tb-flush.h F: include/exec/helper*.h F: include/sysemu/cpus.h F: include/sysemu/tcg.h diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e09254333d..ad9eb6067b 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -677,7 +677,6 @@ void tb_invalidate_phys_addr(target_ulong addr); #else void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs att= rs); #endif -void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end); void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); diff --git a/include/exec/tb-flush.h b/include/exec/tb-flush.h new file mode 100644 index 0000000000..d92d06565b --- /dev/null +++ b/include/exec/tb-flush.h @@ -0,0 +1,26 @@ +/* + * tb-flush prototype for use by the rest of the system. + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef _TB_FLUSH_H_ +#define _TB_FLUSH_H_ + +/** + * tb_flush() - flush all translation blocks + * @cs: CPUState (must be valid, but treated as anonymous pointer) + * + * Used to flush all the translation blocks in the system. Sometimes + * it is simpler to flush everything than work out which individual + * translations are now invalid and ensure they are not called + * anymore. + * + * tb_flush() takes care of running the flush in an exclusive context + * if it is not already running in one. This means no guest code will + * run until this complete. + */ +void tb_flush(CPUState *cs); + +#endif /* _TB_FLUSH_H_ */ diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index 3576da413f..9333db4f51 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -20,6 +20,7 @@ =20 #include "exec/user/thunk.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "qemu/log.h" =20 extern char *exec_path; diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index 96af23dc5d..813695b402 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -11,6 +11,7 @@ */ =20 #include "qemu/osdep.h" +#include "exec/tb-flush.h" #include "exec/exec-all.h" =20 void tb_flush(CPUState *cpu) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index efefa08ee1..7246c1c46b 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -22,6 +22,7 @@ #include "exec/cputlb.h" #include "exec/log.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/translate-all.h" #include "sysemu/tcg.h" #include "tcg/tcg.h" diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4b5abc0f44..7096e68406 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -47,6 +47,7 @@ #include "exec/cputlb.h" #include "exec/translate-all.h" #include "exec/translator.h" +#include "exec/tb-flush.h" #include "qemu/bitmap.h" #include "qemu/qemu-print.h" #include "qemu/main-loop.h" diff --git a/cpu.c b/cpu.c index 2e9f931249..e6abc6c76c 100644 --- a/cpu.c +++ b/cpu.c @@ -36,6 +36,7 @@ #include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/translate-all.h" #include "exec/log.h" #include "hw/core/accel-cpu.h" diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ef506faa8e..abb1777e73 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,6 +47,8 @@ #include "semihosting/semihost.h" #include "exec/exec-all.h" #include "exec/replay-core.h" +#include "exec/tb-flush.h" +#include "exec/hwaddr.h" =20 #include "internals.h" =20 diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 925ff523cc..ec4def62f8 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -8,6 +8,7 @@ #include "qemu/module.h" #include "qemu/error-report.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" #include "hw/ppc/spapr.h" diff --git a/plugins/core.c b/plugins/core.c index e04ffa1ba4..04632886b9 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -24,6 +24,7 @@ #include "exec/cpu-common.h" =20 #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "tcg/tcg.h" #include "tcg/tcg-op.h" diff --git a/plugins/loader.c b/plugins/loader.c index 88c30bde2d..809f3f9b13 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -29,7 +29,7 @@ #include "qemu/plugin.h" #include "qemu/memalign.h" #include "hw/core/cpu.h" -#include "exec/exec-all.h" +#include "exec/tb-flush.h" #ifndef CONFIG_USER_ONLY #include "hw/boards.h" #endif diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c index 25f6cb8894..c83c92dd4c 100644 --- a/target/alpha/sys_helper.c +++ b/target/alpha/sys_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1b0a0c1693..74c64d4902 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -25,6 +25,7 @@ #include "time_helper.h" #include "qemu/main-loop.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "sysemu/cpu-timers.h" #include "qemu/guest-random.h" #include "qapi/error.h" --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784199; cv=none; d=zohomail.com; s=zohoarc; b=IrX1C52y2NRqogaaIfkmS2pPnmxryyZkCko6zNwKve/xFQPISRh2/DYQH0U6DaxRXKFX9nLfgEgcCinKTSOahwE+c+P1tb4pYxz7qaxYQ7cphBAfX+g1w1cQKlT7KHMUmW8NzSrkGTDcPi2KEIvIzUZLj0vxTuNCIKGzGkUs8hc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784199; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zhv1r+37cIdO73Hx2ePtuQOU7s/kw+X5fYnQSMO6fRk=; b=NbvWHT9woUqwXpFbZUkTQlBA6Lll/TR78D4umHQNym9HD0wMVGjAmWLCVpqnyT3txzrrZU/XkByShm83pUnowDZqQKvp/EjYnVHZCPaP3WXN8gaeUcMdoAa6hrOze6gK/BHic+xY7DmTK5bI8/UfaqG7VjdG/E+jAwaqq9yUnu4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784199130169.00926758722176; Thu, 2 Mar 2023 11:09:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIb-0007Un-MT; Thu, 02 Mar 2023 14:09:05 -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 1pXoIZ-0007Rz-Vm for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:04 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIO-0004X5-Du for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:03 -0500 Received: by mail-wr1-x42a.google.com with SMTP id l25so148509wrb.3 for ; Thu, 02 Mar 2023 11:08:52 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id r4-20020a5d4944000000b002c56013c07fsm114369wrs.109.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 941401FFB7; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=zhv1r+37cIdO73Hx2ePtuQOU7s/kw+X5fYnQSMO6fRk=; b=fv7CdPJTK9CJaeTbeeSsek2LKFF9kpjrFZaRix6juRaohfp3SLvfs3Ggy602Up+h22 rM2xGkf/oXZa4xPJz1dMsS/9nSu4BO2fUaLutGMQQZBJacAaysZ9yjQaij8vg+rbctxQ Q5MnIaXHSg9UzOK0B53f4LSbOxoFhEJqE/JrC9ChRXQiO2ZQZ+9DU+Xq0CMEbWfA2HBB Kxe50BtD8Df5BZeNZ2RrVKItDRm/fhDLrIk6vt0R20H34+d4SvBadDANJHcqLzxkCqCV kc70xW8lcrMlG6QToYS7BYHHbJOq+m1tQBnEwCkuHs+ArsDP3CmduWv/bJKuT+1ibyy2 VQXg== 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=zhv1r+37cIdO73Hx2ePtuQOU7s/kw+X5fYnQSMO6fRk=; b=Pu9gHPLmSlLcA0/pxf657aZ2jFtyXrEUzhXbX05Ns2ljqBM4IMVOycZqOvm+OzLn1I /qqrqu72Cl8uGr9qWRH3Jd+6PEODDKNCvNbaNYMPI1UOEiar2dkoF2IBIGj/UMbXwSOi nC/+tcHlbFcd6R7hZn0nvWVNaI277lqW1s4g+jEgJUYcsTAPjLSI41eG48Fg0vaEWi3Y kKITxOk+HM6T20qPMkgbG+I+KIPB7zOPa4TZjLATJAHAyjcfNeOnoEr20INrvMFPR+D0 5xvPLhgosEfORzsnZw+e9Nk75jCOIJIwRJl9WQHrsHXFI7wqaDyPL+epsDy3ydxbsEi8 gnAQ== X-Gm-Message-State: AO0yUKVy522BrH9D0y2Z+eXe7ivOzXzHfB0fEEfXthgLeYtHXNtajvsx 1AbA6AjdoK/7niHGfbI0HxT8fQ== X-Google-Smtp-Source: AK7set+LEp66kxPk8JP5WMjaKbMYNiQxBVToigX4wmvxYtjwSkY7GbDiNpyXd9Ln+qPbqAZZcuMcIA== X-Received: by 2002:a5d:604b:0:b0:2c7:faf:af32 with SMTP id j11-20020a5d604b000000b002c70fafaf32mr7953987wrt.14.1677784131052; Thu, 02 Mar 2023 11:08:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 08/26] gdbstub: move fromhex/tohex routines to internals Date: Thu, 2 Mar 2023 19:08:28 +0000 Message-Id: <20230302190846.2593720-9-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784201589100002 These will be needed from multiple places in the code. They are declared as inline so move to the header and fix up to modern coding style. The only other place that messes with hex stuff at the moment is the URI handling in utils but that would be more code churn so leave for now. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 27 +++++++++++++++++++++++++++ gdbstub/gdbstub.c | 20 -------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 32daaf73a3..b4620f99c4 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -57,6 +57,33 @@ typedef struct GDBState { int supported_sstep_flags; } GDBState; =20 + +/* + * Inline utility function, convert from int to hex and back + */ + +static inline int fromhex(int v) +{ + if (v >=3D '0' && v <=3D '9') { + return v - '0'; + } else if (v >=3D 'A' && v <=3D 'F') { + return v - 'A' + 10; + } else if (v >=3D 'a' && v <=3D 'f') { + return v - 'a' + 10; + } else { + return 0; + } +} + +static inline int tohex(int v) +{ + if (v < 10) { + return v + '0'; + } else { + return v - 10 + 'a'; + } +} + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index abb1777e73..ba46ed73b3 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -546,26 +546,6 @@ static void put_buffer(const uint8_t *buf, int len) #endif } =20 -static inline int fromhex(int v) -{ - if (v >=3D '0' && v <=3D '9') - return v - '0'; - else if (v >=3D 'A' && v <=3D 'F') - return v - 'A' + 10; - else if (v >=3D 'a' && v <=3D 'f') - return v - 'a' + 10; - else - return 0; -} - -static inline int tohex(int v) -{ - if (v < 10) - return v + '0'; - else - return v - 10 + 'a'; -} - /* writes 2*len+1 bytes in buf */ static void memtohex(GString *buf, const uint8_t *mem, int len) { --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784206; cv=none; d=zohomail.com; s=zohoarc; b=ndLYsckSwDA8KMRbis/8jcnjQ26bNSaBsRurEPBqJQE0nbiRZeUeti3UzRKcjw+pOVFzxu9WiaQcytC+3IZ56EeUclQGXG0XsZl2zBExRaBChIL6Eq+jawi/ut/mkyZRdATuRr4GzIbd29Rz84fLqwqXutJwjLeWGHknjETpeQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784206; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7KSjtYA0+1yFli81SbLZm37CjbIYVGVG0kgjY3EPdNo=; b=H+rVV0JVsp/UTI4xvMgQMl7VWcWMl8mZ/QFZhSFhost+FAefu4wXKJDOiViXFm6j+3k5oGLrCt1drOpUED553Ki0EBeTQPko2M2qA8C+HUKQc51AaWLYUJqRSNwz/pXwJYV2LR38jBdaDX+AKdj5By4/teYHxjiPOFU4h9Xed5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784206805854.0937153992853; Thu, 2 Mar 2023 11:10:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIj-0007d7-Qc; Thu, 02 Mar 2023 14:09:13 -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 1pXoIi-0007cC-Jj for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:12 -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 1pXoIQ-0004Y8-9C for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:12 -0500 Received: by mail-wm1-x32c.google.com with SMTP id o38-20020a05600c512600b003e8320d1c11so2456755wms.1 for ; Thu, 02 Mar 2023 11:08:53 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id b9-20020a05600010c900b002c6e84cadcbsm136524wrx.72.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B5BEB1FFC0; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=7KSjtYA0+1yFli81SbLZm37CjbIYVGVG0kgjY3EPdNo=; b=nwN9B+M3QKwbQAaqhIo64+AEdbm/mGRuBUy+eubXt6zyo8ChpxBaEjrjompF6jsrEQ 5ROQZX41cYninegFqDRLj1WQoE6ojz6oUHtB54CVA4Wsn7EVbSUduN6V8lTG5b1GCvGk aq1J1zduCnvG8ccwhh1wa6XRyGOLK//6I7IRyHAoxRfLNjGa7SJaOd9NXEmOA3BHXOwo wkql+x4J4en20glNaWXWpwu+NRQJ/olfNBEg6M7wnsOLoCZSN1dv5ZwEll0/ANDue2k7 2z55EJq2fjgeNVeF3VY9wKe1K25jQU07G4xvSrS/9Rui2uVu0KKEVye/BgK3ZepkgQdX zGNA== 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=7KSjtYA0+1yFli81SbLZm37CjbIYVGVG0kgjY3EPdNo=; b=rTmANELGk4sOPj92qTmCwBiF+ArGKju2w5vsWGRSeaEFOBgyKGan/7L9cKkAznuGiD mOsx15QRjAuGdilY9FoRxfifKZeDypvGDmgMxZq6Wc49MSbrzW3SZt//yraRHkX3gBZy R3tPLg/r7ymASn4Jv7TMG6I2dqfGLxaQtrE948MeW9XYk0x0pWZaFkp8WU03NMeGw+lY dZ7blavaEltrYb0lHa1QIoLoawLi8AuQzs+QR1Nx//5YWqU9OJ1SwzsAJ3fDawdjZqaR p5hwlbkx57/MVFVKqFu/0dH60VhKCH5B697gxB3QimSc68JWvxASawkQTv9JGBiu6Lol cMsA== X-Gm-Message-State: AO0yUKXDJS/tzdQ6cnpL7xslMXO+mcq9FhdveseNy3BblWZ/M1soCjU6 SvSY3dAO+qWVPsq9fHjC2PYSwg== X-Google-Smtp-Source: AK7set+iyrRSthK0lVse0SrKVHw1seYt/Oa7P4DeHUNTsMFm25vtelOpJrzWt6UfTEEDtnv9v06Wog== X-Received: by 2002:a05:600c:329c:b0:3dc:5c86:12f3 with SMTP id t28-20020a05600c329c00b003dc5c8612f3mr8801043wmp.1.1677784132066; Thu, 02 Mar 2023 11:08:52 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 09/26] gdbstub: make various helpers visible to the rest of the module Date: Thu, 2 Mar 2023 19:08:29 +0000 Message-Id: <20230302190846.2593720-10-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784208845100001 We will be needing to use these helpers between the user and softmmu files so declare them in the headers, add a system prefix and remove static from the implementations. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alex Benn=C3=A9e --- v4 - checkpatch warnings --- gdbstub/internals.h | 25 ++++ gdbstub/gdbstub.c | 276 ++++++++++++++++++++++---------------------- 2 files changed, 165 insertions(+), 136 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b4620f99c4..cf76627cf7 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -84,6 +84,31 @@ static inline int tohex(int v) } } =20 +/* + * Connection helpers for both softmmu and user backends + */ + +void gdb_put_strbuf(void); +int gdb_put_packet(const char *buf); +int gdb_put_packet_binary(const char *buf, int len, bool dump); +void gdb_hextomem(GByteArray *mem, const char *buf, int len); +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); + +/* utility helpers */ +CPUState *gdb_first_attached_cpu(void); +void gdb_append_thread_id(CPUState *cpu, GString *buf); +int gdb_get_cpu_index(CPUState *cpu); + +void gdb_init_gdbserver_state(void); +void gdb_create_default_process(GDBState *s); + +/* + * Helpers with separate softmmu and user implementations + */ +void gdb_put_buffer(const uint8_t *buf, int len); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ba46ed73b3..f59ab12cc3 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -85,12 +85,13 @@ static inline int target_memory_rw_debug(CPUState *cpu,= target_ulong addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } =20 -/* Return the GDB index for a given vCPU state. +/* + * Return the GDB index for a given vCPU state. * * For user mode this is simply the thread id. In system mode GDB * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. */ -static inline int cpu_gdb_index(CPUState *cpu) +int gdb_get_cpu_index(CPUState *cpu) { #if defined(CONFIG_USER_ONLY) TaskState *ts =3D (TaskState *) cpu->opaque; @@ -342,7 +343,7 @@ static GDBSystemState gdbserver_system_state; =20 static GDBState gdbserver_state; =20 -static void init_gdbserver_state(void) +void gdb_init_gdbserver_state(void) { g_assert(!gdbserver_state.init); memset(&gdbserver_state, 0, sizeof(GDBState)); @@ -524,7 +525,7 @@ static int gdb_continue_partial(char *newstates) return res; } =20 -static void put_buffer(const uint8_t *buf, int len) +void gdb_put_buffer(const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY int ret; @@ -547,7 +548,7 @@ static void put_buffer(const uint8_t *buf, int len) } =20 /* writes 2*len+1 bytes in buf */ -static void memtohex(GString *buf, const uint8_t *mem, int len) +void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { int i, c; for(i =3D 0; i < len; i++) { @@ -558,7 +559,7 @@ static void memtohex(GString *buf, const uint8_t *mem, = int len) g_string_append_c(buf, '\0'); } =20 -static void hextomem(GByteArray *mem, const char *buf, int len) +void gdb_hextomem(GByteArray *mem, const char *buf, int len) { int i; =20 @@ -603,7 +604,7 @@ static void hexdump(const char *buf, int len, } =20 /* return -1 if error, 0 if OK */ -static int put_packet_binary(const char *buf, int len, bool dump) +int gdb_put_packet_binary(const char *buf, int len, bool dump) { int csum, i; uint8_t footer[3]; @@ -627,7 +628,7 @@ static int put_packet_binary(const char *buf, int len, = bool dump) footer[2] =3D tohex((csum) & 0xf); g_byte_array_append(gdbserver_state.last_packet, footer, 3); =20 - put_buffer(gdbserver_state.last_packet->data, + gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); =20 #ifdef CONFIG_USER_ONLY @@ -644,20 +645,20 @@ static int put_packet_binary(const char *buf, int len= , bool dump) } =20 /* return -1 if error, 0 if OK */ -static int put_packet(const char *buf) +int gdb_put_packet(const char *buf) { trace_gdbstub_io_reply(buf); =20 - return put_packet_binary(buf, strlen(buf), false); + return gdb_put_packet_binary(buf, strlen(buf), false); } =20 -static void put_strbuf(void) +void gdb_put_strbuf(void) { - put_packet(gdbserver_state.str_buf->str); + gdb_put_packet(gdbserver_state.str_buf->str); } =20 /* Encode data using the encoding for 'x' packets. */ -static void memtox(GString *buf, const char *mem, int len) +void gdb_memtox(GString *buf, const char *mem, int len) { char c; =20 @@ -714,7 +715,7 @@ static CPUState *find_cpu(uint32_t thread_id) CPUState *cpu; =20 CPU_FOREACH(cpu) { - if (cpu_gdb_index(cpu) =3D=3D thread_id) { + if (gdb_get_cpu_index(cpu) =3D=3D thread_id) { return cpu; } } @@ -768,7 +769,7 @@ static CPUState *gdb_next_attached_cpu(CPUState *cpu) } =20 /* Return the first attached cpu */ -static CPUState *gdb_first_attached_cpu(void) +CPUState *gdb_first_attached_cpu(void) { CPUState *cpu =3D first_cpu; GDBProcess *process =3D gdb_get_cpu_process(cpu); @@ -982,13 +983,13 @@ static void gdb_set_cpu_pc(target_ulong pc) cpu_set_pc(cpu, pc); } =20 -static void gdb_append_thread_id(CPUState *cpu, GString *buf) +void gdb_append_thread_id(CPUState *cpu, GString *buf) { if (gdbserver_state.multiprocess) { g_string_append_printf(buf, "p%02x.%02x", - gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); + gdb_get_cpu_pid(cpu), gdb_get_cpu_index(cpu= )); } else { - g_string_append_printf(buf, "%02x", cpu_gdb_index(cpu)); + g_string_append_printf(buf, "%02x", gdb_get_cpu_index(cpu)); } } =20 @@ -1359,7 +1360,7 @@ static void run_cmd_parser(const char *data, const Gd= bCmdParseEntry *cmd) /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ if (process_string_cmd(NULL, data, cmd, 1)) { - put_packet(""); + gdb_put_packet(""); } } =20 @@ -1370,7 +1371,7 @@ static void handle_detach(GArray *params, void *user_= ctx) =20 if (gdbserver_state.multiprocess) { if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -1394,7 +1395,7 @@ static void handle_detach(GArray *params, void *user_= ctx) gdb_syscall_mode =3D GDB_SYS_DISABLED; gdb_continue(); } - put_packet("OK"); + gdb_put_packet("OK"); } =20 static void handle_thread_alive(GArray *params, void *user_ctx) @@ -1402,23 +1403,23 @@ static void handle_thread_alive(GArray *params, voi= d *user_ctx) CPUState *cpu; =20 if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 if (get_param(params, 0)->thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 cpu =3D gdb_get_cpu(get_param(params, 0)->thread_id.pid, get_param(params, 0)->thread_id.tid); if (!cpu) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 - put_packet("OK"); + gdb_put_packet("OK"); } =20 static void handle_continue(GArray *params, void *user_ctx) @@ -1455,24 +1456,24 @@ static void handle_set_thread(GArray *params, void = *user_ctx) CPUState *cpu; =20 if (params->len !=3D 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 if (get_param(params, 1)->thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 if (get_param(params, 1)->thread_id.kind !=3D GDB_ONE_THREAD) { - put_packet("OK"); + gdb_put_packet("OK"); return; } =20 cpu =3D gdb_get_cpu(get_param(params, 1)->thread_id.pid, get_param(params, 1)->thread_id.tid); if (!cpu) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -1483,14 +1484,14 @@ static void handle_set_thread(GArray *params, void = *user_ctx) switch (get_param(params, 0)->opcode) { case 'c': gdbserver_state.c_cpu =3D cpu; - put_packet("OK"); + gdb_put_packet("OK"); break; case 'g': gdbserver_state.g_cpu =3D cpu; - put_packet("OK"); + gdb_put_packet("OK"); break; default: - put_packet("E22"); + gdb_put_packet("E22"); break; } } @@ -1500,7 +1501,7 @@ static void handle_insert_bp(GArray *params, void *us= er_ctx) int res; =20 if (params->len !=3D 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -1509,14 +1510,14 @@ static void handle_insert_bp(GArray *params, void *= user_ctx) get_param(params, 1)->val_ull, get_param(params, 2)->val_ull); if (res >=3D 0) { - put_packet("OK"); + gdb_put_packet("OK"); return; } else if (res =3D=3D -ENOSYS) { - put_packet(""); + gdb_put_packet(""); return; } =20 - put_packet("E22"); + gdb_put_packet("E22"); } =20 static void handle_remove_bp(GArray *params, void *user_ctx) @@ -1524,7 +1525,7 @@ static void handle_remove_bp(GArray *params, void *us= er_ctx) int res; =20 if (params->len !=3D 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -1533,14 +1534,14 @@ static void handle_remove_bp(GArray *params, void *= user_ctx) get_param(params, 1)->val_ull, get_param(params, 2)->val_ull); if (res >=3D 0) { - put_packet("OK"); + gdb_put_packet("OK"); return; } else if (res =3D=3D -ENOSYS) { - put_packet(""); + gdb_put_packet(""); return; } =20 - put_packet("E22"); + gdb_put_packet("E22"); } =20 /* @@ -1559,20 +1560,20 @@ static void handle_set_reg(GArray *params, void *us= er_ctx) int reg_size; =20 if (!gdb_has_xml) { - put_packet(""); + gdb_put_packet(""); return; } =20 if (params->len !=3D 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 reg_size =3D strlen(get_param(params, 1)->data) / 2; - hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_size= ); + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_= size); gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->dat= a, get_param(params, 0)->val_ull); - put_packet("OK"); + gdb_put_packet("OK"); } =20 static void handle_get_reg(GArray *params, void *user_ctx) @@ -1580,12 +1581,12 @@ static void handle_get_reg(GArray *params, void *us= er_ctx) int reg_size; =20 if (!gdb_has_xml) { - put_packet(""); + gdb_put_packet(""); return; } =20 if (!params->len) { - put_packet("E14"); + gdb_put_packet("E14"); return; } =20 @@ -1593,53 +1594,54 @@ static void handle_get_reg(GArray *params, void *us= er_ctx) gdbserver_state.mem_buf, get_param(params, 0)->val_ull); if (!reg_size) { - put_packet("E14"); + gdb_put_packet("E14"); return; } else { g_byte_array_set_size(gdbserver_state.mem_buf, reg_size); } =20 - memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, reg_s= ize); - put_strbuf(); + gdb_memtohex(gdbserver_state.str_buf, + gdbserver_state.mem_buf->data, reg_size); + gdb_put_strbuf(); } =20 static void handle_write_mem(GArray *params, void *user_ctx) { if (params->len !=3D 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 - /* hextomem() reads 2*len bytes */ + /* gdb_hextomem() reads 2*len bytes */ if (get_param(params, 1)->val_ull > strlen(get_param(params, 2)->data) / 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 - hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, get_param(params, 1)->val_ull); if (target_memory_rw_debug(gdbserver_state.g_cpu, get_param(params, 0)->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, true)) { - put_packet("E14"); + gdb_put_packet("E14"); return; } =20 - put_packet("OK"); + gdb_put_packet("OK"); } =20 static void handle_read_mem(GArray *params, void *user_ctx) { if (params->len !=3D 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 - /* memtohex() doubles the required space */ + /* gdb_memtohex() doubles the required space */ if (get_param(params, 1)->val_ull > MAX_PACKET_LENGTH / 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -1650,13 +1652,13 @@ static void handle_read_mem(GArray *params, void *u= ser_ctx) get_param(params, 0)->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, false)) { - put_packet("E14"); + gdb_put_packet("E14"); return; } =20 - memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, + gdb_memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len); - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_write_all_regs(GArray *params, void *user_ctx) @@ -1671,7 +1673,7 @@ static void handle_write_all_regs(GArray *params, voi= d *user_ctx) =20 cpu_synchronize_state(gdbserver_state.g_cpu); len =3D strlen(get_param(params, 0)->data) / 2; - hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); registers =3D gdbserver_state.mem_buf->data; for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len >= 0; addr++) { @@ -1679,7 +1681,7 @@ static void handle_write_all_regs(GArray *params, voi= d *user_ctx) len -=3D reg_size; registers +=3D reg_size; } - put_packet("OK"); + gdb_put_packet("OK"); } =20 static void handle_read_all_regs(GArray *params, void *user_ctx) @@ -1696,8 +1698,8 @@ static void handle_read_all_regs(GArray *params, void= *user_ctx) } g_assert(len =3D=3D gdbserver_state.mem_buf->len); =20 - memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); - put_strbuf(); + gdb_memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, l= en); + gdb_put_strbuf(); } =20 static void handle_file_io(GArray *params, void *user_ctx) @@ -1748,7 +1750,7 @@ static void handle_file_io(GArray *params, void *user= _ctx) } =20 if (params->len >=3D 3 && get_param(params, 2)->opcode =3D=3D (uint8_t= )'C') { - put_packet("T02"); + gdb_put_packet("T02"); return; } =20 @@ -1768,7 +1770,7 @@ static void handle_step(GArray *params, void *user_ct= x) static void handle_backward(GArray *params, void *user_ctx) { if (!stub_can_reverse()) { - put_packet("E22"); + gdb_put_packet("E22"); } if (params->len =3D=3D 1) { switch (get_param(params, 0)->opcode) { @@ -1776,26 +1778,26 @@ static void handle_backward(GArray *params, void *u= ser_ctx) if (replay_reverse_step()) { gdb_continue(); } else { - put_packet("E14"); + gdb_put_packet("E14"); } return; case 'c': if (replay_reverse_continue()) { gdb_continue(); } else { - put_packet("E14"); + gdb_put_packet("E14"); } return; } } =20 /* Default invalid command */ - put_packet(""); + gdb_put_packet(""); } =20 static void handle_v_cont_query(GArray *params, void *user_ctx) { - put_packet("vCont;c;C;s;S"); + gdb_put_packet("vCont;c;C;s;S"); } =20 static void handle_v_cont(GArray *params, void *user_ctx) @@ -1808,9 +1810,9 @@ static void handle_v_cont(GArray *params, void *user_= ctx) =20 res =3D gdb_handle_vcont(get_param(params, 0)->data); if ((res =3D=3D -EINVAL) || (res =3D=3D -ERANGE)) { - put_packet("E22"); + gdb_put_packet("E22"); } else if (res) { - put_packet(""); + gdb_put_packet(""); } } =20 @@ -1842,13 +1844,13 @@ static void handle_v_attach(GArray *params, void *u= ser_ctx) gdb_append_thread_id(cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); cleanup: - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_v_kill(GArray *params, void *user_ctx) { /* Kill the target */ - put_packet("OK"); + gdb_put_packet("OK"); error_report("QEMU: Terminated via GDBstub"); gdb_exit(0); exit(0); @@ -1889,7 +1891,7 @@ static void handle_v_commands(GArray *params, void *u= ser_ctx) if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_v_commands_table, ARRAY_SIZE(gdb_v_commands_table))) { - put_packet(""); + gdb_put_packet(""); } } =20 @@ -1907,7 +1909,7 @@ static void handle_query_qemu_sstepbits(GArray *param= s, void *user_ctx) SSTEP_NOTIMER); } =20 - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_set_qemu_sstep(GArray *params, void *user_ctx) @@ -1921,19 +1923,19 @@ static void handle_set_qemu_sstep(GArray *params, v= oid *user_ctx) new_sstep_flags =3D get_param(params, 0)->val_ul; =20 if (new_sstep_flags & ~gdbserver_state.supported_sstep_flags) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 gdbserver_state.sstep_flags =3D new_sstep_flags; - put_packet("OK"); + gdb_put_packet("OK"); } =20 static void handle_query_qemu_sstep(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "0x%x", gdbserver_state.sstep_flags); - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_query_curr_tid(GArray *params, void *user_ctx) @@ -1950,19 +1952,19 @@ static void handle_query_curr_tid(GArray *params, v= oid *user_ctx) cpu =3D get_first_cpu_in_process(process); g_string_assign(gdbserver_state.str_buf, "QC"); gdb_append_thread_id(cpu, gdbserver_state.str_buf); - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_query_threads(GArray *params, void *user_ctx) { if (!gdbserver_state.query_cpu) { - put_packet("l"); + gdb_put_packet("l"); return; } =20 g_string_assign(gdbserver_state.str_buf, "m"); gdb_append_thread_id(gdbserver_state.query_cpu, gdbserver_state.str_bu= f); - put_strbuf(); + gdb_put_strbuf(); gdbserver_state.query_cpu =3D gdb_next_attached_cpu(gdbserver_state.qu= ery_cpu); } =20 @@ -1979,7 +1981,7 @@ static void handle_query_thread_extra(GArray *params,= void *user_ctx) =20 if (!params->len || get_param(params, 0)->thread_id.kind =3D=3D GDB_READ_THREAD_ERR) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -2004,8 +2006,8 @@ static void handle_query_thread_extra(GArray *params,= void *user_ctx) cpu->halted ? "halted " : "running"); } trace_gdbstub_op_extra_info(rs->str); - memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len); - put_strbuf(); + gdb_memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len); + gdb_put_strbuf(); } =20 #ifdef CONFIG_USER_ONLY @@ -2021,7 +2023,7 @@ static void handle_query_offsets(GArray *params, void= *user_ctx) ts->info->code_offset, ts->info->data_offset, ts->info->data_offset); - put_strbuf(); + gdb_put_strbuf(); } #else static void handle_query_rcmd(GArray *params, void *user_ctx) @@ -2030,24 +2032,24 @@ static void handle_query_rcmd(GArray *params, void = *user_ctx) int len; =20 if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 len =3D strlen(get_param(params, 0)->data); if (len % 2) { - put_packet("E01"); + gdb_put_packet("E01"); return; } =20 g_assert(gdbserver_state.mem_buf->len =3D=3D 0); len =3D len / 2; - hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); qemu_chr_be_write(gdbserver_system_state.mon_chr, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len); - put_packet("OK"); + gdb_put_packet("OK"); } #endif =20 @@ -2078,7 +2080,7 @@ static void handle_query_supported(GArray *params, vo= id *user_ctx) } =20 g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiproces= s+"); - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_query_xfer_features(GArray *params, void *user_ctx) @@ -2090,14 +2092,14 @@ static void handle_query_xfer_features(GArray *para= ms, void *user_ctx) const char *p; =20 if (params->len < 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 process =3D gdb_get_cpu_process(gdbserver_state.g_cpu); cc =3D CPU_GET_CLASS(gdbserver_state.g_cpu); if (!cc->gdb_core_xml_file) { - put_packet(""); + gdb_put_packet(""); return; } =20 @@ -2105,7 +2107,7 @@ static void handle_query_xfer_features(GArray *params= , void *user_ctx) p =3D get_param(params, 0)->data; xml =3D get_feature_xml(p, &p, process); if (!xml) { - put_packet("E00"); + gdb_put_packet("E00"); return; } =20 @@ -2113,7 +2115,7 @@ static void handle_query_xfer_features(GArray *params= , void *user_ctx) len =3D get_param(params, 2)->val_ul; total_len =3D strlen(xml); if (addr > total_len) { - put_packet("E00"); + gdb_put_packet("E00"); return; } =20 @@ -2123,13 +2125,13 @@ static void handle_query_xfer_features(GArray *para= ms, void *user_ctx) =20 if (len < total_len - addr) { g_string_assign(gdbserver_state.str_buf, "m"); - memtox(gdbserver_state.str_buf, xml + addr, len); + gdb_memtox(gdbserver_state.str_buf, xml + addr, len); } else { g_string_assign(gdbserver_state.str_buf, "l"); - memtox(gdbserver_state.str_buf, xml + addr, total_len - addr); + gdb_memtox(gdbserver_state.str_buf, xml + addr, total_len - addr); } =20 - put_packet_binary(gdbserver_state.str_buf->str, + gdb_put_packet_binary(gdbserver_state.str_buf->str, gdbserver_state.str_buf->len, true); } =20 @@ -2140,7 +2142,7 @@ static void handle_query_xfer_auxv(GArray *params, vo= id *user_ctx) unsigned long offset, len, saved_auxv, auxv_len; =20 if (params->len < 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -2151,7 +2153,7 @@ static void handle_query_xfer_auxv(GArray *params, vo= id *user_ctx) auxv_len =3D ts->info->auxv_len; =20 if (offset >=3D auxv_len) { - put_packet("E00"); + gdb_put_packet("E00"); return; } =20 @@ -2169,20 +2171,20 @@ static void handle_query_xfer_auxv(GArray *params, = void *user_ctx) g_byte_array_set_size(gdbserver_state.mem_buf, len); if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset, gdbserver_state.mem_buf->data, len, false))= { - put_packet("E14"); + gdb_put_packet("E14"); return; } =20 - memtox(gdbserver_state.str_buf, - (const char *)gdbserver_state.mem_buf->data, len); - put_packet_binary(gdbserver_state.str_buf->str, - gdbserver_state.str_buf->len, true); + gdb_memtox(gdbserver_state.str_buf, + (const char *)gdbserver_state.mem_buf->data, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); } #endif =20 static void handle_query_attached(GArray *params, void *user_ctx) { - put_packet(GDB_ATTACHED); + gdb_put_packet(GDB_ATTACHED); } =20 static void handle_query_qemu_supported(GArray *params, void *user_ctx) @@ -2191,7 +2193,7 @@ static void handle_query_qemu_supported(GArray *param= s, void *user_ctx) #ifndef CONFIG_USER_ONLY g_string_append(gdbserver_state.str_buf, ";PhyMemMode"); #endif - put_strbuf(); + gdb_put_strbuf(); } =20 #ifndef CONFIG_USER_ONLY @@ -2199,13 +2201,13 @@ static void handle_query_qemu_phy_mem_mode(GArray *= params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); - put_strbuf(); + gdb_put_strbuf(); } =20 static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) { if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } =20 @@ -2214,7 +2216,7 @@ static void handle_set_qemu_phy_mem_mode(GArray *para= ms, void *user_ctx) } else { phy_memory_mode =3D 1; } - put_packet("OK"); + gdb_put_packet("OK"); } #endif =20 @@ -2347,7 +2349,7 @@ static void handle_gen_query(GArray *params, void *us= er_ctx) if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_table, ARRAY_SIZE(gdb_gen_query_table))) { - put_packet(""); + gdb_put_packet(""); } } =20 @@ -2366,7 +2368,7 @@ static void handle_gen_set(GArray *params, void *user= _ctx) if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { - put_packet(""); + gdb_put_packet(""); } } =20 @@ -2375,7 +2377,7 @@ static void handle_target_halt(GArray *params, void *= user_ctx) g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TR= AP); gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); - put_strbuf(); + gdb_put_strbuf(); /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2392,7 +2394,7 @@ static int gdb_handle_packet(const char *line_buf) =20 switch (line_buf[0]) { case '!': - put_packet("OK"); + gdb_put_packet("OK"); break; case '?': { @@ -2619,7 +2621,7 @@ static int gdb_handle_packet(const char *line_buf) break; default: /* put empty packet */ - put_packet(""); + gdb_put_packet(""); break; } =20 @@ -2660,7 +2662,7 @@ static void gdb_vm_state_change(void *opaque, bool ru= nning, RunState state) } /* Is there a GDB syscall waiting to be sent? */ if (gdbserver_state.current_syscall_cb) { - put_packet(gdbserver_state.syscall_buf); + gdb_put_packet(gdbserver_state.syscall_buf); return; } =20 @@ -2685,7 +2687,7 @@ static void gdb_vm_state_change(void *opaque, bool ru= nning, RunState state) type =3D ""; break; } - trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), + trace_gdbstub_hit_watchpoint(type, gdb_get_cpu_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); g_string_printf(buf, "T%02xthread:%s;%swatch:" TARGET_FMT_lx "= ;", GDB_SIGNAL_TRAP, tid->str, type, @@ -2733,7 +2735,7 @@ static void gdb_vm_state_change(void *opaque, bool ru= nning, RunState state) g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); =20 send_packet: - put_packet(buf->str); + gdb_put_packet(buf->str); =20 /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -2794,7 +2796,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, cons= t char *fmt, va_list va) } *p =3D 0; #ifdef CONFIG_USER_ONLY - put_packet(gdbserver_state.syscall_buf); + gdb_put_packet(gdbserver_state.syscall_buf); /* Return control to gdb for it to process the syscall request. * Since the protocol requires that gdb hands control back to us * using a "here are the results" F packet, we don't need to check @@ -2822,7 +2824,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const= char *fmt, ...) va_end(va); } =20 -static void gdb_read_byte(uint8_t ch) +void gdb_read_byte(uint8_t ch) { uint8_t reply; =20 @@ -2832,7 +2834,7 @@ static void gdb_read_byte(uint8_t ch) of a new command then abandon the previous response. */ if (ch =3D=3D '-') { trace_gdbstub_err_got_nack(); - put_buffer(gdbserver_state.last_packet->data, + gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); } else if (ch =3D=3D '+') { trace_gdbstub_io_got_ack(); @@ -2954,12 +2956,12 @@ static void gdb_read_byte(uint8_t ch) trace_gdbstub_err_checksum_incorrect(gdbserver_state.line_= sum, gdbserver_state.line_csum); /* send NAK reply */ reply =3D '-'; - put_buffer(&reply, 1); + gdb_put_buffer(&reply, 1); gdbserver_state.state =3D RS_IDLE; } else { /* send ACK reply */ reply =3D '+'; - put_buffer(&reply, 1); + gdb_put_buffer(&reply, 1); gdbserver_state.state =3D gdb_handle_packet(gdbserver_stat= e.line_buf); } break; @@ -2989,7 +2991,7 @@ void gdb_exit(int code) trace_gdbstub_op_exiting((uint8_t)code); =20 snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(buf); + gdb_put_packet(buf); =20 #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); @@ -3001,7 +3003,7 @@ void gdb_exit(int code) * part of a CPU cluster). Note that if this process contains no CPUs, it = won't * be attachable and thus will be invisible to the user. */ -static void create_default_process(GDBState *s) +void gdb_create_default_process(GDBState *s) { GDBProcess *process; int max_pid =3D 0; @@ -3042,10 +3044,12 @@ gdb_handlesig(CPUState *cpu, int sig) "T%02xthread:", target_signal_to_gdb(sig)); gdb_append_thread_id(cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); - put_strbuf(); + gdb_put_strbuf(); } - /* put_packet() might have detected that the peer terminated the - connection. */ + /* + * gdb_put_packet() might have detected that the peer terminated the + * connection. + */ if (gdbserver_user_state.fd < 0) { return sig; } @@ -3086,13 +3090,13 @@ void gdb_signalled(CPUArchState *env, int sig) } =20 snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - put_packet(buf); + gdb_put_packet(buf); } =20 static void gdb_accept_init(int fd) { - init_gdbserver_state(); - create_default_process(&gdbserver_state); + gdb_init_gdbserver_state(); + gdb_create_default_process(&gdbserver_state); gdbserver_state.processes[0].attached =3D true; gdbserver_state.c_cpu =3D gdb_first_attached_cpu(); gdbserver_state.g_cpu =3D gdbserver_state.c_cpu; @@ -3292,8 +3296,8 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent = event) static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) { g_autoptr(GString) hex_buf =3D g_string_new("O"); - memtohex(hex_buf, buf, len); - put_packet(hex_buf->str); + gdb_memtohex(hex_buf, buf, len); + gdb_put_packet(hex_buf->str); return len; } =20 @@ -3379,7 +3383,7 @@ static void create_processes(GDBState *s) qsort(gdbserver_state.processes, gdbserver_state.process_num, size= of(gdbserver_state.processes[0]), pid_order); } =20 - create_default_process(s); + gdb_create_default_process(s); } =20 int gdbserver_start(const char *device) @@ -3429,7 +3433,7 @@ int gdbserver_start(const char *device) } =20 if (!gdbserver_state.init) { - init_gdbserver_state(); + gdb_init_gdbserver_state(); =20 qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); =20 --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784344; cv=none; d=zohomail.com; s=zohoarc; b=RqBdwPttWBUo6Mj4R6bm4xrfWK1/4w5qq/BGF0cKLLOHlOiP5XML7GTHMt6S6OMk957WzDpfVJMQssgYdy3eqkORSM5iY08oMfsT3lCcRc9ZsEdy40+aqADqnO7JxkYplIIhp5gQ1Rij2APf9+7BgIP8WAs3bNma1EQZYh3Ul/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784344; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jGgBwMUcyIBik2rNBr0fhqXEGqg20UF3VvqGQKmkW3Y=; b=OnQWZug/LpcPRNXR6+FQgZOQVWd3jnWndRe6ZgTDQ6wrvgPu0cUKGBTRYq5B7ofXybxEvFTjno2EBACjEjkohE8gkH94zqZT2/BaDI2Xb+bVtTISmXpF6jczPG3wuT3E+lGx33bh4r9W0LHqAD2ddHuP5onHPGD4YSylto4f/t4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784344749521.4120268411745; Thu, 2 Mar 2023 11:12:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIf-0007YS-IL; Thu, 02 Mar 2023 14:09:09 -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 1pXoId-0007XG-Uy for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:07 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIP-0004Xl-LM for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:07 -0500 Received: by mail-wm1-x32a.google.com with SMTP id d41-20020a05600c4c2900b003e9e066550fso2116851wmp.4 for ; Thu, 02 Mar 2023 11:08:52 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id l8-20020a05600c4f0800b003b47b80cec3sm4627458wmq.42.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E242E1FFB8; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) 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=jGgBwMUcyIBik2rNBr0fhqXEGqg20UF3VvqGQKmkW3Y=; b=YVMjUsdlRGu5n3GOK7fu9LV2wUJ8rJIFQJO/hX/rEsdugWl8LyVId7p16V53Fwjwf1 3vb5b4bnrnttlbLudOKrcsqbP2cPCjrOh5bQBy2eHSFuv/HZS3DhOXUghKvZwkeX4kY1 7IjZKWdV6DFQy/Q8JvveYRFJamQN+2E2BL20pvPDbzZXnTw0dBhOw5eJzgoH/SLazN1q yR5RXyp8n0QafdRjlFVvN9Wqu5+w+solznDCuRd8MvNkLgn+Wx+kcyehpPo3HRY7TjeA ZdV78NMyTIMYpi1IYIbLKUBkGrleAuA+BpuTrAC7VDkDs7UM3zCfxnC+GrloSRp1aJdk KiyQ== 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=jGgBwMUcyIBik2rNBr0fhqXEGqg20UF3VvqGQKmkW3Y=; b=qyKf0P9tik3Cvrmixn6pqDEygwlpHXvNxWQ/tVrdYuuERhaJJyaBZZG8/Fd9u4nFqz 940aXF/RGq9tMPD+G5mFASpsLnvR3On/tRPYzzu0AY+fPa+0JeG+OaShKqjvuGzO/EZ1 cAwnHga7r3HXrd64JyChwNAVzZt8GM6kp6bJriWJ5MkgmhZ2vm64j1fHHy9+QXTWVK+D KOrWiMc8eVuXX8dkll4G/BJ3Mzf/THFJ9RoJaj0JgIqLyMY+9wh5mQ04m1yDFPuqrFOS 55btP6UFtaMYiqhaUw0IOe4wnBbrluCVa4XjPWyrjP4PQxmKdzEMRe8pA0MxC0Eu/kgu Ay9Q== X-Gm-Message-State: AO0yUKVBKW+Y1NR3pGzgn/8MYQhGP+1Q4M7+oeEcZI9zJRA1h/R6a2a9 yPLw0iLeKXh6/B6AM+ftPu0t3Q== X-Google-Smtp-Source: AK7set/cNdM7jQ++k3nkvmJwAiZ7hCs3e8eESAMApYjctdji+9SeV4nFRuXMKCMeNkcSGRS+KeksmA== X-Received: by 2002:a05:600c:4aa8:b0:3eb:3947:41ea with SMTP id b40-20020a05600c4aa800b003eb394741eamr7902497wmp.37.1677784131868; Thu, 02 Mar 2023 11:08:51 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= , Fabiano Rosas Subject: [PATCH v4 10/26] gdbstub: move chunk of softmmu functionality to own file Date: Thu, 2 Mar 2023 19:08:30 +0000 Message-Id: <20230302190846.2593720-11-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784346988100006 This is mostly code motion but a number of things needed to be done for this minimal patch set: - move shared structures to internals.h - splitting some functions into user and softmmu versions - fixing a few casting issues to keep softmmu common More CONFIG_USER_ONLY stuff will be handled in a following patches. Reviewed-by: Richard Henderson Reviewed-by: Fabiano Rosas Signed-off-by: Alex Benn=C3=A9e --- v3 - rebase fixes - move extern to internals.h v4 - checkpatch updates --- gdbstub/internals.h | 43 ++++- gdbstub/gdbstub.c | 421 +----------------------------------------- gdbstub/softmmu.c | 423 +++++++++++++++++++++++++++++++++++++++++++ gdbstub/trace-events | 4 +- 4 files changed, 478 insertions(+), 413 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index cf76627cf7..83989af859 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -17,6 +17,18 @@ * Shared structures and definitions */ =20 +enum { + GDB_SIGNAL_0 =3D 0, + GDB_SIGNAL_INT =3D 2, + GDB_SIGNAL_QUIT =3D 3, + GDB_SIGNAL_TRAP =3D 5, + GDB_SIGNAL_ABRT =3D 6, + GDB_SIGNAL_ALRM =3D 14, + GDB_SIGNAL_IO =3D 23, + GDB_SIGNAL_XCPU =3D 24, + GDB_SIGNAL_UNKNOWN =3D 143 +}; + typedef struct GDBProcess { uint32_t pid; bool attached; @@ -57,6 +69,8 @@ typedef struct GDBState { int supported_sstep_flags; } GDBState; =20 +/* lives in main gdbstub.c */ +extern GDBState gdbserver_state; =20 /* * Inline utility function, convert from int to hex and back @@ -101,7 +115,6 @@ CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); =20 -void gdb_init_gdbserver_state(void); void gdb_create_default_process(GDBState *s); =20 /* @@ -109,6 +122,34 @@ void gdb_create_default_process(GDBState *s); */ void gdb_put_buffer(const uint8_t *buf, int len); =20 +/* + * Command handlers - either softmmu or user only + */ +void gdb_init_gdbserver_state(void); + +typedef enum GDBThreadIdKind { + GDB_ONE_THREAD =3D 0, + GDB_ALL_THREADS, /* One process, all threads */ + GDB_ALL_PROCESSES, + GDB_READ_THREAD_ERR +} GDBThreadIdKind; + +typedef union GdbCmdVariant { + const char *data; + uint8_t opcode; + unsigned long val_ul; + unsigned long long val_ull; + struct { + GDBThreadIdKind kind; + uint32_t pid; + uint32_t tid; + } thread_id; +} GdbCmdVariant; + +#define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) + +void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index f59ab12cc3..4b939c689c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -24,8 +24,6 @@ */ =20 #include "qemu/osdep.h" -#include "qapi/error.h" -#include "qemu/error-report.h" #include "qemu/ctype.h" #include "qemu/cutils.h" #include "qemu/module.h" @@ -34,9 +32,6 @@ #ifdef CONFIG_USER_ONLY #include "qemu.h" #else -#include "monitor/monitor.h" -#include "chardev/char.h" -#include "chardev/char-fe.h" #include "hw/cpu/cluster.h" #include "hw/boards.h" #endif @@ -88,30 +83,15 @@ static inline int target_memory_rw_debug(CPUState *cpu,= target_ulong addr, /* * Return the GDB index for a given vCPU state. * - * For user mode this is simply the thread id. In system mode GDB - * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. + * For user mode this is simply the thread id. */ +#if defined(CONFIG_USER_ONLY) int gdb_get_cpu_index(CPUState *cpu) { -#if defined(CONFIG_USER_ONLY) TaskState *ts =3D (TaskState *) cpu->opaque; return ts ? ts->ts_tid : -1; -#else - return cpu->cpu_index + 1; -#endif } - -enum { - GDB_SIGNAL_0 =3D 0, - GDB_SIGNAL_INT =3D 2, - GDB_SIGNAL_QUIT =3D 3, - GDB_SIGNAL_TRAP =3D 5, - GDB_SIGNAL_ABRT =3D 6, - GDB_SIGNAL_ALRM =3D 14, - GDB_SIGNAL_IO =3D 23, - GDB_SIGNAL_XCPU =3D 24, - GDB_SIGNAL_UNKNOWN =3D 143 -}; +#endif =20 #ifdef CONFIG_USER_ONLY =20 @@ -333,15 +313,9 @@ typedef struct { int running_state; } GDBUserState; static GDBUserState gdbserver_user_state; -#else -typedef struct { - CharBackend chr; - Chardev *mon_chr; -} GDBSystemState; -static GDBSystemState gdbserver_system_state; #endif =20 -static GDBState gdbserver_state; +GDBState gdbserver_state; =20 void gdb_init_gdbserver_state(void) { @@ -362,15 +336,6 @@ void gdb_init_gdbserver_state(void) gdbserver_state.sstep_flags &=3D gdbserver_state.supported_sstep_flags; } =20 -#ifndef CONFIG_USER_ONLY -static void reset_gdbserver_state(void) -{ - g_free(gdbserver_state.processes); - gdbserver_state.processes =3D NULL; - gdbserver_state.process_num =3D 0; -} -#endif - bool gdb_has_xml; =20 #ifdef CONFIG_USER_ONLY @@ -446,7 +411,7 @@ static bool stub_can_reverse(void) } =20 /* Resume execution. */ -static inline void gdb_continue(void) +static void gdb_continue(void) { =20 #ifdef CONFIG_USER_ONLY @@ -525,9 +490,9 @@ static int gdb_continue_partial(char *newstates) return res; } =20 +#ifdef CONFIG_USER_ONLY void gdb_put_buffer(const uint8_t *buf, int len) { -#ifdef CONFIG_USER_ONLY int ret; =20 while (len > 0) { @@ -540,12 +505,8 @@ void gdb_put_buffer(const uint8_t *buf, int len) len -=3D ret; } } -#else - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&gdbserver_system_state.chr, buf, len); -#endif } +#endif =20 /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) @@ -993,13 +954,6 @@ void gdb_append_thread_id(CPUState *cpu, GString *buf) } } =20 -typedef enum GDBThreadIdKind { - GDB_ONE_THREAD =3D 0, - GDB_ALL_THREADS, /* One process, all threads */ - GDB_ALL_PROCESSES, - GDB_READ_THREAD_ERR -} GDBThreadIdKind; - static GDBThreadIdKind read_thread_id(const char *buf, const char **end_bu= f, uint32_t *pid, uint32_t *tid) { @@ -1180,20 +1134,6 @@ out: return res; } =20 -typedef union GdbCmdVariant { - const char *data; - uint8_t opcode; - unsigned long val_ul; - unsigned long long val_ull; - struct { - GDBThreadIdKind kind; - uint32_t pid; - uint32_t tid; - } thread_id; -} GdbCmdVariant; - -#define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) - static const char *cmd_next_param(const char *param, const char delimiter) { static const char all_delimiters[] =3D ",;:=3D"; @@ -2025,32 +1965,6 @@ static void handle_query_offsets(GArray *params, voi= d *user_ctx) ts->info->data_offset); gdb_put_strbuf(); } -#else -static void handle_query_rcmd(GArray *params, void *user_ctx) -{ - const guint8 zero =3D 0; - int len; - - if (!params->len) { - gdb_put_packet("E22"); - return; - } - - len =3D strlen(get_param(params, 0)->data); - if (len % 2) { - gdb_put_packet("E01"); - return; - } - - g_assert(gdbserver_state.mem_buf->len =3D=3D 0); - len =3D len / 2; - gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); - g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); - qemu_chr_be_write(gdbserver_system_state.mon_chr, - gdbserver_state.mem_buf->data, - gdbserver_state.mem_buf->len); - gdb_put_packet("OK"); -} #endif =20 static void handle_query_supported(GArray *params, void *user_ctx) @@ -2264,7 +2178,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = =3D { }, #else { - .handler =3D handle_query_rcmd, + .handler =3D gdb_handle_query_rcmd, .cmd =3D "Rcmd,", .cmd_startswith =3D 1, .schema =3D "s0" @@ -2648,100 +2562,6 @@ void gdb_set_stop_cpu(CPUState *cpu) gdbserver_state.g_cpu =3D cpu; } =20 -#ifndef CONFIG_USER_ONLY -static void gdb_vm_state_change(void *opaque, bool running, RunState state) -{ - CPUState *cpu =3D gdbserver_state.c_cpu; - g_autoptr(GString) buf =3D g_string_new(NULL); - g_autoptr(GString) tid =3D g_string_new(NULL); - const char *type; - int ret; - - if (running || gdbserver_state.state =3D=3D RS_INACTIVE) { - return; - } - /* Is there a GDB syscall waiting to be sent? */ - if (gdbserver_state.current_syscall_cb) { - gdb_put_packet(gdbserver_state.syscall_buf); - return; - } - - if (cpu =3D=3D NULL) { - /* No process attached */ - return; - } - - gdb_append_thread_id(cpu, tid); - - switch (state) { - case RUN_STATE_DEBUG: - if (cpu->watchpoint_hit) { - switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { - case BP_MEM_READ: - type =3D "r"; - break; - case BP_MEM_ACCESS: - type =3D "a"; - break; - default: - type =3D ""; - break; - } - trace_gdbstub_hit_watchpoint(type, gdb_get_cpu_index(cpu), - (target_ulong)cpu->watchpoint_hit->vaddr); - g_string_printf(buf, "T%02xthread:%s;%swatch:" TARGET_FMT_lx "= ;", - GDB_SIGNAL_TRAP, tid->str, type, - (target_ulong)cpu->watchpoint_hit->vaddr); - cpu->watchpoint_hit =3D NULL; - goto send_packet; - } else { - trace_gdbstub_hit_break(); - } - tb_flush(cpu); - ret =3D GDB_SIGNAL_TRAP; - break; - case RUN_STATE_PAUSED: - trace_gdbstub_hit_paused(); - ret =3D GDB_SIGNAL_INT; - break; - case RUN_STATE_SHUTDOWN: - trace_gdbstub_hit_shutdown(); - ret =3D GDB_SIGNAL_QUIT; - break; - case RUN_STATE_IO_ERROR: - trace_gdbstub_hit_io_error(); - ret =3D GDB_SIGNAL_IO; - break; - case RUN_STATE_WATCHDOG: - trace_gdbstub_hit_watchdog(); - ret =3D GDB_SIGNAL_ALRM; - break; - case RUN_STATE_INTERNAL_ERROR: - trace_gdbstub_hit_internal_error(); - ret =3D GDB_SIGNAL_ABRT; - break; - case RUN_STATE_SAVE_VM: - case RUN_STATE_RESTORE_VM: - return; - case RUN_STATE_FINISH_MIGRATE: - ret =3D GDB_SIGNAL_XCPU; - break; - default: - trace_gdbstub_hit_unknown(state); - ret =3D GDB_SIGNAL_UNKNOWN; - break; - } - gdb_set_stop_cpu(cpu); - g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); - -send_packet: - gdb_put_packet(buf->str); - - /* disable single step if it was enabled */ - cpu_single_step(cpu, 0); -} -#endif - /* Send a gdb syscall request. This accepts limited printf-style format specifiers, specifically: %x - target_ulong argument printed in hex. @@ -2971,6 +2791,7 @@ void gdb_read_byte(uint8_t ch) } } =20 +#ifdef CONFIG_USER_ONLY /* Tell the remote gdb that the process has exited. */ void gdb_exit(int code) { @@ -2979,24 +2800,19 @@ void gdb_exit(int code) if (!gdbserver_state.init) { return; } -#ifdef CONFIG_USER_ONLY if (gdbserver_user_state.socket_path) { unlink(gdbserver_user_state.socket_path); } if (gdbserver_user_state.fd < 0) { return; } -#endif =20 trace_gdbstub_op_exiting((uint8_t)code); =20 snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); gdb_put_packet(buf); - -#ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); -#endif } +#endif =20 /* * Create the process that will contain all the "orphan" CPUs (that are not @@ -3252,221 +3068,4 @@ void gdbserver_fork(CPUState *cpu) cpu_breakpoint_remove_all(cpu, BP_GDB); cpu_watchpoint_remove_all(cpu, BP_GDB); } -#else -static int gdb_chr_can_receive(void *opaque) -{ - /* We can handle an arbitrarily large amount of data. - Pick the maximum packet size, which is as good as anything. */ - return MAX_PACKET_LENGTH; -} - -static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) -{ - int i; - - for (i =3D 0; i < size; i++) { - gdb_read_byte(buf[i]); - } -} - -static void gdb_chr_event(void *opaque, QEMUChrEvent event) -{ - int i; - GDBState *s =3D (GDBState *) opaque; - - switch (event) { - case CHR_EVENT_OPENED: - /* Start with first process attached, others detached */ - for (i =3D 0; i < s->process_num; i++) { - s->processes[i].attached =3D !i; - } - - s->c_cpu =3D gdb_first_attached_cpu(); - s->g_cpu =3D s->c_cpu; - - vm_stop(RUN_STATE_PAUSED); - replay_gdb_attached(); - gdb_has_xml =3D false; - break; - default: - break; - } -} - -static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) -{ - g_autoptr(GString) hex_buf =3D g_string_new("O"); - gdb_memtohex(hex_buf, buf, len); - gdb_put_packet(hex_buf->str); - return len; -} - -#ifndef _WIN32 -static void gdb_sigterm_handler(int signal) -{ - if (runstate_is_running()) { - vm_stop(RUN_STATE_PAUSED); - } -} -#endif - -static void gdb_monitor_open(Chardev *chr, ChardevBackend *backend, - bool *be_opened, Error **errp) -{ - *be_opened =3D false; -} - -static void char_gdb_class_init(ObjectClass *oc, void *data) -{ - ChardevClass *cc =3D CHARDEV_CLASS(oc); - - cc->internal =3D true; - cc->open =3D gdb_monitor_open; - cc->chr_write =3D gdb_monitor_write; -} - -#define TYPE_CHARDEV_GDB "chardev-gdb" - -static const TypeInfo char_gdb_type_info =3D { - .name =3D TYPE_CHARDEV_GDB, - .parent =3D TYPE_CHARDEV, - .class_init =3D char_gdb_class_init, -}; - -static int find_cpu_clusters(Object *child, void *opaque) -{ - if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { - GDBState *s =3D (GDBState *) opaque; - CPUClusterState *cluster =3D CPU_CLUSTER(child); - GDBProcess *process; - - s->processes =3D g_renew(GDBProcess, s->processes, ++s->process_nu= m); - - process =3D &s->processes[s->process_num - 1]; - - /* - * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at - * runtime, we enforce here that the machine does not use a cluste= r ID - * that would lead to PID 0. - */ - assert(cluster->cluster_id !=3D UINT32_MAX); - process->pid =3D cluster->cluster_id + 1; - process->attached =3D false; - process->target_xml[0] =3D '\0'; - - return 0; - } - - return object_child_foreach(child, find_cpu_clusters, opaque); -} - -static int pid_order(const void *a, const void *b) -{ - GDBProcess *pa =3D (GDBProcess *) a; - GDBProcess *pb =3D (GDBProcess *) b; - - if (pa->pid < pb->pid) { - return -1; - } else if (pa->pid > pb->pid) { - return 1; - } else { - return 0; - } -} - -static void create_processes(GDBState *s) -{ - object_child_foreach(object_get_root(), find_cpu_clusters, s); - - if (gdbserver_state.processes) { - /* Sort by PID */ - qsort(gdbserver_state.processes, gdbserver_state.process_num, size= of(gdbserver_state.processes[0]), pid_order); - } - - gdb_create_default_process(s); -} - -int gdbserver_start(const char *device) -{ - trace_gdbstub_op_start(device); - - char gdbstub_device_name[128]; - Chardev *chr =3D NULL; - Chardev *mon_chr; - - if (!first_cpu) { - error_report("gdbstub: meaningless to attach gdb to a " - "machine without any CPU."); - return -1; - } - - if (!gdb_supports_guest_debug()) { - error_report("gdbstub: current accelerator doesn't support guest d= ebugging"); - return -1; - } - - if (!device) - return -1; - if (strcmp(device, "none") !=3D 0) { - if (strstart(device, "tcp:", NULL)) { - /* enforce required TCP attributes */ - snprintf(gdbstub_device_name, sizeof(gdbstub_device_name), - "%s,wait=3Doff,nodelay=3Don,server=3Don", device); - device =3D gdbstub_device_name; - } -#ifndef _WIN32 - else if (strcmp(device, "stdio") =3D=3D 0) { - struct sigaction act; - - memset(&act, 0, sizeof(act)); - act.sa_handler =3D gdb_sigterm_handler; - sigaction(SIGINT, &act, NULL); - } -#endif - /* - * FIXME: it's a bit weird to allow using a mux chardev here - * and implicitly setup a monitor. We may want to break this. - */ - chr =3D qemu_chr_new_noreplay("gdb", device, true, NULL); - if (!chr) - return -1; - } - - if (!gdbserver_state.init) { - gdb_init_gdbserver_state(); - - qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); - - /* Initialize a monitor terminal for gdb */ - mon_chr =3D qemu_chardev_new(NULL, TYPE_CHARDEV_GDB, - NULL, NULL, &error_abort); - monitor_init_hmp(mon_chr, false, &error_abort); - } else { - qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); - mon_chr =3D gdbserver_system_state.mon_chr; - reset_gdbserver_state(); - } - - create_processes(&gdbserver_state); - - if (chr) { - qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, - gdb_chr_can_receive, - gdb_chr_receive, gdb_chr_event, - NULL, &gdbserver_state, NULL, true); - } - gdbserver_state.state =3D chr ? RS_IDLE : RS_INACTIVE; - gdbserver_system_state.mon_chr =3D mon_chr; - gdbserver_state.current_syscall_cb =3D NULL; - - return 0; -} - -static void register_types(void) -{ - type_register_static(&char_gdb_type_info); -} - -type_init(register_types); #endif diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 05db6f8a9f..86a94f1519 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -11,10 +11,433 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/cutils.h" #include "exec/gdbstub.h" +#include "exec/hwaddr.h" +#include "exec/tb-flush.h" #include "sysemu/cpus.h" +#include "sysemu/runstate.h" +#include "sysemu/replay.h" +#include "hw/core/cpu.h" +#include "hw/cpu/cluster.h" +#include "hw/boards.h" +#include "chardev/char.h" +#include "chardev/char-fe.h" +#include "monitor/monitor.h" +#include "trace.h" #include "internals.h" =20 +/* System emulation specific state */ +typedef struct { + CharBackend chr; + Chardev *mon_chr; +} GDBSystemState; + +GDBSystemState gdbserver_system_state; + +static void reset_gdbserver_state(void) +{ + g_free(gdbserver_state.processes); + gdbserver_state.processes =3D NULL; + gdbserver_state.process_num =3D 0; +} + +/* + * Return the GDB index for a given vCPU state. + * + * In system mode GDB numbers CPUs from 1 as 0 is reserved as an "any + * cpu" index. + */ +int gdb_get_cpu_index(CPUState *cpu) +{ + return cpu->cpu_index + 1; +} + +/* + * GDB Connection management. For system emulation we do all of this + * via our existing Chardev infrastructure which allows us to support + * network and unix sockets. + */ + +void gdb_put_buffer(const uint8_t *buf, int len) +{ + /* + * XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks + */ + qemu_chr_fe_write_all(&gdbserver_system_state.chr, buf, len); +} + +static void gdb_chr_event(void *opaque, QEMUChrEvent event) +{ + int i; + GDBState *s =3D (GDBState *) opaque; + + switch (event) { + case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i =3D 0; i < s->process_num; i++) { + s->processes[i].attached =3D !i; + } + + s->c_cpu =3D gdb_first_attached_cpu(); + s->g_cpu =3D s->c_cpu; + + vm_stop(RUN_STATE_PAUSED); + replay_gdb_attached(); + gdb_has_xml =3D false; + break; + default: + break; + } +} + +static void gdb_vm_state_change(void *opaque, bool running, RunState state) +{ + CPUState *cpu =3D gdbserver_state.c_cpu; + g_autoptr(GString) buf =3D g_string_new(NULL); + g_autoptr(GString) tid =3D g_string_new(NULL); + const char *type; + int ret; + + if (running || gdbserver_state.state =3D=3D RS_INACTIVE) { + return; + } + /* Is there a GDB syscall waiting to be sent? */ + if (gdbserver_state.current_syscall_cb) { + gdb_put_packet(gdbserver_state.syscall_buf); + return; + } + + if (cpu =3D=3D NULL) { + /* No process attached */ + return; + } + + gdb_append_thread_id(cpu, tid); + + switch (state) { + case RUN_STATE_DEBUG: + if (cpu->watchpoint_hit) { + switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { + case BP_MEM_READ: + type =3D "r"; + break; + case BP_MEM_ACCESS: + type =3D "a"; + break; + default: + type =3D ""; + break; + } + trace_gdbstub_hit_watchpoint(type, + gdb_get_cpu_index(cpu), + cpu->watchpoint_hit->vaddr); + g_string_printf(buf, "T%02xthread:%s;%swatch:%" VADDR_PRIx ";", + GDB_SIGNAL_TRAP, tid->str, type, + cpu->watchpoint_hit->vaddr); + cpu->watchpoint_hit =3D NULL; + goto send_packet; + } else { + trace_gdbstub_hit_break(); + } + tb_flush(cpu); + ret =3D GDB_SIGNAL_TRAP; + break; + case RUN_STATE_PAUSED: + trace_gdbstub_hit_paused(); + ret =3D GDB_SIGNAL_INT; + break; + case RUN_STATE_SHUTDOWN: + trace_gdbstub_hit_shutdown(); + ret =3D GDB_SIGNAL_QUIT; + break; + case RUN_STATE_IO_ERROR: + trace_gdbstub_hit_io_error(); + ret =3D GDB_SIGNAL_IO; + break; + case RUN_STATE_WATCHDOG: + trace_gdbstub_hit_watchdog(); + ret =3D GDB_SIGNAL_ALRM; + break; + case RUN_STATE_INTERNAL_ERROR: + trace_gdbstub_hit_internal_error(); + ret =3D GDB_SIGNAL_ABRT; + break; + case RUN_STATE_SAVE_VM: + case RUN_STATE_RESTORE_VM: + return; + case RUN_STATE_FINISH_MIGRATE: + ret =3D GDB_SIGNAL_XCPU; + break; + default: + trace_gdbstub_hit_unknown(state); + ret =3D GDB_SIGNAL_UNKNOWN; + break; + } + gdb_set_stop_cpu(cpu); + g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); + +send_packet: + gdb_put_packet(buf->str); + + /* disable single step if it was enabled */ + cpu_single_step(cpu, 0); +} + +#ifndef _WIN32 +static void gdb_sigterm_handler(int signal) +{ + if (runstate_is_running()) { + vm_stop(RUN_STATE_PAUSED); + } +} +#endif + +static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) +{ + g_autoptr(GString) hex_buf =3D g_string_new("O"); + gdb_memtohex(hex_buf, buf, len); + gdb_put_packet(hex_buf->str); + return len; +} + +static void gdb_monitor_open(Chardev *chr, ChardevBackend *backend, + bool *be_opened, Error **errp) +{ + *be_opened =3D false; +} + +static void char_gdb_class_init(ObjectClass *oc, void *data) +{ + ChardevClass *cc =3D CHARDEV_CLASS(oc); + + cc->internal =3D true; + cc->open =3D gdb_monitor_open; + cc->chr_write =3D gdb_monitor_write; +} + +#define TYPE_CHARDEV_GDB "chardev-gdb" + +static const TypeInfo char_gdb_type_info =3D { + .name =3D TYPE_CHARDEV_GDB, + .parent =3D TYPE_CHARDEV, + .class_init =3D char_gdb_class_init, +}; + +static int gdb_chr_can_receive(void *opaque) +{ + /* + * We can handle an arbitrarily large amount of data. + * Pick the maximum packet size, which is as good as anything. + */ + return MAX_PACKET_LENGTH; +} + +static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) +{ + int i; + + for (i =3D 0; i < size; i++) { + gdb_read_byte(buf[i]); + } +} + +static int find_cpu_clusters(Object *child, void *opaque) +{ + if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { + GDBState *s =3D (GDBState *) opaque; + CPUClusterState *cluster =3D CPU_CLUSTER(child); + GDBProcess *process; + + s->processes =3D g_renew(GDBProcess, s->processes, ++s->process_nu= m); + + process =3D &s->processes[s->process_num - 1]; + + /* + * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at + * runtime, we enforce here that the machine does not use a cluste= r ID + * that would lead to PID 0. + */ + assert(cluster->cluster_id !=3D UINT32_MAX); + process->pid =3D cluster->cluster_id + 1; + process->attached =3D false; + process->target_xml[0] =3D '\0'; + + return 0; + } + + return object_child_foreach(child, find_cpu_clusters, opaque); +} + +static int pid_order(const void *a, const void *b) +{ + GDBProcess *pa =3D (GDBProcess *) a; + GDBProcess *pb =3D (GDBProcess *) b; + + if (pa->pid < pb->pid) { + return -1; + } else if (pa->pid > pb->pid) { + return 1; + } else { + return 0; + } +} + +static void create_processes(GDBState *s) +{ + object_child_foreach(object_get_root(), find_cpu_clusters, s); + + if (gdbserver_state.processes) { + /* Sort by PID */ + qsort(gdbserver_state.processes, + gdbserver_state.process_num, + sizeof(gdbserver_state.processes[0]), + pid_order); + } + + gdb_create_default_process(s); +} + +int gdbserver_start(const char *device) +{ + trace_gdbstub_op_start(device); + + char gdbstub_device_name[128]; + Chardev *chr =3D NULL; + Chardev *mon_chr; + + if (!first_cpu) { + error_report("gdbstub: meaningless to attach gdb to a " + "machine without any CPU."); + return -1; + } + + if (!gdb_supports_guest_debug()) { + error_report("gdbstub: current accelerator doesn't " + "support guest debugging"); + return -1; + } + + if (!device) { + return -1; + } + if (strcmp(device, "none") !=3D 0) { + if (strstart(device, "tcp:", NULL)) { + /* enforce required TCP attributes */ + snprintf(gdbstub_device_name, sizeof(gdbstub_device_name), + "%s,wait=3Doff,nodelay=3Don,server=3Don", device); + device =3D gdbstub_device_name; + } +#ifndef _WIN32 + else if (strcmp(device, "stdio") =3D=3D 0) { + struct sigaction act; + + memset(&act, 0, sizeof(act)); + act.sa_handler =3D gdb_sigterm_handler; + sigaction(SIGINT, &act, NULL); + } +#endif + /* + * FIXME: it's a bit weird to allow using a mux chardev here + * and implicitly setup a monitor. We may want to break this. + */ + chr =3D qemu_chr_new_noreplay("gdb", device, true, NULL); + if (!chr) { + return -1; + } + } + + if (!gdbserver_state.init) { + gdb_init_gdbserver_state(); + + qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); + + /* Initialize a monitor terminal for gdb */ + mon_chr =3D qemu_chardev_new(NULL, TYPE_CHARDEV_GDB, + NULL, NULL, &error_abort); + monitor_init_hmp(mon_chr, false, &error_abort); + } else { + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); + mon_chr =3D gdbserver_system_state.mon_chr; + reset_gdbserver_state(); + } + + create_processes(&gdbserver_state); + + if (chr) { + qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, + gdb_chr_can_receive, + gdb_chr_receive, gdb_chr_event, + NULL, &gdbserver_state, NULL, true); + } + gdbserver_state.state =3D chr ? RS_IDLE : RS_INACTIVE; + gdbserver_system_state.mon_chr =3D mon_chr; + gdbserver_state.current_syscall_cb =3D NULL; + + return 0; +} + +static void register_types(void) +{ + type_register_static(&char_gdb_type_info); +} + +type_init(register_types); + +/* Tell the remote gdb that the process has exited. */ +void gdb_exit(int code) +{ + char buf[4]; + + if (!gdbserver_state.init) { + return; + } + + trace_gdbstub_op_exiting((uint8_t)code); + + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + gdb_put_packet(buf); + + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); +} + +/* + * Softmmu specific command helpers + */ +void gdb_handle_query_rcmd(GArray *params, void *user_ctx) +{ + const guint8 zero =3D 0; + int len; + + if (!params->len) { + gdb_put_packet("E22"); + return; + } + + len =3D strlen(get_param(params, 0)->data); + if (len % 2) { + gdb_put_packet("E01"); + return; + } + + g_assert(gdbserver_state.mem_buf->len =3D=3D 0); + len =3D len / 2; + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); + g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); + qemu_chr_be_write(gdbserver_system_state.mon_chr, + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len); + gdb_put_packet("OK"); +} + +/* + * Break/Watch point helpers + */ + bool gdb_supports_guest_debug(void) { const AccelOpsClass *ops =3D cpus_get_accel(); diff --git a/gdbstub/trace-events b/gdbstub/trace-events index 03f0c303bf..0c18a4d70a 100644 --- a/gdbstub/trace-events +++ b/gdbstub/trace-events @@ -7,7 +7,6 @@ gdbstub_op_continue(void) "Continuing all CPUs" gdbstub_op_continue_cpu(int cpu_index) "Continuing CPU %d" gdbstub_op_stepping(int cpu_index) "Stepping CPU %d" gdbstub_op_extra_info(const char *info) "Thread extra info: %s" -gdbstub_hit_watchpoint(const char *type, int cpu_gdb_index, uint64_t vaddr= ) "Watchpoint hit, type=3D\"%s\" cpu=3D%d, vaddr=3D0x%" PRIx64 "" gdbstub_hit_internal_error(void) "RUN_STATE_INTERNAL_ERROR" gdbstub_hit_break(void) "RUN_STATE_DEBUG" gdbstub_hit_paused(void) "RUN_STATE_PAUSED" @@ -27,3 +26,6 @@ gdbstub_err_invalid_repeat(uint8_t ch) "got invalid RLE c= ount: 0x%02x" gdbstub_err_invalid_rle(void) "got invalid RLE sequence" gdbstub_err_checksum_invalid(uint8_t ch) "got invalid command checksum dig= it: 0x%02x" gdbstub_err_checksum_incorrect(uint8_t expected, uint8_t got) "got command= packet with incorrect checksum, expected=3D0x%02x, received=3D0x%02x" + +# softmmu.c +gdbstub_hit_watchpoint(const char *type, int cpu_gdb_index, uint64_t vaddr= ) "Watchpoint hit, type=3D\"%s\" cpu=3D%d, vaddr=3D0x%" PRIx64 "" --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784445; cv=none; d=zohomail.com; s=zohoarc; b=liPnVQYOpmCJp1KT8E9qNeBP6S5EUNmVsn7TAO3j/Bm0+awg9ZSKoANH0V0d0BZfXAOHn0L0qpnpDF0TaAlnnHb2L8w+NflOq/vstbxoA96irFW4wHwCfEkpP3D2FkBApx3/S3NESCr7TyfMBbFItosYWIGPLR0brnhMAR49VyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F0Kn9OKT1TQEx0v0tI79gonDvUx2BQPcVJJf3idPjHc=; b=R7gAWXujoKv7zSEouymx2wLcSkmlzvqT8DMvYzmVEEufv9reoy8csVnyLSIGDMsGmOJtnkyTqDW/F6rJBDH3JCIafpIcJq8NPS8wpddIhG6BV1rHs2N6PiUl2fN2AaceaIT7d3yqC0x7/w/PatGSMoc8aLYB7OtTTgsAnYXU85E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784445598228.59262016481853; Thu, 2 Mar 2023 11:14:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIn-0007fk-MY; Thu, 02 Mar 2023 14:09:17 -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 1pXoIl-0007el-Uo for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:15 -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 1pXoIR-0004ZU-1c for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:15 -0500 Received: by mail-wm1-x32e.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso2558673wmb.0 for ; Thu, 02 Mar 2023 11:08:54 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id c16-20020a5d4cd0000000b002be0b1e556esm141148wrt.59.2023.03.02.11.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:52 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2A47C1FFBA; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) 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=F0Kn9OKT1TQEx0v0tI79gonDvUx2BQPcVJJf3idPjHc=; b=f4sKtOPmZUsLLUAunpIP+ACCCAT5c/PvN0xxPldEZCgh72Bmo/6Kqp7MglXCKLm91k BhjxD/W7ikdNVAJTBuhR4gMv22X37bKUpGoW7NNr9z8MQ1a45J3//2paWOXiJNKGuA3G 8J+u815bWq9gwUXzrBxgZauPdg5/ghNWoV49/kjSRZZYdPMd1fTf5fmI+kijafutIQiR D1NSF0u5QFVdKmd3WJ8p69GqnLHwo+WSp3DM81cH/BURMihIhoKt1QFwKhqSpTap6XwR p/ydqTGC3YeAt7ms0NeREQnBtTTNR2WL86/mWMwiLSptiwbJYHSZX2+yfC5Gg+Gm3DZm x3ow== 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=F0Kn9OKT1TQEx0v0tI79gonDvUx2BQPcVJJf3idPjHc=; b=Z5GGjEzh/ETiUCKm6mGi70g3kusoNoHI5PdxTtaGgG3ojcNmYmj6GiujjKZgEOmF3U HUbIup3oUJl2yG7NeWfy1BurpggVkaNS6HPaxQW7lMpPS/UrQzF6evaGQzsxn1jblbtk 4Bafmap7VrASOAcpYZ5BIyZYWjR7C2RGSQoD+sNwnMqWHY2tkETQdo/JINHV3mN7UJf3 kdDr3m5g4Ks5FANTc52Ih1vqdDIrjnLezxCEbjxkHwusfoHZSPy8f9ey6bEe2K/ye6AA pZaEiubA62QpdsRuH6sAuPW2/NV96JuTIRyUmW4tutJpqOXMRDrb5nHAC5iud9SdJlHx tGNA== X-Gm-Message-State: AO0yUKVmniNlB1KpE//Zob5FTx4UkaGlANuLjdDz9uk+/1x429Xza0sx /AJyDz3l47AaF2Q5H2ZPm51Bnw== X-Google-Smtp-Source: AK7set8y6lU0E7o64Ye7NwCcI0Iou6OmUeSSQJO9dVUWmr/nai0yEsprlgubVBj1KYQ9/r9baRjjAQ== X-Received: by 2002:a05:600c:3b14:b0:3ea:d620:57a7 with SMTP id m20-20020a05600c3b1400b003ead62057a7mr8869099wms.8.1677784133345; Thu, 02 Mar 2023 11:08:53 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= , Fabiano Rosas Subject: [PATCH v4 11/26] gdbstub: move chunks of user code into own files Date: Thu, 2 Mar 2023 19:08:31 +0000 Message-Id: <20230302190846.2593720-12-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784447305100001 The process was pretty similar to the softmmu move except we take the time to split stuff between user.c and user-target.c to avoid as much target specific compilation as possible. We also start to make use of our shiny new header scheme so the user-only helpers can be included without the rest of the exec/gsbstub.h cruft. As before we split some functions into user and softmmu versions Reviewed-by: Fabiano Rosas Signed-off-by: Alex Benn=C3=A9e --- v2 - separate splitting of functions - create user.h here v3 - rebase cleanups - bring forward hunk to ensure all user-mode targets covered v4 - checkpatch cleanup --- MAINTAINERS | 1 + gdbstub/internals.h | 18 ++ include/exec/gdbstub.h | 21 -- include/gdbstub/user.h | 43 +++ gdbstub/gdbstub.c | 678 +---------------------------------------- gdbstub/softmmu.c | 90 ++++++ gdbstub/user-target.c | 283 +++++++++++++++++ gdbstub/user.c | 344 +++++++++++++++++++++ linux-user/main.c | 1 + linux-user/signal.c | 2 +- gdbstub/meson.build | 3 + 11 files changed, 788 insertions(+), 696 deletions(-) create mode 100644 include/gdbstub/user.h create mode 100644 gdbstub/user-target.c diff --git a/MAINTAINERS b/MAINTAINERS index 234800e3dc..c7a8e2307f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2735,6 +2735,7 @@ S: Maintained F: docs/system/gdb.rst F: gdbstub/* F: include/exec/gdbstub.h +F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ F: scripts/feature_to_c.sh diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 83989af859..6bd6a05657 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -117,6 +117,22 @@ int gdb_get_cpu_index(CPUState *cpu); =20 void gdb_create_default_process(GDBState *s); =20 +/* signal mapping, common for softmmu, specialised for user-mode */ +int gdb_signal_to_target(int sig); +int gdb_target_signal_to_gdb(int sig); + +int gdb_get_char(void); /* user only */ + +/** + * gdb_continue() - handle continue in mode specific way. + */ +void gdb_continue(void); + +/** + * gdb_continue_partial() - handle partial continue in mode specific way. + */ +int gdb_continue_partial(char *newstates); + /* * Helpers with separate softmmu and user implementations */ @@ -149,6 +165,8 @@ typedef union GdbCmdVariant { #define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) =20 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 */ =20 /* * Break/Watch point support - there is an implementation for softmmu diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 1636fb3841..8fff5450ed 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -103,27 +103,6 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const = char *fmt, ...); void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list = va); int use_gdb_syscalls(void); =20 -#ifdef CONFIG_USER_ONLY -/** - * gdb_handlesig: yield control to gdb - * @cpu: CPU - * @sig: if non-zero, the signal number which caused us to stop - * - * This function yields control to gdb, when a user-mode-only target - * needs to stop execution. If @sig is non-zero, then we will send a - * stop packet to tell gdb that we have stopped because of this signal. - * - * This function will block (handling protocol requests from gdb) - * until gdb tells us to continue target execution. When it does - * return, the return value is a signal to deliver to the target, - * or 0 if no signal should be delivered, ie the signal that caused - * us to stop should be ignored. - */ -int gdb_handlesig(CPUState *, int); -void gdb_signalled(CPUArchState *, int); -void gdbserver_fork(CPUState *); -#endif - /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h new file mode 100644 index 0000000000..d392e510c5 --- /dev/null +++ b/include/gdbstub/user.h @@ -0,0 +1,43 @@ +/* + * gdbstub user-mode only APIs + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#ifndef GDBSTUB_USER_H +#define GDBSTUB_USER_H + +/** + * gdb_handlesig() - yield control to gdb + * @cpu: CPU + * @sig: if non-zero, the signal number which caused us to stop + * + * This function yields control to gdb, when a user-mode-only target + * needs to stop execution. If @sig is non-zero, then we will send a + * stop packet to tell gdb that we have stopped because of this signal. + * + * This function will block (handling protocol requests from gdb) + * until gdb tells us to continue target execution. When it does + * return, the return value is a signal to deliver to the target, + * or 0 if no signal should be delivered, ie the signal that caused + * us to stop should be ignored. + */ +int gdb_handlesig(CPUState *, int); + +/** + * gdb_signalled() - inform remote gdb of sig exit + * @as: current CPUArchState + * @sig: signal number + */ +void gdb_signalled(CPUArchState *as, int sig); + +/** + * gdbserver_fork() - disable gdb stub for child processes. + * @cs: CPU + */ +void gdbserver_fork(CPUState *cs); + + +#endif /* GDBSTUB_USER_H */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 4b939c689c..6907bdc99c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -30,13 +30,12 @@ #include "trace.h" #include "exec/gdbstub.h" #ifdef CONFIG_USER_ONLY -#include "qemu.h" +#include "gdbstub/user.h" #else #include "hw/cpu/cluster.h" #include "hw/boards.h" #endif =20 -#include "qemu/sockets.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" #include "semihosting/semihost.h" @@ -80,223 +79,6 @@ static inline int target_memory_rw_debug(CPUState *cpu,= target_ulong addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } =20 -/* - * Return the GDB index for a given vCPU state. - * - * For user mode this is simply the thread id. - */ -#if defined(CONFIG_USER_ONLY) -int gdb_get_cpu_index(CPUState *cpu) -{ - TaskState *ts =3D (TaskState *) cpu->opaque; - return ts ? ts->ts_tid : -1; -} -#endif - -#ifdef CONFIG_USER_ONLY - -/* Map target signal numbers to GDB protocol signal numbers and vice - * versa. For user emulation's currently supported systems, we can - * assume most signals are defined. - */ - -static int gdb_signal_table[] =3D { - 0, - TARGET_SIGHUP, - TARGET_SIGINT, - TARGET_SIGQUIT, - TARGET_SIGILL, - TARGET_SIGTRAP, - TARGET_SIGABRT, - -1, /* SIGEMT */ - TARGET_SIGFPE, - TARGET_SIGKILL, - TARGET_SIGBUS, - TARGET_SIGSEGV, - TARGET_SIGSYS, - TARGET_SIGPIPE, - TARGET_SIGALRM, - TARGET_SIGTERM, - TARGET_SIGURG, - TARGET_SIGSTOP, - TARGET_SIGTSTP, - TARGET_SIGCONT, - TARGET_SIGCHLD, - TARGET_SIGTTIN, - TARGET_SIGTTOU, - TARGET_SIGIO, - TARGET_SIGXCPU, - TARGET_SIGXFSZ, - TARGET_SIGVTALRM, - TARGET_SIGPROF, - TARGET_SIGWINCH, - -1, /* SIGLOST */ - TARGET_SIGUSR1, - TARGET_SIGUSR2, -#ifdef TARGET_SIGPWR - TARGET_SIGPWR, -#else - -1, -#endif - -1, /* SIGPOLL */ - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, -#ifdef __SIGRTMIN - __SIGRTMIN + 1, - __SIGRTMIN + 2, - __SIGRTMIN + 3, - __SIGRTMIN + 4, - __SIGRTMIN + 5, - __SIGRTMIN + 6, - __SIGRTMIN + 7, - __SIGRTMIN + 8, - __SIGRTMIN + 9, - __SIGRTMIN + 10, - __SIGRTMIN + 11, - __SIGRTMIN + 12, - __SIGRTMIN + 13, - __SIGRTMIN + 14, - __SIGRTMIN + 15, - __SIGRTMIN + 16, - __SIGRTMIN + 17, - __SIGRTMIN + 18, - __SIGRTMIN + 19, - __SIGRTMIN + 20, - __SIGRTMIN + 21, - __SIGRTMIN + 22, - __SIGRTMIN + 23, - __SIGRTMIN + 24, - __SIGRTMIN + 25, - __SIGRTMIN + 26, - __SIGRTMIN + 27, - __SIGRTMIN + 28, - __SIGRTMIN + 29, - __SIGRTMIN + 30, - __SIGRTMIN + 31, - -1, /* SIGCANCEL */ - __SIGRTMIN, - __SIGRTMIN + 32, - __SIGRTMIN + 33, - __SIGRTMIN + 34, - __SIGRTMIN + 35, - __SIGRTMIN + 36, - __SIGRTMIN + 37, - __SIGRTMIN + 38, - __SIGRTMIN + 39, - __SIGRTMIN + 40, - __SIGRTMIN + 41, - __SIGRTMIN + 42, - __SIGRTMIN + 43, - __SIGRTMIN + 44, - __SIGRTMIN + 45, - __SIGRTMIN + 46, - __SIGRTMIN + 47, - __SIGRTMIN + 48, - __SIGRTMIN + 49, - __SIGRTMIN + 50, - __SIGRTMIN + 51, - __SIGRTMIN + 52, - __SIGRTMIN + 53, - __SIGRTMIN + 54, - __SIGRTMIN + 55, - __SIGRTMIN + 56, - __SIGRTMIN + 57, - __SIGRTMIN + 58, - __SIGRTMIN + 59, - __SIGRTMIN + 60, - __SIGRTMIN + 61, - __SIGRTMIN + 62, - __SIGRTMIN + 63, - __SIGRTMIN + 64, - __SIGRTMIN + 65, - __SIGRTMIN + 66, - __SIGRTMIN + 67, - __SIGRTMIN + 68, - __SIGRTMIN + 69, - __SIGRTMIN + 70, - __SIGRTMIN + 71, - __SIGRTMIN + 72, - __SIGRTMIN + 73, - __SIGRTMIN + 74, - __SIGRTMIN + 75, - __SIGRTMIN + 76, - __SIGRTMIN + 77, - __SIGRTMIN + 78, - __SIGRTMIN + 79, - __SIGRTMIN + 80, - __SIGRTMIN + 81, - __SIGRTMIN + 82, - __SIGRTMIN + 83, - __SIGRTMIN + 84, - __SIGRTMIN + 85, - __SIGRTMIN + 86, - __SIGRTMIN + 87, - __SIGRTMIN + 88, - __SIGRTMIN + 89, - __SIGRTMIN + 90, - __SIGRTMIN + 91, - __SIGRTMIN + 92, - __SIGRTMIN + 93, - __SIGRTMIN + 94, - __SIGRTMIN + 95, - -1, /* SIGINFO */ - -1, /* UNKNOWN */ - -1, /* DEFAULT */ - -1, - -1, - -1, - -1, - -1, - -1 -#endif -}; -#else -/* In system mode we only need SIGINT and SIGTRAP; other signals - are not yet supported. */ - -enum { - TARGET_SIGINT =3D 2, - TARGET_SIGTRAP =3D 5 -}; - -static int gdb_signal_table[] =3D { - -1, - -1, - TARGET_SIGINT, - -1, - -1, - TARGET_SIGTRAP -}; -#endif - -#ifdef CONFIG_USER_ONLY -static int target_signal_to_gdb (int sig) -{ - int i; - for (i =3D 0; i < ARRAY_SIZE (gdb_signal_table); i++) - if (gdb_signal_table[i] =3D=3D sig) - return i; - return GDB_SIGNAL_UNKNOWN; -} -#endif - -static int gdb_signal_to_target (int sig) -{ - if (sig < ARRAY_SIZE (gdb_signal_table)) - return gdb_signal_table[sig]; - else - return -1; -} - typedef struct GDBRegisterState { int base_reg; int num_regs; @@ -306,15 +88,6 @@ typedef struct GDBRegisterState { struct GDBRegisterState *next; } GDBRegisterState; =20 -#ifdef CONFIG_USER_ONLY -typedef struct { - int fd; - char *socket_path; - int running_state; -} GDBUserState; -static GDBUserState gdbserver_user_state; -#endif - GDBState gdbserver_state; =20 void gdb_init_gdbserver_state(void) @@ -338,34 +111,6 @@ void gdb_init_gdbserver_state(void) =20 bool gdb_has_xml; =20 -#ifdef CONFIG_USER_ONLY - -static int get_char(void) -{ - uint8_t ch; - int ret; - - for(;;) { - ret =3D recv(gdbserver_user_state.fd, &ch, 1, 0); - if (ret < 0) { - if (errno =3D=3D ECONNRESET) { - gdbserver_user_state.fd =3D -1; - } - if (errno !=3D EINTR) { - return -1; - } - } else if (ret =3D=3D 0) { - close(gdbserver_user_state.fd); - gdbserver_user_state.fd =3D -1; - return -1; - } else { - break; - } - } - return ch; -} -#endif - /* * Return true if there is a GDB currently connected to the stub * and attached to a CPU @@ -410,104 +155,6 @@ static bool stub_can_reverse(void) #endif } =20 -/* Resume execution. */ -static void gdb_continue(void) -{ - -#ifdef CONFIG_USER_ONLY - gdbserver_user_state.running_state =3D 1; - trace_gdbstub_op_continue(); -#else - if (!runstate_needs_reset()) { - trace_gdbstub_op_continue(); - vm_start(); - } -#endif -} - -/* - * Resume execution, per CPU actions. For user-mode emulation it's - * equivalent to gdb_continue. - */ -static int gdb_continue_partial(char *newstates) -{ - CPUState *cpu; - int res =3D 0; -#ifdef CONFIG_USER_ONLY - /* - * This is not exactly accurate, but it's an improvement compared to t= he - * previous situation, where only one CPU would be single-stepped. - */ - CPU_FOREACH(cpu) { - if (newstates[cpu->cpu_index] =3D=3D 's') { - trace_gdbstub_op_stepping(cpu->cpu_index); - cpu_single_step(cpu, gdbserver_state.sstep_flags); - } - } - gdbserver_user_state.running_state =3D 1; -#else - int flag =3D 0; - - if (!runstate_needs_reset()) { - bool step_requested =3D false; - CPU_FOREACH(cpu) { - if (newstates[cpu->cpu_index] =3D=3D 's') { - step_requested =3D true; - break; - } - } - - if (vm_prepare_start(step_requested)) { - return 0; - } - - CPU_FOREACH(cpu) { - switch (newstates[cpu->cpu_index]) { - case 0: - case 1: - break; /* nothing to do here */ - case 's': - trace_gdbstub_op_stepping(cpu->cpu_index); - cpu_single_step(cpu, gdbserver_state.sstep_flags); - cpu_resume(cpu); - flag =3D 1; - break; - case 'c': - trace_gdbstub_op_continue_cpu(cpu->cpu_index); - cpu_resume(cpu); - flag =3D 1; - break; - default: - res =3D -1; - break; - } - } - } - if (flag) { - qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true); - } -#endif - return res; -} - -#ifdef CONFIG_USER_ONLY -void gdb_put_buffer(const uint8_t *buf, int len) -{ - int ret; - - while (len > 0) { - ret =3D send(gdbserver_user_state.fd, buf, len, 0); - if (ret < 0) { - if (errno !=3D EINTR) - return; - } else { - buf +=3D ret; - len -=3D ret; - } - } -} -#endif - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -593,7 +240,7 @@ int gdb_put_packet_binary(const char *buf, int len, boo= l dump) gdbserver_state.last_packet->len); =20 #ifdef CONFIG_USER_ONLY - i =3D get_char(); + i =3D gdb_get_char(); if (i < 0) return -1; if (i =3D=3D '+') @@ -1950,23 +1597,6 @@ static void handle_query_thread_extra(GArray *params= , void *user_ctx) gdb_put_strbuf(); } =20 -#ifdef CONFIG_USER_ONLY -static void handle_query_offsets(GArray *params, void *user_ctx) -{ - TaskState *ts; - - ts =3D gdbserver_state.c_cpu->opaque; - g_string_printf(gdbserver_state.str_buf, - "Text=3D" TARGET_ABI_FMT_lx - ";Data=3D" TARGET_ABI_FMT_lx - ";Bss=3D" TARGET_ABI_FMT_lx, - ts->info->code_offset, - ts->info->data_offset, - ts->info->data_offset); - gdb_put_strbuf(); -} -#endif - static void handle_query_supported(GArray *params, void *user_ctx) { CPUClass *cc; @@ -2049,53 +1679,6 @@ static void handle_query_xfer_features(GArray *param= s, void *user_ctx) gdbserver_state.str_buf->len, true); } =20 -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) -static void handle_query_xfer_auxv(GArray *params, void *user_ctx) -{ - TaskState *ts; - unsigned long offset, len, saved_auxv, auxv_len; - - if (params->len < 2) { - gdb_put_packet("E22"); - return; - } - - offset =3D get_param(params, 0)->val_ul; - len =3D get_param(params, 1)->val_ul; - ts =3D gdbserver_state.c_cpu->opaque; - saved_auxv =3D ts->info->saved_auxv; - auxv_len =3D ts->info->auxv_len; - - if (offset >=3D auxv_len) { - gdb_put_packet("E00"); - return; - } - - if (len > (MAX_PACKET_LENGTH - 5) / 2) { - len =3D (MAX_PACKET_LENGTH - 5) / 2; - } - - if (len < auxv_len - offset) { - g_string_assign(gdbserver_state.str_buf, "m"); - } else { - g_string_assign(gdbserver_state.str_buf, "l"); - len =3D auxv_len - offset; - } - - g_byte_array_set_size(gdbserver_state.mem_buf, len); - if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset, - gdbserver_state.mem_buf->data, len, false))= { - gdb_put_packet("E14"); - return; - } - - gdb_memtox(gdbserver_state.str_buf, - (const char *)gdbserver_state.mem_buf->data, len); - gdb_put_packet_binary(gdbserver_state.str_buf->str, - gdbserver_state.str_buf->len, true); -} -#endif - static void handle_query_attached(GArray *params, void *user_ctx) { gdb_put_packet(GDB_ATTACHED); @@ -2173,7 +1756,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = =3D { }, #ifdef CONFIG_USER_ONLY { - .handler =3D handle_query_offsets, + .handler =3D gdb_handle_query_offsets, .cmd =3D "Offsets", }, #else @@ -2203,7 +1786,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = =3D { }, #if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) { - .handler =3D handle_query_xfer_auxv, + .handler =3D gdb_handle_query_xfer_auxv, .cmd =3D "Xfer:auxv:read::", .cmd_startswith =3D 1, .schema =3D "l,l0" @@ -2791,29 +2374,6 @@ void gdb_read_byte(uint8_t ch) } } =20 -#ifdef CONFIG_USER_ONLY -/* Tell the remote gdb that the process has exited. */ -void gdb_exit(int code) -{ - char buf[4]; - - if (!gdbserver_state.init) { - return; - } - if (gdbserver_user_state.socket_path) { - unlink(gdbserver_user_state.socket_path); - } - if (gdbserver_user_state.fd < 0) { - return; - } - - trace_gdbstub_op_exiting((uint8_t)code); - - snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - gdb_put_packet(buf); -} -#endif - /* * Create the process that will contain all the "orphan" CPUs (that are not * part of a CPU cluster). Note that if this process contains no CPUs, it = won't @@ -2839,233 +2399,3 @@ void gdb_create_default_process(GDBState *s) process->target_xml[0] =3D '\0'; } =20 -#ifdef CONFIG_USER_ONLY -int -gdb_handlesig(CPUState *cpu, int sig) -{ - char buf[256]; - int n; - - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { - return sig; - } - - /* disable single step if it was enabled */ - cpu_single_step(cpu, 0); - tb_flush(cpu); - - if (sig !=3D 0) { - gdb_set_stop_cpu(cpu); - g_string_printf(gdbserver_state.str_buf, - "T%02xthread:", target_signal_to_gdb(sig)); - gdb_append_thread_id(cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); - gdb_put_strbuf(); - } - /* - * gdb_put_packet() might have detected that the peer terminated the - * connection. - */ - if (gdbserver_user_state.fd < 0) { - return sig; - } - - sig =3D 0; - gdbserver_state.state =3D RS_IDLE; - gdbserver_user_state.running_state =3D 0; - while (gdbserver_user_state.running_state =3D=3D 0) { - n =3D read(gdbserver_user_state.fd, buf, 256); - if (n > 0) { - int i; - - for (i =3D 0; i < n; i++) { - gdb_read_byte(buf[i]); - } - } else { - /* XXX: Connection closed. Should probably wait for another - connection before continuing. */ - if (n =3D=3D 0) { - close(gdbserver_user_state.fd); - } - gdbserver_user_state.fd =3D -1; - return sig; - } - } - sig =3D gdbserver_state.signal; - gdbserver_state.signal =3D 0; - return sig; -} - -/* Tell the remote gdb that the process has exited due to SIG. */ -void gdb_signalled(CPUArchState *env, int sig) -{ - char buf[4]; - - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { - return; - } - - snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - gdb_put_packet(buf); -} - -static void gdb_accept_init(int fd) -{ - gdb_init_gdbserver_state(); - gdb_create_default_process(&gdbserver_state); - gdbserver_state.processes[0].attached =3D true; - gdbserver_state.c_cpu =3D gdb_first_attached_cpu(); - gdbserver_state.g_cpu =3D gdbserver_state.c_cpu; - gdbserver_user_state.fd =3D fd; - gdb_has_xml =3D false; -} - -static bool gdb_accept_socket(int gdb_fd) -{ - int fd; - - for(;;) { - fd =3D accept(gdb_fd, NULL, NULL); - if (fd < 0 && errno !=3D EINTR) { - perror("accept socket"); - return false; - } else if (fd >=3D 0) { - qemu_set_cloexec(fd); - break; - } - } - - gdb_accept_init(fd); - return true; -} - -static int gdbserver_open_socket(const char *path) -{ - struct sockaddr_un sockaddr =3D {}; - int fd, ret; - - fd =3D socket(AF_UNIX, SOCK_STREAM, 0); - if (fd < 0) { - perror("create socket"); - return -1; - } - - sockaddr.sun_family =3D AF_UNIX; - pstrcpy(sockaddr.sun_path, sizeof(sockaddr.sun_path) - 1, path); - ret =3D bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); - if (ret < 0) { - perror("bind socket"); - close(fd); - return -1; - } - ret =3D listen(fd, 1); - if (ret < 0) { - perror("listen socket"); - close(fd); - return -1; - } - - return fd; -} - -static bool gdb_accept_tcp(int gdb_fd) -{ - struct sockaddr_in sockaddr =3D {}; - socklen_t len; - int fd; - - for(;;) { - len =3D sizeof(sockaddr); - fd =3D accept(gdb_fd, (struct sockaddr *)&sockaddr, &len); - if (fd < 0 && errno !=3D EINTR) { - perror("accept"); - return false; - } else if (fd >=3D 0) { - qemu_set_cloexec(fd); - break; - } - } - - /* set short latency */ - if (socket_set_nodelay(fd)) { - perror("setsockopt"); - close(fd); - return false; - } - - gdb_accept_init(fd); - return true; -} - -static int gdbserver_open_port(int port) -{ - struct sockaddr_in sockaddr; - int fd, ret; - - fd =3D socket(PF_INET, SOCK_STREAM, 0); - if (fd < 0) { - perror("socket"); - return -1; - } - qemu_set_cloexec(fd); - - socket_set_fast_reuse(fd); - - sockaddr.sin_family =3D AF_INET; - sockaddr.sin_port =3D htons(port); - sockaddr.sin_addr.s_addr =3D 0; - ret =3D bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); - if (ret < 0) { - perror("bind"); - close(fd); - return -1; - } - ret =3D listen(fd, 1); - if (ret < 0) { - perror("listen"); - close(fd); - return -1; - } - - return fd; -} - -int gdbserver_start(const char *port_or_path) -{ - int port =3D g_ascii_strtoull(port_or_path, NULL, 10); - int gdb_fd; - - if (port > 0) { - gdb_fd =3D gdbserver_open_port(port); - } else { - gdb_fd =3D gdbserver_open_socket(port_or_path); - } - - if (gdb_fd < 0) { - return -1; - } - - if (port > 0 && gdb_accept_tcp(gdb_fd)) { - return 0; - } else if (gdb_accept_socket(gdb_fd)) { - gdbserver_user_state.socket_path =3D g_strdup(port_or_path); - return 0; - } - - /* gone wrong */ - close(gdb_fd); - return -1; -} - -/* Disable gdb stub for child processes. */ -void gdbserver_fork(CPUState *cpu) -{ - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { - return; - } - close(gdbserver_user_state.fd); - gdbserver_user_state.fd =3D -1; - cpu_breakpoint_remove_all(cpu, BP_GDB); - cpu_watchpoint_remove_all(cpu, BP_GDB); -} -#endif diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 86a94f1519..a6c196ade6 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -434,6 +434,96 @@ void gdb_handle_query_rcmd(GArray *params, void *user_= ctx) gdb_put_packet("OK"); } =20 +/* + * Execution state helpers + */ + +void gdb_continue(void) +{ + if (!runstate_needs_reset()) { + trace_gdbstub_op_continue(); + vm_start(); + } +} + +/* + * Resume execution, per CPU actions. + */ +int gdb_continue_partial(char *newstates) +{ + CPUState *cpu; + int res =3D 0; + int flag =3D 0; + + if (!runstate_needs_reset()) { + bool step_requested =3D false; + CPU_FOREACH(cpu) { + if (newstates[cpu->cpu_index] =3D=3D 's') { + step_requested =3D true; + break; + } + } + + if (vm_prepare_start(step_requested)) { + return 0; + } + + CPU_FOREACH(cpu) { + switch (newstates[cpu->cpu_index]) { + case 0: + case 1: + break; /* nothing to do here */ + case 's': + trace_gdbstub_op_stepping(cpu->cpu_index); + cpu_single_step(cpu, gdbserver_state.sstep_flags); + cpu_resume(cpu); + flag =3D 1; + break; + case 'c': + trace_gdbstub_op_continue_cpu(cpu->cpu_index); + cpu_resume(cpu); + flag =3D 1; + break; + default: + res =3D -1; + break; + } + } + } + if (flag) { + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true); + } + return res; +} + +/* + * Signal Handling - in system mode we only need SIGINT and SIGTRAP; other + * signals are not yet supported. + */ + +enum { + TARGET_SIGINT =3D 2, + TARGET_SIGTRAP =3D 5 +}; + +static int gdb_signal_table[] =3D { + -1, + -1, + TARGET_SIGINT, + -1, + -1, + TARGET_SIGTRAP +}; + +int gdb_signal_to_target(int sig) +{ + if (sig < ARRAY_SIZE(gdb_signal_table)) { + return gdb_signal_table[sig]; + } else { + return -1; + } +} + /* * Break/Watch point helpers */ diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c new file mode 100644 index 0000000000..fa0e59ec9a --- /dev/null +++ b/gdbstub/user-target.c @@ -0,0 +1,283 @@ +/* + * Target specific user-mode handling + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#include "qemu/osdep.h" +#include "exec/gdbstub.h" +#include "qemu.h" +#include "internals.h" + +/* + * Map target signal numbers to GDB protocol signal numbers and vice + * versa. For user emulation's currently supported systems, we can + * assume most signals are defined. + */ + +static int gdb_signal_table[] =3D { + 0, + TARGET_SIGHUP, + TARGET_SIGINT, + TARGET_SIGQUIT, + TARGET_SIGILL, + TARGET_SIGTRAP, + TARGET_SIGABRT, + -1, /* SIGEMT */ + TARGET_SIGFPE, + TARGET_SIGKILL, + TARGET_SIGBUS, + TARGET_SIGSEGV, + TARGET_SIGSYS, + TARGET_SIGPIPE, + TARGET_SIGALRM, + TARGET_SIGTERM, + TARGET_SIGURG, + TARGET_SIGSTOP, + TARGET_SIGTSTP, + TARGET_SIGCONT, + TARGET_SIGCHLD, + TARGET_SIGTTIN, + TARGET_SIGTTOU, + TARGET_SIGIO, + TARGET_SIGXCPU, + TARGET_SIGXFSZ, + TARGET_SIGVTALRM, + TARGET_SIGPROF, + TARGET_SIGWINCH, + -1, /* SIGLOST */ + TARGET_SIGUSR1, + TARGET_SIGUSR2, +#ifdef TARGET_SIGPWR + TARGET_SIGPWR, +#else + -1, +#endif + -1, /* SIGPOLL */ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, +#ifdef __SIGRTMIN + __SIGRTMIN + 1, + __SIGRTMIN + 2, + __SIGRTMIN + 3, + __SIGRTMIN + 4, + __SIGRTMIN + 5, + __SIGRTMIN + 6, + __SIGRTMIN + 7, + __SIGRTMIN + 8, + __SIGRTMIN + 9, + __SIGRTMIN + 10, + __SIGRTMIN + 11, + __SIGRTMIN + 12, + __SIGRTMIN + 13, + __SIGRTMIN + 14, + __SIGRTMIN + 15, + __SIGRTMIN + 16, + __SIGRTMIN + 17, + __SIGRTMIN + 18, + __SIGRTMIN + 19, + __SIGRTMIN + 20, + __SIGRTMIN + 21, + __SIGRTMIN + 22, + __SIGRTMIN + 23, + __SIGRTMIN + 24, + __SIGRTMIN + 25, + __SIGRTMIN + 26, + __SIGRTMIN + 27, + __SIGRTMIN + 28, + __SIGRTMIN + 29, + __SIGRTMIN + 30, + __SIGRTMIN + 31, + -1, /* SIGCANCEL */ + __SIGRTMIN, + __SIGRTMIN + 32, + __SIGRTMIN + 33, + __SIGRTMIN + 34, + __SIGRTMIN + 35, + __SIGRTMIN + 36, + __SIGRTMIN + 37, + __SIGRTMIN + 38, + __SIGRTMIN + 39, + __SIGRTMIN + 40, + __SIGRTMIN + 41, + __SIGRTMIN + 42, + __SIGRTMIN + 43, + __SIGRTMIN + 44, + __SIGRTMIN + 45, + __SIGRTMIN + 46, + __SIGRTMIN + 47, + __SIGRTMIN + 48, + __SIGRTMIN + 49, + __SIGRTMIN + 50, + __SIGRTMIN + 51, + __SIGRTMIN + 52, + __SIGRTMIN + 53, + __SIGRTMIN + 54, + __SIGRTMIN + 55, + __SIGRTMIN + 56, + __SIGRTMIN + 57, + __SIGRTMIN + 58, + __SIGRTMIN + 59, + __SIGRTMIN + 60, + __SIGRTMIN + 61, + __SIGRTMIN + 62, + __SIGRTMIN + 63, + __SIGRTMIN + 64, + __SIGRTMIN + 65, + __SIGRTMIN + 66, + __SIGRTMIN + 67, + __SIGRTMIN + 68, + __SIGRTMIN + 69, + __SIGRTMIN + 70, + __SIGRTMIN + 71, + __SIGRTMIN + 72, + __SIGRTMIN + 73, + __SIGRTMIN + 74, + __SIGRTMIN + 75, + __SIGRTMIN + 76, + __SIGRTMIN + 77, + __SIGRTMIN + 78, + __SIGRTMIN + 79, + __SIGRTMIN + 80, + __SIGRTMIN + 81, + __SIGRTMIN + 82, + __SIGRTMIN + 83, + __SIGRTMIN + 84, + __SIGRTMIN + 85, + __SIGRTMIN + 86, + __SIGRTMIN + 87, + __SIGRTMIN + 88, + __SIGRTMIN + 89, + __SIGRTMIN + 90, + __SIGRTMIN + 91, + __SIGRTMIN + 92, + __SIGRTMIN + 93, + __SIGRTMIN + 94, + __SIGRTMIN + 95, + -1, /* SIGINFO */ + -1, /* UNKNOWN */ + -1, /* DEFAULT */ + -1, + -1, + -1, + -1, + -1, + -1 +#endif +}; + +int gdb_signal_to_target(int sig) +{ + if (sig < ARRAY_SIZE(gdb_signal_table)) { + return gdb_signal_table[sig]; + } else { + return -1; + } +} + +int gdb_target_signal_to_gdb(int sig) +{ + int i; + for (i =3D 0; i < ARRAY_SIZE(gdb_signal_table); i++) { + if (gdb_signal_table[i] =3D=3D sig) { + return i; + } + } + return GDB_SIGNAL_UNKNOWN; +} + +int gdb_get_cpu_index(CPUState *cpu) +{ + TaskState *ts =3D (TaskState *) cpu->opaque; + return ts ? ts->ts_tid : -1; +} + +/* + * User-mode specific command helpers + */ + +void gdb_handle_query_offsets(GArray *params, void *user_ctx) +{ + TaskState *ts; + + ts =3D gdbserver_state.c_cpu->opaque; + g_string_printf(gdbserver_state.str_buf, + "Text=3D" TARGET_ABI_FMT_lx + ";Data=3D" TARGET_ABI_FMT_lx + ";Bss=3D" TARGET_ABI_FMT_lx, + ts->info->code_offset, + ts->info->data_offset, + ts->info->data_offset); + gdb_put_strbuf(); +} + +#if defined(CONFIG_LINUX) +/* Partial user only duplicate of helper in gdbstub.c */ +static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, + uint8_t *buf, int len, bool is_wr= ite) +{ + CPUClass *cc; + cc =3D CPU_GET_CLASS(cpu); + if (cc->memory_rw_debug) { + return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + } + return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); +} + +void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx) +{ + TaskState *ts; + unsigned long offset, len, saved_auxv, auxv_len; + + if (params->len < 2) { + gdb_put_packet("E22"); + return; + } + + offset =3D get_param(params, 0)->val_ul; + len =3D get_param(params, 1)->val_ul; + ts =3D gdbserver_state.c_cpu->opaque; + saved_auxv =3D ts->info->saved_auxv; + auxv_len =3D ts->info->auxv_len; + + if (offset >=3D auxv_len) { + gdb_put_packet("E00"); + return; + } + + if (len > (MAX_PACKET_LENGTH - 5) / 2) { + len =3D (MAX_PACKET_LENGTH - 5) / 2; + } + + if (len < auxv_len - offset) { + g_string_assign(gdbserver_state.str_buf, "m"); + } else { + g_string_assign(gdbserver_state.str_buf, "l"); + len =3D auxv_len - offset; + } + + g_byte_array_set_size(gdbserver_state.mem_buf, len); + if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset, + gdbserver_state.mem_buf->data, len, false))= { + gdb_put_packet("E14"); + return; + } + + gdb_memtox(gdbserver_state.str_buf, + (const char *)gdbserver_state.mem_buf->data, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} +#endif diff --git a/gdbstub/user.c b/gdbstub/user.c index 09a18fb23b..23b2e726f6 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -10,10 +10,354 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/sockets.h" +#include "exec/hwaddr.h" +#include "exec/tb-flush.h" #include "exec/gdbstub.h" +#include "gdbstub/user.h" #include "hw/core/cpu.h" +#include "trace.h" #include "internals.h" =20 +/* User-mode specific state */ +typedef struct { + int fd; + char *socket_path; + int running_state; +} GDBUserState; + +static GDBUserState gdbserver_user_state; + +int gdb_get_char(void) +{ + uint8_t ch; + int ret; + + for (;;) { + ret =3D recv(gdbserver_user_state.fd, &ch, 1, 0); + if (ret < 0) { + if (errno =3D=3D ECONNRESET) { + gdbserver_user_state.fd =3D -1; + } + if (errno !=3D EINTR) { + return -1; + } + } else if (ret =3D=3D 0) { + close(gdbserver_user_state.fd); + gdbserver_user_state.fd =3D -1; + return -1; + } else { + break; + } + } + return ch; +} + +void gdb_put_buffer(const uint8_t *buf, int len) +{ + int ret; + + while (len > 0) { + ret =3D send(gdbserver_user_state.fd, buf, len, 0); + if (ret < 0) { + if (errno !=3D EINTR) { + return; + } + } else { + buf +=3D ret; + len -=3D ret; + } + } +} + +/* Tell the remote gdb that the process has exited. */ +void gdb_exit(int code) +{ + char buf[4]; + + if (!gdbserver_state.init) { + return; + } + if (gdbserver_user_state.socket_path) { + unlink(gdbserver_user_state.socket_path); + } + if (gdbserver_user_state.fd < 0) { + return; + } + + trace_gdbstub_op_exiting((uint8_t)code); + + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + gdb_put_packet(buf); +} + +int gdb_handlesig(CPUState *cpu, int sig) +{ + char buf[256]; + int n; + + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return sig; + } + + /* disable single step if it was enabled */ + cpu_single_step(cpu, 0); + tb_flush(cpu); + + if (sig !=3D 0) { + gdb_set_stop_cpu(cpu); + g_string_printf(gdbserver_state.str_buf, + "T%02xthread:", gdb_target_signal_to_gdb(sig)); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + gdb_put_strbuf(); + } + /* + * gdb_put_packet() might have detected that the peer terminated the + * connection. + */ + if (gdbserver_user_state.fd < 0) { + return sig; + } + + sig =3D 0; + gdbserver_state.state =3D RS_IDLE; + gdbserver_user_state.running_state =3D 0; + while (gdbserver_user_state.running_state =3D=3D 0) { + n =3D read(gdbserver_user_state.fd, buf, 256); + if (n > 0) { + int i; + + for (i =3D 0; i < n; i++) { + gdb_read_byte(buf[i]); + } + } else { + /* + * XXX: Connection closed. Should probably wait for another + * connection before continuing. + */ + if (n =3D=3D 0) { + close(gdbserver_user_state.fd); + } + gdbserver_user_state.fd =3D -1; + return sig; + } + } + sig =3D gdbserver_state.signal; + gdbserver_state.signal =3D 0; + return sig; +} + +/* Tell the remote gdb that the process has exited due to SIG. */ +void gdb_signalled(CPUArchState *env, int sig) +{ + char buf[4]; + + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return; + } + + snprintf(buf, sizeof(buf), "X%02x", gdb_target_signal_to_gdb(sig)); + gdb_put_packet(buf); +} + +static void gdb_accept_init(int fd) +{ + gdb_init_gdbserver_state(); + gdb_create_default_process(&gdbserver_state); + gdbserver_state.processes[0].attached =3D true; + gdbserver_state.c_cpu =3D gdb_first_attached_cpu(); + gdbserver_state.g_cpu =3D gdbserver_state.c_cpu; + gdbserver_user_state.fd =3D fd; + gdb_has_xml =3D false; +} + +static bool gdb_accept_socket(int gdb_fd) +{ + int fd; + + for (;;) { + fd =3D accept(gdb_fd, NULL, NULL); + if (fd < 0 && errno !=3D EINTR) { + perror("accept socket"); + return false; + } else if (fd >=3D 0) { + qemu_set_cloexec(fd); + break; + } + } + + gdb_accept_init(fd); + return true; +} + +static int gdbserver_open_socket(const char *path) +{ + struct sockaddr_un sockaddr =3D {}; + int fd, ret; + + fd =3D socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + perror("create socket"); + return -1; + } + + sockaddr.sun_family =3D AF_UNIX; + pstrcpy(sockaddr.sun_path, sizeof(sockaddr.sun_path) - 1, path); + ret =3D bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); + if (ret < 0) { + perror("bind socket"); + close(fd); + return -1; + } + ret =3D listen(fd, 1); + if (ret < 0) { + perror("listen socket"); + close(fd); + return -1; + } + + return fd; +} + +static bool gdb_accept_tcp(int gdb_fd) +{ + struct sockaddr_in sockaddr =3D {}; + socklen_t len; + int fd; + + for (;;) { + len =3D sizeof(sockaddr); + fd =3D accept(gdb_fd, (struct sockaddr *)&sockaddr, &len); + if (fd < 0 && errno !=3D EINTR) { + perror("accept"); + return false; + } else if (fd >=3D 0) { + qemu_set_cloexec(fd); + break; + } + } + + /* set short latency */ + if (socket_set_nodelay(fd)) { + perror("setsockopt"); + close(fd); + return false; + } + + gdb_accept_init(fd); + return true; +} + +static int gdbserver_open_port(int port) +{ + struct sockaddr_in sockaddr; + int fd, ret; + + fd =3D socket(PF_INET, SOCK_STREAM, 0); + if (fd < 0) { + perror("socket"); + return -1; + } + qemu_set_cloexec(fd); + + socket_set_fast_reuse(fd); + + sockaddr.sin_family =3D AF_INET; + sockaddr.sin_port =3D htons(port); + sockaddr.sin_addr.s_addr =3D 0; + ret =3D bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); + if (ret < 0) { + perror("bind"); + close(fd); + return -1; + } + ret =3D listen(fd, 1); + if (ret < 0) { + perror("listen"); + close(fd); + return -1; + } + + return fd; +} + +int gdbserver_start(const char *port_or_path) +{ + int port =3D g_ascii_strtoull(port_or_path, NULL, 10); + int gdb_fd; + + if (port > 0) { + gdb_fd =3D gdbserver_open_port(port); + } else { + gdb_fd =3D gdbserver_open_socket(port_or_path); + } + + if (gdb_fd < 0) { + return -1; + } + + if (port > 0 && gdb_accept_tcp(gdb_fd)) { + return 0; + } else if (gdb_accept_socket(gdb_fd)) { + gdbserver_user_state.socket_path =3D g_strdup(port_or_path); + return 0; + } + + /* gone wrong */ + close(gdb_fd); + return -1; +} + +/* Disable gdb stub for child processes. */ +void gdbserver_fork(CPUState *cpu) +{ + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return; + } + close(gdbserver_user_state.fd); + gdbserver_user_state.fd =3D -1; + cpu_breakpoint_remove_all(cpu, BP_GDB); + /* no cpu_watchpoint_remove_all for user-mode */ +} + +/* + * Execution state helpers + */ + +void gdb_continue(void) +{ + gdbserver_user_state.running_state =3D 1; + trace_gdbstub_op_continue(); +} + +/* + * Resume execution, for user-mode emulation it's equivalent to + * gdb_continue. + */ +int gdb_continue_partial(char *newstates) +{ + CPUState *cpu; + int res =3D 0; + /* + * This is not exactly accurate, but it's an improvement compared to t= he + * previous situation, where only one CPU would be single-stepped. + */ + CPU_FOREACH(cpu) { + if (newstates[cpu->cpu_index] =3D=3D 's') { + trace_gdbstub_op_stepping(cpu->cpu_index); + cpu_single_step(cpu, gdbserver_state.sstep_flags); + } + } + gdbserver_user_state.running_state =3D 1; + return res; +} + +/* + * Break/Watch point helpers + */ + bool gdb_supports_guest_debug(void) { /* user-mode =3D=3D TCG =3D=3D supported */ diff --git a/linux-user/main.c b/linux-user/main.c index 4ff30ff980..75dbb52788 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -40,6 +40,7 @@ #include "qemu/plugin.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" +#include "gdbstub/user.h" #include "tcg/tcg.h" #include "qemu/timer.h" #include "qemu/envlist.h" diff --git a/linux-user/signal.c b/linux-user/signal.c index 098f3a787d..748a98f3e5 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -18,7 +18,7 @@ */ #include "qemu/osdep.h" #include "qemu/bitops.h" -#include "exec/gdbstub.h" +#include "gdbstub/user.h" #include "hw/core/tcg-cpu-ops.h" =20 #include diff --git a/gdbstub/meson.build b/gdbstub/meson.build index fc895a2c39..773bd4b9c9 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -7,3 +7,6 @@ specific_ss.add(files('gdbstub.c')) softmmu_ss.add(files('softmmu.c')) user_ss.add(files('user.c')) + +# The user-target is specialised by the guest +specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-target.c')) --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784305; cv=none; d=zohomail.com; s=zohoarc; b=TWHmmLcyRaWv3L17WfD8N2u2MG3OJ3MYRcoPFvp8y+je3VkD/vnVNa2d0oocbNat3lPkccaxlRe8X18rGilB6Jv7L4NzBOjJaEMZ0JSuyEHMs0aU7lt1UrOGBsu//bdUETAZAhApIR8aIjlrxbir/W5W702be5K9qcfHEmTBCI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784305; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fbnWOXh4ZExL9KJ5IqauLpuFcCfssFumF9ny95ox2i8=; b=V2bc3rbvz15JHakC9YZ4pEC0mBdklBN4xsMjDs3fWSWGZpc/1bsim8SJdZbFwCyvsYuJ2FukmelUn3RQTO4zYcwM41YiOA1s0OCa5etwhGsU/AJJUSNtK6HW+RDGM2xSVPx1CdP7k47VZjBIeq57I4WgFS7GRS7eJjDTJn2muJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784305557653.5695904511991; Thu, 2 Mar 2023 11:11:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIg-0007Ze-7H; Thu, 02 Mar 2023 14:09:10 -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 1pXoIf-0007YT-7u for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:09 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIQ-0004UG-3n for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:08 -0500 Received: by mail-wr1-x430.google.com with SMTP id bw19so98820wrb.13 for ; Thu, 02 Mar 2023 11:08:53 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n1-20020adffe01000000b002c4084d3472sm141397wrr.58.2023.03.02.11.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:52 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 4781C1FFC1; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) 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=fbnWOXh4ZExL9KJ5IqauLpuFcCfssFumF9ny95ox2i8=; b=IPI+6Gk7NYKXNZza05A834y6TpN8DALtHsZetaiTaxMlqJmMqUfqEWijlq7+vj+GZU T4sTwET7CEM0Ksqjf8q9uWmPjCMFogW6HfCic9FuCGZAsCc9vYNfJ09m3CIBzt1lhNMu mW35GsGmBrUNTqCqT/LByr1cOumN1O9v9jHOe0Xp7urTyaTpW3yrs1I7ExnPRg3hoppv 68AC9nvaklylPBBkUSjNThhscvVbQFRit+YWGCe+U5bqbNE838b0cxUA6VoDi2RsjcVt h76y+TstjC5Kp07+PUCXJP2gbzVDGslt6hZUyRcsBzLvS8ApKyeVt9vTxTjng939Qw5u RWgw== 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=fbnWOXh4ZExL9KJ5IqauLpuFcCfssFumF9ny95ox2i8=; b=CxC/k20JndPiEZTyx0z+fZAgfBvy3ooXnNJq9aKDxD5rFzV9hkDzpsfq+coUJAekTG kII6awsRA4hoF3s3UJFflegwlKkh5mk14JpB2TxxbV4i9KQJXhjLJq50g/vaJwkLE/O9 9CveRlVr7UpgeHQYap1WywFDdsafu4Ji+XRroBW0WKX3mtp4EMiTBdzqlK3fcVZVDbbx f7AZmSKqSvO26LBnkTPIz0TBUn8Jgh+9nfBbNQUSbiJfx+S56um00vVp+FqOHJEgMXdx d0YA7qrHz004F5XcYUI3rVvEn86+XI6T/MlKvUgJtc4RsTR2/o0QgczXnpODmoRzewfL KN8w== X-Gm-Message-State: AO0yUKULD0Bh2To+5tBLPXHrsscekYGdKP+sXBpkE9jCYIirzaQuc+nf iTEgKY3EDdCcTRwGx2O1Cl56iA== X-Google-Smtp-Source: AK7set+sgWnQU7C1557YTr26sjJJG7QJkrJhRZa4q9qR+57x/VqQHBAAVOWgrFutk1LRjL326N5Fuw== X-Received: by 2002:adf:f483:0:b0:2c7:d7ca:4c89 with SMTP id l3-20020adff483000000b002c7d7ca4c89mr8552024wro.58.1677784133103; Thu, 02 Mar 2023 11:08:53 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 12/26] gdbstub: rationalise signal mapping in softmmu Date: Thu, 2 Mar 2023 19:08:32 +0000 Message-Id: <20230302190846.2593720-13-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784306541100003 We don't really need a table for mapping two symbols. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- gdbstub/softmmu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index a6c196ade6..6796761fd9 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -506,20 +506,14 @@ enum { TARGET_SIGTRAP =3D 5 }; =20 -static int gdb_signal_table[] =3D { - -1, - -1, - TARGET_SIGINT, - -1, - -1, - TARGET_SIGTRAP -}; - int gdb_signal_to_target(int sig) { - if (sig < ARRAY_SIZE(gdb_signal_table)) { - return gdb_signal_table[sig]; - } else { + switch (sig) { + case 2: + return TARGET_SIGINT; + case 5: + return TARGET_SIGTRAP; + default: return -1; } } --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784560; cv=none; d=zohomail.com; s=zohoarc; b=aX7SHdAjxl/T68QMwH8HKXT6pCHZjtmP554hJOvcfFf/AVW8VMBdUofxamEuSDxv5kKv4eAu/icxtjFiSYt2MqG0ldhijO/5go2dMiZ5SSFfC4W3oa4evWyazJp/JLVcZhHoK9rBh0L4GY0PBLt6f76ZUUzeUuudDpcB9DT0pKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784560; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AkhUerl9HMLvEw3fit+pxInPqsKmIKwDU7RamZamxD0=; b=TvEvFO9gvV8QM/Ree+3SctPc6N36HQsnAC1SlZhxc4bRB/ri2aiV0qiX6TculuK6v98KE7OZaO83Juru0veHZ90mpn0I/PoanN8K5TkVFKeWLPJAx7+k5//7F+GBWLx3ZWK31zqZKjZJY+v4Ndrkj26qqBHqxyTxnvrMHOtH3Z0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784560266626.8534398309085; Thu, 2 Mar 2023 11:16:00 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AK7set/t5q9Z1Hr3yT7+q7UuT7SPkaO07wY8/R/Oryajsdhp3v0zZwHlvilonbAyiMin/c9qQ1y3+w== 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) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784562218100001 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=C3=A9 Signed-off-by: Alex Benn=C3=A9e --- 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, in= t len); void gdb_memtox(GString *buf, const char *mem, int len); void gdb_read_byte(uint8_t ch); =20 +/* + * 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, bo= ol dump) gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); =20 -#ifdef CONFIG_USER_ONLY - i =3D gdb_get_char(); - if (i < 0) - return -1; - if (i =3D=3D '+') + 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; } =20 +/* + * 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; } =20 +bool gdb_got_immediate_ack(void) +{ + int i; + + i =3D gdb_get_char(); + if (i < 0) { + /* no response, continue anyway */ + return true; + } + + if (i =3D=3D '+') { + /* 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; --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784741; cv=none; d=zohomail.com; s=zohoarc; b=FhqIp0vR/vtoFTnszb1OTW2kJtSdbXZeu5Oz8eRD3Mfv7Fygn4OsWYs5j4OT+/0Q27Bfoj9iynwIdT+l3Hy/BTjDPPRGuPCuhmF3CfjCcLKv/OJ16rSGrqWg9Z2avWnfYhieQJXGEHwVtPxEqhzn05wIF/oLnujfbFAyoDPhAr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784741; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hPckY1i9/afyDgbEgGvXK1gW63TVchEE6fBLm/0KY9U=; b=eAa0bbj5fdupkXRCCRkCCLEXFW0ibKB/0zJPj8OAJtCRJzjGIdWS6gLnyo2vuxz6L9DcMk3VGbSxbJ2vQtpFJ/zR/DRhZkTPWnnI4iQyET2Et19dNQWtAVXQrMp7AdU/GfxNoB1ZHUettn+1smYqBx1piKHcueKM6e9aBbeO/KI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784741568270.60233026679884; Thu, 2 Mar 2023 11:19:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoO8-0007f4-5v; Thu, 02 Mar 2023 14:14:48 -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 1pXoNz-00079A-Vq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:40 -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 1pXoNo-0000n8-NY for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:39 -0500 Received: by mail-wm1-x32e.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso2569647wmb.0 for ; Thu, 02 Mar 2023 11:14:25 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f2-20020a5d50c2000000b002c704271b05sm144559wrt.66.2023.03.02.11.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 86ABC1FFC3; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) 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=hPckY1i9/afyDgbEgGvXK1gW63TVchEE6fBLm/0KY9U=; b=N+KnOEUBoGC/1nIkicXd5l1SOjqX1TKqBCd6X9BCF5PvOmhg8hQQsf76J1FgTBhn9i 0YfaCyhmP9+XTknmV7jzdRVtD7aXqXBldUOx3tmOqNq6Kj1EB1FZIWYX2NtebKYBJp/7 hDqQbdh/SlPVDDDhXLBnBQGjxYj9/b3QQzDN7iK4UYsC22Z9p6/2QSITDfKxGf01j2s+ E32z5Oh4HVVnWgYaneyGfz9g+y5zCUMAME5WuQncSPioHTjSWOlDksbPJLzGamRlU5eU uBZTqryWMS8kpnj3QoGRWIpldwfax64K6UIrncN9dpWIPMLqtPGzVk/aFFE8ASANDfWu m8Xg== 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=hPckY1i9/afyDgbEgGvXK1gW63TVchEE6fBLm/0KY9U=; b=tay2IriVyPdWnPTJIu3VtrPbOiMBQghJV2c1V7Y6VBxbhR6flgKqTq/3dclNjhVFZC EzrX/KALNFQIRZOB07iGZ8hwU9b1Hgv5V9F0H4N+eaYVela85C2LX0ajmLvEHQxsQ1aE us2UZvkKexgkez4uz8k8nGshvRz5bHCcsp8GVLI3fQMJQKOgx3EBtmWFGXuTAbm/AaFS s8cmLh8WIzx0UBl/nejLnjU8IoRknBOVajl3nT1pymM3GENDlddYdaCwHko7OhPaGWa2 mZG67g+T2E1LNkos01USMimY60DY1YD2uejrIYUMReA9xqjvTrNQ+sKMcZHTcVejZPwL JA+A== X-Gm-Message-State: AO0yUKVdPn/DDlWf5GSJPhfLjIgHfEZ7AAnyIKygXHLM8jOwTr3zXrPb 40mfGaIXj5VlzcQEB06hatjIWg== X-Google-Smtp-Source: AK7set8MqFU/5jaVdDxnuYT+ajqtzMLG6tlGmGnhwj4AEnBYGZcS65UNRIQAw/eVtS3SNjKVhJy8YQ== X-Received: by 2002:a05:600c:310c:b0:3eb:395b:8b62 with SMTP id g12-20020a05600c310c00b003eb395b8b62mr9248096wmo.39.1677784464419; Thu, 02 Mar 2023 11:14:24 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 14/26] gdbstub: specialise handle_query_attached Date: Thu, 2 Mar 2023 19:08:34 +0000 Message-Id: <20230302190846.2593720-15-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784742356100001 In both user and softmmu cases we are just replying with a constant. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - remove allusions to possible linker optimisations --- 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 6534e373cb..20caacd744 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -154,7 +154,7 @@ int gdb_continue_partial(char *newstates); void gdb_put_buffer(const uint8_t *buf, int len); =20 /* - * Command handlers - either softmmu or user only + * Command handlers - either specialised or softmmu or user only */ void gdb_init_gdbserver_state(void); =20 @@ -183,6 +183,8 @@ void gdb_handle_query_rcmd(GArray *params, void *user_c= tx); /* softmmu */ void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ =20 +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 0476ee7039..52d1769f57 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -46,12 +46,6 @@ =20 #include "internals.h" =20 -#ifdef CONFIG_USER_ONLY -#define GDB_ATTACHED "0" -#else -#define GDB_ATTACHED "1" -#endif - #ifndef CONFIG_USER_ONLY static int phy_memory_mode; #endif @@ -1673,11 +1667,6 @@ static void handle_query_xfer_features(GArray *param= s, void *user_ctx) gdbserver_state.str_buf->len, true); } =20 -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"); @@ -1787,12 +1776,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[]= =3D { }, #endif { - .handler =3D handle_query_attached, + .handler =3D gdb_handle_query_attached, .cmd =3D "Attached:", .cmd_startswith =3D 1 }, { - .handler =3D handle_query_attached, + .handler =3D gdb_handle_query_attached, .cmd =3D "Attached", }, { diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 04e75449a2..7c180b779a 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -446,6 +446,11 @@ void gdb_handle_query_rcmd(GArray *params, void *user_= ctx) * Execution state helpers */ =20 +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 0c8cd028b1..c0fd83b373 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -345,6 +345,11 @@ void gdbserver_fork(CPUState *cpu) * Execution state helpers */ =20 +void gdb_handle_query_attached(GArray *params, void *user_ctx) +{ + gdb_put_packet("0"); +} + void gdb_continue(void) { gdbserver_user_state.running_state =3D 1; --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784644; cv=none; d=zohomail.com; s=zohoarc; b=Rd6eEHtD8G1zcOk5+Srp8Xyt/zfsJzzmpVRFkIEO9spLYMzo1oNN/9a687COXtnMG29IScdkrB1pRmQfdrdFkcllwN+ctI8RIEonFXcNqZJNEvjf7Aj+6Hhs/wMY+UMU8Z+OnsAMysJoF0IEAipMdczcs29uR+YlWWronp5WfBU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784644; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YcZgLPXFzYH2nM8OnzRIJ6/+BMVfARgO12rPV6+9lRs=; b=iKIw2CvJ0dAigfJusNA4YRwBxGb9dFcWOz87aWPKjsZDMunQXVULDfTJZcFAE6qqMD8UhauacNpMy6aNmP6A5V2qbPJm/cfp55q9/ucpDQHdR/jbR5hnt52SmD8rsuhYRIKDU8myNbrVm6fINEQrr6xsRTGufFSZ8wuwXqkwCxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784644150362.613624562784; Thu, 2 Mar 2023 11:17:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoO9-0007k5-SD; Thu, 02 Mar 2023 14:14:50 -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 1pXoO0-0007B1-GX for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:40 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNo-0000lW-O0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:40 -0500 Received: by mail-wr1-x436.google.com with SMTP id h11so151248wrm.5 for ; Thu, 02 Mar 2023 11:14:23 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k8-20020a5d66c8000000b002c573a6216fsm162582wrw.37.2023.03.02.11.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:21 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A73881FFC4; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) 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=YcZgLPXFzYH2nM8OnzRIJ6/+BMVfARgO12rPV6+9lRs=; b=QzmCqvhlvk0aSavqacO0/dbwBYIrpOnDWKfHPjglM3nZPnwTkDUNiPrSCHTI+vSfgL 5LgDxF+o7tbZif9BqKFfpb/Zd/fmnhFZChfNczilC6UyGel6TGGvc+AXC6TYdi4V7Nr3 pPRrXGmg4sEOeQRnKOybFPrS1Fw3fle//Xy9Nv3zqqGr5rQgUf67lYzYK7B6yQobNnBQ MDV1W7qjaHHeAmUshnT/HmFkHkaJpiKntlSt/T7FRJGrgWgoAhrhGCZc9PYlvikvqYJa EV7lwTP6we8kPx9lgbQ3f7s2fXlqLs2HdOqnREJwAVeoF1tm9FazNAQm/L4+gALNgwQX xBsg== 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=YcZgLPXFzYH2nM8OnzRIJ6/+BMVfARgO12rPV6+9lRs=; b=UV9/zMy99roK50wkpHjyFsbX1DaGt9K60/9E/IfEM5m+DEecMde2S+c91FkWLe9FN1 HLWxp6gY2px/BaVZNQKadI0ICbiw9spFOjCknTSCwJn9yOdYbeeYeOsU7qqub7z2KbW5 KWM31a4nZ1OEW5/bSNsWvAaitcQ/hVl7l5NH9/84ueSaEsaE5V8HythLewsoNuCMuRkq okTbVUReZJq0xWayeLEPsuz7dWUUC/JiFdCuZgl46f8/zs6wEXLyVC8y414R/prOQqfG 41e0M3YOHqdsL/XQAKyxygffUYDNpz4yj4b9sxxsWlBbwsP4yhgWs2li0+ZjL52mu8Wc 4LIQ== X-Gm-Message-State: AO0yUKXgTmZw4WmuUTgk3xY1iBYrYARTvXK5a1f6Emm5FVSTyAit8rLt zpwP5avJt7ViG/3yJkF4TJxxwg== X-Google-Smtp-Source: AK7set86ttx/YLHxKGDawdGkfm27cwOBEpZMwOgL/GzSnybahDI+T9cbXgLqCuamXVrR5GFU8UePjw== X-Received: by 2002:adf:eed1:0:b0:2c5:4c9f:cf3b with SMTP id a17-20020adfeed1000000b002c54c9fcf3bmr2297414wrp.7.1677784462865; Thu, 02 Mar 2023 11:14:22 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 15/26] gdbstub: specialise target_memory_rw_debug Date: Thu, 2 Mar 2023 19:08:35 +0000 Message-Id: <20230302190846.2593720-16-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784645508100003 The two implementations are different enough to encourage having a specialisation and we can move some of the softmmu only stuff out of gdbstub. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- gdbstub/internals.h | 19 ++++++++++++ gdbstub/gdbstub.c | 73 +++++++-------------------------------------- gdbstub/softmmu.c | 51 +++++++++++++++++++++++++++++++ gdbstub/user.c | 15 ++++++++++ 4 files changed, 96 insertions(+), 62 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 20caacd744..d8c0292d99 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -185,6 +185,10 @@ void gdb_handle_query_xfer_auxv(GArray *params, void *= user_ctx); /*user */ =20 void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ =20 +/* softmmu only */ +void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx); +void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. @@ -194,4 +198,19 @@ int gdb_breakpoint_insert(CPUState *cs, int type, vadd= r addr, vaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); void gdb_breakpoint_remove_all(CPUState *cs); =20 +/** + * gdb_target_memory_rw_debug() - handle debug access to memory + * @cs: CPUState + * @addr: nominal address, could be an entire physical address + * @buf: data + * @len: length of access + * @is_write: is it a write operation + * + * This function is specialised depending on the mode we are running + * in. For softmmu guests we can switch the interpretation of the + * address to a physical address. + */ +int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr, + uint8_t *buf, int len, bool is_write); + #endif /* GDBSTUB_INTERNALS_H */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 52d1769f57..ed38ab0aaa 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -46,33 +46,6 @@ =20 #include "internals.h" =20 -#ifndef CONFIG_USER_ONLY -static int phy_memory_mode; -#endif - -static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, - uint8_t *buf, int len, bool is_wr= ite) -{ - CPUClass *cc; - -#ifndef CONFIG_USER_ONLY - if (phy_memory_mode) { - if (is_write) { - cpu_physical_memory_write(addr, buf, len); - } else { - cpu_physical_memory_read(addr, buf, len); - } - return 0; - } -#endif - - cc =3D CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); - } - return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); -} - typedef struct GDBRegisterState { int base_reg; int num_regs; @@ -1195,11 +1168,11 @@ static void handle_write_mem(GArray *params, void *= user_ctx) } =20 gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, - get_param(params, 1)->val_ull); - if (target_memory_rw_debug(gdbserver_state.g_cpu, - get_param(params, 0)->val_ull, - gdbserver_state.mem_buf->data, - gdbserver_state.mem_buf->len, true)) { + get_param(params, 1)->val_ull); + if (gdb_target_memory_rw_debug(gdbserver_state.g_cpu, + get_param(params, 0)->val_ull, + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, true)) { gdb_put_packet("E14"); return; } @@ -1223,10 +1196,10 @@ static void handle_read_mem(GArray *params, void *u= ser_ctx) g_byte_array_set_size(gdbserver_state.mem_buf, get_param(params, 1)->val_ull); =20 - if (target_memory_rw_debug(gdbserver_state.g_cpu, - get_param(params, 0)->val_ull, - gdbserver_state.mem_buf->data, - gdbserver_state.mem_buf->len, false)) { + if (gdb_target_memory_rw_debug(gdbserver_state.g_cpu, + get_param(params, 0)->val_ull, + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, false)) { gdb_put_packet("E14"); return; } @@ -1676,30 +1649,6 @@ static void handle_query_qemu_supported(GArray *para= ms, void *user_ctx) gdb_put_strbuf(); } =20 -#ifndef CONFIG_USER_ONLY -static void handle_query_qemu_phy_mem_mode(GArray *params, - void *user_ctx) -{ - g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); - gdb_put_strbuf(); -} - -static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) -{ - if (!params->len) { - gdb_put_packet("E22"); - return; - } - - if (!get_param(params, 0)->val_ul) { - phy_memory_mode =3D 0; - } else { - phy_memory_mode =3D 1; - } - gdb_put_packet("OK"); -} -#endif - static const GdbCmdParseEntry gdb_gen_query_set_common_table[] =3D { /* Order is important if has same prefix */ { @@ -1790,7 +1739,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = =3D { }, #ifndef CONFIG_USER_ONLY { - .handler =3D handle_query_qemu_phy_mem_mode, + .handler =3D gdb_handle_query_qemu_phy_mem_mode, .cmd =3D "qemu.PhyMemMode", }, #endif @@ -1806,7 +1755,7 @@ static const GdbCmdParseEntry gdb_gen_set_table[] =3D= { }, #ifndef CONFIG_USER_ONLY { - .handler =3D handle_set_qemu_phy_mem_mode, + .handler =3D gdb_handle_set_qemu_phy_mem_mode, .cmd =3D "qemu.PhyMemMode:", .cmd_startswith =3D 1, .schema =3D "l0" diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 7c180b779a..ab2d182654 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -413,9 +413,60 @@ void gdb_exit(int code) qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); } =20 +/* + * Memory access + */ +static int phy_memory_mode; + +int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, + uint8_t *buf, int len, bool is_write) +{ + CPUClass *cc; + + if (phy_memory_mode) { + if (is_write) { + cpu_physical_memory_write(addr, buf, len); + } else { + cpu_physical_memory_read(addr, buf, len); + } + return 0; + } + + cc =3D CPU_GET_CLASS(cpu); + if (cc->memory_rw_debug) { + return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + } + + return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); +} + + /* * Softmmu specific command helpers */ + +void gdb_handle_query_qemu_phy_mem_mode(GArray *params, + void *user_ctx) +{ + g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); + gdb_put_strbuf(); +} + +void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) +{ + if (!params->len) { + gdb_put_packet("E22"); + return; + } + + if (!get_param(params, 0)->val_ul) { + phy_memory_mode =3D 0; + } else { + phy_memory_mode =3D 1; + } + gdb_put_packet("OK"); +} + void gdb_handle_query_rcmd(GArray *params, void *user_ctx) { const guint8 zero =3D 0; diff --git a/gdbstub/user.c b/gdbstub/user.c index c0fd83b373..92663d971c 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -378,6 +378,21 @@ int gdb_continue_partial(char *newstates) return res; } =20 +/* + * Memory access helpers + */ +int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, + uint8_t *buf, int len, bool is_write) +{ + CPUClass *cc; + + cc =3D CPU_GET_CLASS(cpu); + if (cc->memory_rw_debug) { + return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + } + return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); +} + /* * Break/Watch point helpers */ --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784723; cv=none; d=zohomail.com; s=zohoarc; b=BD7N3bKAi82hRk51XHElwuVtvE+IirjVT9mM42+KaWNl+ElJEvt2ZnpDIOy1dFDNmgwnes0o+r6o8GaE55XqJ7m+T7eVLLL311G1e7LkEzcE4k6yuBrhqLCrooPP/Sb9iGXgylcLIPQhZOUeQ6U4iz8wBfwxK6wkMfvJn56QW98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784723; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OkchIjEfD+60EpcbCT5XhulXGtH6Nh+X+dtOXOoAXwo=; b=O/eDCpv3BidGiuM3SDSGeZ3cW9VF5S0C8lbhQn7j4QPVDjA7ssopr9S1kUsMHo+TP6YefPCRuKWCfGrggipHLcncBCw8RpqPtApWtdETD3jyD7wC5dJJ43GLRn6BtuKil0ckDVNqQ6qa2MOpsjPVa0nXbkx8anHfVOxrlDotajI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784723397578.0736757701803; Thu, 2 Mar 2023 11:18:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoO6-0007VN-Ur; Thu, 02 Mar 2023 14:14:47 -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 1pXoNz-00077J-Jj for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:39 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNo-0000mN-NR for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:39 -0500 Received: by mail-wr1-x42d.google.com with SMTP id h11so151275wrm.5 for ; Thu, 02 Mar 2023 11:14:24 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id x9-20020a5d60c9000000b002c70d97af78sm141079wrt.85.2023.03.02.11.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:21 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C5DF41FFC5; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) 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=OkchIjEfD+60EpcbCT5XhulXGtH6Nh+X+dtOXOoAXwo=; b=ZA0YRhSKo0mKNsXz/40NcIJ0lx+r74+ySfJ0wptw+mc/NHg3LXJwLe4oaSogxLLvVT MXaHUbDMuxCP6fJGdN38Fu8rlaUvahqRlx2skoLOTRMdw8X/f/aca7JRT9Rx+4z0nzYS k5WaUGckPkD+ZLTewsmx3JKjlbTiM7+ZII8UCzvNcYO1sKmlss9ilWL424WKSssCIJUB ke35tRnrzFvWs3bfo9a3ubqRZfNorhdc412Rc52usg1Bo8O7YFCj+aDf5elShp6qi6ns Hm+TnfopORY7xXsyOj9rxGCTOGGkWXiZ+4kyNRsOqWktKGBiVyas2NduA6sg9DHdhZQp 3ScA== 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=OkchIjEfD+60EpcbCT5XhulXGtH6Nh+X+dtOXOoAXwo=; b=VTuGAHT37GywzxcFN5j32zPsLTpbqR6sED8d9NUhzKjOqk79/jjHT/HYqJKhwLyURK xXqry1qHcRzJAWAEceZp4rVNdMl6yWyRJeHiDA/n5spRANnaxl2sYERV2AAkCnktpfKk Laj0wl4u+LnpDLrLv5IiqdCJDuPtRXlz5l+XiCE+saaIb3sUmSayJltFwhQjOUYlB81D C1ZZqoRK46xLdTVkx9XcIwPmmTMf8aMmiw2aj6d/eO3QXdMOe2Ha932AQ+BIlb2sM2MF jIGckl03lKWnGwZSgV+YAO5CdLTiXxKPtLkqikXQ03kbcZpnISabH3wdocxN9+6jqSyn xqjw== X-Gm-Message-State: AO0yUKVAO1J4h0ZALh8G8sl+E13KGq6ldIGSXjlGnS9Vg+XydivPNN8Q NeqhpUpVb2W9zgGPDMcDTsIiXA== X-Google-Smtp-Source: AK7set+rHHp+XuBPHtP8FDC0egngoTGIIwBolsTa9jbmzaAhXxpb+Ba6ajcNYTOiZ6Vf8U0Zm0yzzA== X-Received: by 2002:a5d:5189:0:b0:2c3:be89:7c2b with SMTP id k9-20020a5d5189000000b002c3be897c2bmr2200483wrv.14.1677784463604; Thu, 02 Mar 2023 11:14:23 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 16/26] gdbstub: introduce gdb_get_max_cpus Date: Thu, 2 Mar 2023 19:08:36 +0000 Message-Id: <20230302190846.2593720-17-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784724228100001 This is needed for handling vcont packets as the way of calculating max cpus vhanges between user and softmmu mode. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - rm out of date comment --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 11 +---------- gdbstub/softmmu.c | 9 +++++++++ gdbstub/user.c | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index d8c0292d99..26a6468a69 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -129,6 +129,7 @@ bool gdb_got_immediate_ack(void); CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); +unsigned int gdb_get_max_cpus(void); /* both */ =20 void gdb_create_default_process(GDBState *s); =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ed38ab0aaa..1b783100c2 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -624,16 +624,7 @@ static int gdb_handle_vcont(const char *p) GDBProcess *process; CPUState *cpu; GDBThreadIdKind kind; -#ifdef CONFIG_USER_ONLY - int max_cpus =3D 1; /* global variable max_cpus exists only in system = mode */ - - CPU_FOREACH(cpu) { - max_cpus =3D max_cpus <=3D cpu->cpu_index ? cpu->cpu_index + 1 : m= ax_cpus; - } -#else - MachineState *ms =3D MACHINE(qdev_get_machine()); - unsigned int max_cpus =3D ms->smp.max_cpus; -#endif + unsigned int max_cpus =3D gdb_get_max_cpus(); /* uninitialised CPUs stay 0 */ newstates =3D g_new0(char, max_cpus); =20 diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index ab2d182654..3a5587d387 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -440,6 +440,15 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr a= ddr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } =20 +/* + * cpu helpers + */ + +unsigned int gdb_get_max_cpus(void) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + return ms->smp.max_cpus; +} =20 /* * Softmmu specific command helpers diff --git a/gdbstub/user.c b/gdbstub/user.c index 92663d971c..e10988a62b 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -393,6 +393,23 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr a= ddr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } =20 +/* + * cpu helpers + */ + +unsigned int gdb_get_max_cpus(void) +{ + CPUState *cpu; + unsigned int max_cpus =3D 1; + + CPU_FOREACH(cpu) { + max_cpus =3D max_cpus <=3D cpu->cpu_index ? cpu->cpu_index + 1 : m= ax_cpus; + } + + return max_cpus; +} + + /* * Break/Watch point helpers */ --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784562; cv=none; d=zohomail.com; s=zohoarc; b=VAKUl/I5qffb4g0VxrT05XqC4wxD5FhIje0h4eCbx9PjRBrv6nM/PXaJ9HGszb+Yqij/WgOv5OlmLX3Q/ulD2qekcFO4i2wmaJSOndxN7Ugd9mN8dQkNI6ctlUS9QWx/mxgoe8UqcI0QRXo01HcgHW3+IxueNNEsExCsrX6quWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784562; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kvMUUc5wEUJYWdA676z788wbTTrYmGmHmSy4eXEEE4E=; b=GIW287yD0zYbezc7eW0D29sctLfov8l3fIa+AijewiCIKrEuRt7zTYeTqwTgqpSPXirRBtfDf7agvyvwD7r3OFJXjX/vZT0c9X24d1SVWpRijxich9MzxWL6d/XYTM41YYWzRCgjDl/s/3yuDZMpDyzqRjdumkckNl/Itt/gCm8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784562871615.1854605749602; Thu, 2 Mar 2023 11:16:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoNx-0006va-A0; Thu, 02 Mar 2023 14:14:37 -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 1pXoNt-0006jF-RT for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:33 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNj-0000l2-TB for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:33 -0500 Received: by mail-wm1-x32a.google.com with SMTP id m25-20020a7bcb99000000b003e7842b75f2so9754wmi.3 for ; Thu, 02 Mar 2023 11:14:23 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ip21-20020a05600ca69500b003eb596cbc54sm450210wmb.0.2023.03.02.11.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:21 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E698E1FFC6; Thu, 2 Mar 2023 19:08:48 +0000 (GMT) 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=kvMUUc5wEUJYWdA676z788wbTTrYmGmHmSy4eXEEE4E=; b=No0tJw9N+bb/4p6Vsb6qYzWqwgEsGf2ywyP5YYcxA4ht4YgrV8RALbz4Q2rLJItRC1 ZnnIWD7acjmco+PLes60MWbG8kPlpWW6QpkK0DndOv4Ejb21sgl2ouenPEtc8IG0vZo7 9JjbofdnGZZMPLcMmIlizC3ARNI9clEPQ2Xv5MYGKXJ+Ne4SOc1M0miivaS7NQ7o53p8 bUMe46WJyHyUu3RtC0wRZPM5IDoX/3Ozb7TFM/RMxfQGTUQ8ea+jbHm1SaqX+A4X4WiM EmKUrVk2ZrEhOuafiu5bT6yvrzV1ogkGkapqioJTYdikH/LRZiUA9/n9LCUn3LY7ApnY Oh0A== 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=kvMUUc5wEUJYWdA676z788wbTTrYmGmHmSy4eXEEE4E=; b=LA+cyV1xF5R2UOPePupflApV8BrZy2XJpw+MEB/K1YJ5ZYGGJgS9IeDOqyGkh/ZhjG pqUB1hNi82nHpGtamPkFl7atK1Jr34KIxzcGKYzDuwG5kaE2zGO214/neL7GsuEYIYSp aHlLkJ6DhS06ksQDU9mPych/NanApmjScxsHC9DcSrAvi0H/MsEcRypYRe8gfVdQ0VRK x0DUD59T0fW2zxQT6xQeL9AKq20MhGHC/AHhmGQHQagBw6mY1fIIwcaocrFKoO/QozEY Jcv6kHlmVZrkOswbwdooRW/tcmpgPBAjbch0p9xRRrfXcx7kL2wcFZdONf1rooHtor6A Mn0g== X-Gm-Message-State: AO0yUKXok58p/k7MvO0+jt/ZQKw9ez3uuG1QvI4w+eLIMoi9TMzHgCEf UjAc9RwfUkIO5PIy+HvGc6J3cA== X-Google-Smtp-Source: AK7set99x5f15zwPdc3lgmkc1Lm3RjN/nUIbueV8TnBeIymj/y6MSAhspthJMp+dsHxYBVPf4c6YJw== X-Received: by 2002:a05:600c:181c:b0:3eb:2e1e:beae with SMTP id n28-20020a05600c181c00b003eb2e1ebeaemr8262271wmp.25.1677784462476; Thu, 02 Mar 2023 11:14:22 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 17/26] gdbstub: specialise stub_can_reverse Date: Thu, 2 Mar 2023 19:08:37 +0000 Message-Id: <20230302190846.2593720-18-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784564027100005 Currently we only support replay for softmmu mode so it is a constant false for user-mode. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - rename gdb_stub_can_revers -> gdb_can_reverse --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 13 ++----------- gdbstub/softmmu.c | 5 +++++ gdbstub/user.c | 5 +++++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 26a6468a69..be0eef4850 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -130,6 +130,7 @@ CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); unsigned int gdb_get_max_cpus(void); /* both */ +bool gdb_can_reverse(void); /* softmmu, stub for user */ =20 void gdb_create_default_process(GDBState *s); =20 diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 1b783100c2..7301466ff5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -113,15 +113,6 @@ int use_gdb_syscalls(void) return gdb_syscall_mode =3D=3D GDB_SYS_ENABLED; } =20 -static bool stub_can_reverse(void) -{ -#ifdef CONFIG_USER_ONLY - return false; -#else - return replay_mode =3D=3D REPLAY_MODE_PLAY; -#endif -} - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -1308,7 +1299,7 @@ static void handle_step(GArray *params, void *user_ct= x) =20 static void handle_backward(GArray *params, void *user_ctx) { - if (!stub_can_reverse()) { + if (!gdb_can_reverse()) { gdb_put_packet("E22"); } if (params->len =3D=3D 1) { @@ -1559,7 +1550,7 @@ static void handle_query_supported(GArray *params, vo= id *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } =20 - if (stub_can_reverse()) { + if (gdb_can_reverse()) { g_string_append(gdbserver_state.str_buf, ";ReverseStep+;ReverseContinue+"); } diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 3a5587d387..d2863d0663 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -450,6 +450,11 @@ unsigned int gdb_get_max_cpus(void) return ms->smp.max_cpus; } =20 +bool gdb_can_reverse(void) +{ + return replay_mode =3D=3D REPLAY_MODE_PLAY; +} + /* * Softmmu specific command helpers */ diff --git a/gdbstub/user.c b/gdbstub/user.c index e10988a62b..3f6183e66a 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -409,6 +409,11 @@ unsigned int gdb_get_max_cpus(void) return max_cpus; } =20 +/* replay not supported for user-mode */ +bool gdb_can_reverse(void) +{ + return false; +} =20 /* * Break/Watch point helpers --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784533; cv=none; d=zohomail.com; s=zohoarc; b=U6bsgOkBTqDZPhSqBWqgUd1/y1wu9kOCdU1TkNUcr7FLgvRMoTMgbfgELuvoeXaCYpZ9Mislc6B2IREr+5IylpyWhY/JX9rd0NU7WwM21VYIcg6h+BbEaT9MD8uj5eylvUnpJi6gpIQYxRIPEZyWEfIC5dFb7quuzgtnvTI3RnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2mDcBmWouGnqGshBynFnpTf0FCw+Ej8aBvk380H3UuI=; b=NQBamCfVSKD6taAPdeYxsA6aGSPwbgnfMkEccnCGp97O+f22y7l8oKkKvRdyq6qkBJ8u6VVhv9nn377XqPdD8jvzodHRvgueNC+ySvM7w3+SqUYQmhgDMpCo1zhf/9QXivzEA3NUdGRk4k17l60zHbI0AvyiCI5eIQ+mFi8Yh/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784533573825.0057506026358; Thu, 2 Mar 2023 11:15:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoNu-0006jP-5Z; Thu, 02 Mar 2023 14:14:34 -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 1pXoNq-0006aV-LS for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:30 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNj-0000kS-Ak for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:30 -0500 Received: by mail-wm1-x329.google.com with SMTP id j19-20020a05600c191300b003eb3e1eb0caso2535617wmq.1 for ; Thu, 02 Mar 2023 11:14:22 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k5-20020adfe8c5000000b002c56179d39esm162354wrn.44.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 0A81B1FFBB; Thu, 2 Mar 2023 19:08:49 +0000 (GMT) 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=2mDcBmWouGnqGshBynFnpTf0FCw+Ej8aBvk380H3UuI=; b=BXhYzlIz4j2CWr7staJK2ZrwQKbpSJoV8+CqliJorOBQviI6qlvhy8hs/bRlc8iHzK 2d8waRQy+vebFK4XDNLRiTHY+tdbnJ0FfASQMOZ+rjY+pRu+vEGgpgdlfuMb6DjhEMgS FK/nNatkJbpwbdhWrWI9tnYRH/dysVdyKNVqA8dGn+DwgFSM096dN388OZGadt3S6ruA WhRe13FdZYLXrr/2thq3+du5LceKbDMJH+6IhHD+TADiQE96sHjcfg68vOyYSVhD4z0s xxOEaxrH9bCsCQb3ZwQrPf01mEXK5fll2XGLUysUcP+9SuD6i8rvmaCgJ0SDXqX5IQ4J mCUA== 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=2mDcBmWouGnqGshBynFnpTf0FCw+Ej8aBvk380H3UuI=; b=53mMR7XGT0Ao5E+GDLyDaAbdkyff7hcNkHvVzDddctPt4KFV+9zb598A3RMC7s9oes 0FAimMgvYiy9YuJ7OS0Hw3wadz/EUuAJdXP67kf6hB5hqE+d2lkPlwx7PvJ3xDY+nu9k ZZFR1npOm3+sCbVu948yG1if7dAwSVWbfNDQq5lK5GMxB9p0Oiy8v8ZwZMZ/Hhd/G6u6 9JRICuBkdTUABl59Wac+uNfTs7DJfopBOs5dczwu/5NWSllXBYwHFS/2aY+x+5zU5uhh a6tPr8xbGVCamj5X2WbrtCM/sHply5yrztDlvKQK1vzvoUcp+KNi9240IduOLGTo028b L3MQ== X-Gm-Message-State: AO0yUKWWkE+U4WSGtAwnRCpvhsd2C6DTm98OZiyirsAT8naN4I1EbORt n6d3PaqKi9M6vOkkQ/QbigtQSg== X-Google-Smtp-Source: AK7set9YxIWJrYn/MpIzDLybLevwDttFD09ikLI3/HBK8ztypWUCRjSint/bPii24PauHRFn4AZCgw== X-Received: by 2002:a05:600c:198e:b0:3eb:6878:5523 with SMTP id t14-20020a05600c198e00b003eb68785523mr250882wmq.12.1677784461721; Thu, 02 Mar 2023 11:14:21 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 18/26] gdbstub: fix address type of gdb_set_cpu_pc Date: Thu, 2 Mar 2023 19:08:38 +0000 Message-Id: <20230302190846.2593720-19-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784534200100002 The underlying call uses vaddr and the comms API uses unsigned long long which will always fit. We don't need to deal in target_ulong here. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- gdbstub/gdbstub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 7301466ff5..b8aead03bd 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -535,7 +535,7 @@ static void gdb_process_breakpoint_remove_all(GDBProces= s *p) } =20 =20 -static void gdb_set_cpu_pc(target_ulong pc) +static void gdb_set_cpu_pc(vaddr pc) { CPUState *cpu =3D gdbserver_state.c_cpu; =20 @@ -1290,7 +1290,7 @@ static void handle_file_io(GArray *params, void *user= _ctx) static void handle_step(GArray *params, void *user_ctx) { if (params->len) { - gdb_set_cpu_pc((target_ulong)get_param(params, 0)->val_ull); + gdb_set_cpu_pc(get_param(params, 0)->val_ull); } =20 cpu_single_step(gdbserver_state.c_cpu, gdbserver_state.sstep_flags); --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784610; cv=none; d=zohomail.com; s=zohoarc; b=EfZLNrQns5cahSShc8OP33TPVgDgGHnqTvUUGjJ6ojPC9jSOBIUtfJAiOuFMS16m3aHKFQArZEaAS45lAtg3E+OT0GC6rx8s0I5IfrvsqEtjhmwC4ACi64wLXo8rjk/O2hfinFgiALIaFSS3fn+I9lg5T2doX1UNZP2YAHnbJOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784610; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kebJRJ/Zd0hMxCtlzPa2wrDMn74tVWfVULcszCFYnrs=; b=hLPRIFwYUP6OaUp2cWO/o4oiJZxw9IcFaFYmRVRFtRC4RszOAFe6A5PoXFXn6K/D+WYgJ2FQZ9ZooxH9idaGFpdSnq4DPXfpbIWKytbOdbyR/1akkQYv1ADr5PbLbUqZNpUfM1WvuOZ8UlGlpOt9vgfYDZ01Dh7q4MDVlrghqzU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16777846099995.7941775030152485; Thu, 2 Mar 2023 11:16:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoO7-0007Zd-KT; Thu, 02 Mar 2023 14:14:47 -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 1pXoO1-0007D1-0N for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:44 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNo-0000nl-PE for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:40 -0500 Received: by mail-wr1-x430.google.com with SMTP id q16so166648wrw.2 for ; Thu, 02 Mar 2023 11:14:25 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id b5-20020a05600c150500b003e91b9a92c9sm384899wmg.24.2023.03.02.11.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:24 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 234561FFC7; Thu, 2 Mar 2023 19:08:49 +0000 (GMT) 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=kebJRJ/Zd0hMxCtlzPa2wrDMn74tVWfVULcszCFYnrs=; b=RHVfSsXSeOsHZgpUTWIlzcqkeEi3+plFRd6crMtuBIX/nPCnvRLS3NA5NERG9MQxDC kLTG8utGQ9QSoL2omBP8n8BU69T6lQnPcQAHEn4BfU0784JW5LZ1h3B/dirN0aG0LOUn ZGuJyeqfT+u4C5dfFRXEEKN0qyFtD0m/K16wJcdae9PY/dxrQVHb/bAtbVMCjXBYzZ6a 2f3Lhn2hfn6G34LFcDwxVJRnPPNxvjCjk3iEtZ7Rqa49kWFOzBjrZgCZQN1SA7vNIxE2 gY29OoR0T8jS/mYtLH59BH3VlNYg8yS9ILRxnl1jUabfs29WHqXloX8fEb9uGXXNKavg 6ARQ== 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=kebJRJ/Zd0hMxCtlzPa2wrDMn74tVWfVULcszCFYnrs=; b=QJILZHzFWbc6lPZpUqcXMW68fJIxoZv2hmHOuN+N/1EmQQ4R52mwq7A29bXnLpekb2 A48ITAx1d8rBNjQgz2v+FGMTro6Kyvd53QYCcHA76skPxRGW2G1GCKu9NjUf8+qQ+j8c TmLhRCQnwos+ibMONYYbIbSvdtnm0fNeWgcBaFM1Zs0cS41ordsDM+7IrnEgSPcr36k+ R0kTjSpNk1waEmULTcxIulI7OpbtcBZ+cjLkpk9fSK7NwpczlwApN94jV1jRf3flLgAI 7chhWaf+tSXPTvdzHS9IUMxRtX6wLBASxuV11Ih0ypmTZkdjzMJXlYeTkEJiwSSwy0v8 hhiQ== X-Gm-Message-State: AO0yUKV4DfK7QOBdiGH6eBEWsy6yKFDaQhod7/iACnZJZ3AKEJfeMNLl OQBgUBSPhcoZAL5ykBIws7Wl2Q== X-Google-Smtp-Source: AK7set+D/4mTEhIX+7Jk/ThTEoGUCRN5R/1wUY3+La0dBKWoMtb+xw5AxRlJ8TNMrqyA30xvhuE2qg== X-Received: by 2002:a05:6000:10cc:b0:2c7:e60:abe8 with SMTP id b12-20020a05600010cc00b002c70e60abe8mr2230369wrx.9.1677784465139; Thu, 02 Mar 2023 11:14:25 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 19/26] gdbstub: don't use target_ulong while handling registers Date: Thu, 2 Mar 2023 19:08:39 +0000 Message-Id: <20230302190846.2593720-20-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784611056100003 This is a hangover from the original code. addr is misleading as it is only really a register id. While len will never exceed MAX_PACKET_LENGTH I've used size_t as that is what strlen returns. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - fix commit message - use unsigned for regid v4 - revert unsigned change --- gdbstub/gdbstub.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b8aead03bd..f1504af44f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1193,7 +1193,8 @@ static void handle_read_mem(GArray *params, void *use= r_ctx) =20 static void handle_write_all_regs(GArray *params, void *user_ctx) { - target_ulong addr, len; + int reg_id; + size_t len; uint8_t *registers; int reg_size; =20 @@ -1205,9 +1206,10 @@ static void handle_write_all_regs(GArray *params, vo= id *user_ctx) len =3D strlen(get_param(params, 0)->data) / 2; gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); registers =3D gdbserver_state.mem_buf->data; - for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len >= 0; - addr++) { - reg_size =3D gdb_write_register(gdbserver_state.g_cpu, registers, = addr); + for (reg_id =3D 0; + reg_id < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; + reg_id++) { + reg_size =3D gdb_write_register(gdbserver_state.g_cpu, registers, = reg_id); len -=3D reg_size; registers +=3D reg_size; } @@ -1216,15 +1218,16 @@ static void handle_write_all_regs(GArray *params, v= oid *user_ctx) =20 static void handle_read_all_regs(GArray *params, void *user_ctx) { - target_ulong addr, len; + int reg_id; + size_t len; =20 cpu_synchronize_state(gdbserver_state.g_cpu); g_byte_array_set_size(gdbserver_state.mem_buf, 0); len =3D 0; - for (addr =3D 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++)= { + for (reg_id =3D 0; reg_id < gdbserver_state.g_cpu->gdb_num_g_regs; reg= _id++) { len +=3D gdb_read_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf, - addr); + reg_id); } g_assert(len =3D=3D gdbserver_state.mem_buf->len); =20 --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784713; cv=none; d=zohomail.com; s=zohoarc; b=ctqhr2CoAx/UaysThHmtYg2V0WfHaV+ubwSX2vB1D5cGx1qwJyvedMOYwpYksm6KIZGn9fxUbg5g4+Ti+3VHmgfir9+ZXrUtSfIjO7gMJiDJx6S66e8rXFzYqSpBtpAeLalBk0NYnJOXJlZxnQ3kJC6wq8KuETdSjBCxibVw3/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784713; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L4KhUA1XFJwwWEmsegyMuDUvMlSPYSVpzli4rf0vM6k=; b=YZ3QZqto6OfbhrcVpocmLEbAfoPeiWN1d4LiSnD7ykp9qcOAWgfR/lo1BLAnYhnJWZtmCVnyodOz5rjp4SuL+BOxZS+fXXwWGsnZM5A+IP9wEtkiPvlzvqdDaHNgDoyFLKz8HCRrZmTj9c6vwInfK+tTjGQeHyXeJ9hdC3mkFiY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16777847130881012.3685468178285; Thu, 2 Mar 2023 11:18:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoO6-0007QN-AV; Thu, 02 Mar 2023 14:14:46 -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 1pXoO4-0007G0-FK for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:44 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNo-0000lr-Mh for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:44 -0500 Received: by mail-wr1-x42f.google.com with SMTP id f11so135352wrv.8 for ; Thu, 02 Mar 2023 11:14:24 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o1-20020a5d4081000000b002c71a32394dsm143563wrp.64.2023.03.02.11.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:21 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id ACDB71FFC8; Thu, 2 Mar 2023 19:08:49 +0000 (GMT) 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=L4KhUA1XFJwwWEmsegyMuDUvMlSPYSVpzli4rf0vM6k=; b=LAOeKs2/Vj0fzaUFKWAkUHCUjXyuF6vteIzflhN1WmDJFGxdkVi1KdAHXqBBxrsGkf 0Xf9JhF2LjzywpBPJVHZliMSrNjz0SNkNEtQIGZgjKh97Iyy5qc4RKJMcLpjx983xj1J ctG5lCLdmTASkJqbk4Y67uAsUwNbSGJeM5OGaqwVvyxFrmEzpzFMrzXJ4N5f7RArColm BFDh+tvygPdQCa4XgcsBiJUHo293XJONiSRHay0Gf8dEMvT+ZlctLKoGBLEd7TNNLGdd eXW6MBd55JIXn3AiyOVzRMdJqlGk8Uv6mF+CrFs1nRDTjc1GCO1iBDbKO8rLATHui1K7 wEkw== 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=L4KhUA1XFJwwWEmsegyMuDUvMlSPYSVpzli4rf0vM6k=; b=OWGbQxBCwjF4TGDqpuaEmZE7ELBxZXDpanR94gGq93axp+wOTdsDS6nW20OlAjJEJ5 ncSp+d130956xvfhjsHb+SJE1DLIoZQhxOLj59lGbqiK69XOfwsd5dGg69L94stnfnVp iTGoqzr0+nnwl1RDxWQTvn4e8BqzholPH40v7CJrnHvoM28H+dkDDodSY2wHFLn1HkjJ h78NgRXrzDOe6E5KmSOD3tsaeKnprzg/JgoGzRUkuv6To166/bhmTmwzYrqCR+vNGiWy pYmH99amWBIlkWHPg65hd9nbfWda9nzRk/ML4To0slQnK74vECblxSW0fW1wrLbtiPDR eiQg== X-Gm-Message-State: AO0yUKW7kI/W3ypycIzEYZHiCE6Q3Y5+SxKiq+hifjdw54zAC46yBPr8 XG03kpU+EBNfEY81SLCj6sxbsA== X-Google-Smtp-Source: AK7set+J7hPaeoVDz7pGoK2llCnE51OyeYKqtKAtDXjN9DSi5cTIjdmt/QOchoAhalDWwasrPlU24g== X-Received: by 2002:a5d:6545:0:b0:2c7:cc8:782c with SMTP id z5-20020a5d6545000000b002c70cc8782cmr2351610wrv.1.1677784463241; Thu, 02 Mar 2023 11:14:23 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 20/26] gdbstub: move register helpers into standalone include Date: Thu, 2 Mar 2023 19:08:40 +0000 Message-Id: <20230302190846.2593720-21-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784714186100003 These inline helpers are all used by target specific code so move them out of the general header so we don't needlessly pollute the rest of the API with target specific stuff. Note we have to include cpu.h in semihosting as it was relying on a side effect before. Reviewed-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v3 - update xtensa's import-core script as well v4 - checkpatch cleanups --- include/exec/gdbstub.h | 86 --------------------- include/gdbstub/helpers.h | 103 +++++++++++++++++++++++++ semihosting/syscalls.c | 1 + target/alpha/gdbstub.c | 2 +- target/arm/gdbstub.c | 1 + target/arm/gdbstub64.c | 2 +- target/arm/tcg/helper-a64.c | 2 +- target/arm/tcg/m_helper.c | 1 + target/avr/gdbstub.c | 2 +- target/cris/gdbstub.c | 2 +- target/hexagon/gdbstub.c | 2 +- target/hppa/gdbstub.c | 2 +- target/i386/gdbstub.c | 2 +- target/i386/whpx/whpx-all.c | 2 +- target/loongarch/gdbstub.c | 1 + target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 1 + target/m68k/m68k-semi.c | 1 + target/microblaze/gdbstub.c | 2 +- target/mips/gdbstub.c | 2 +- target/mips/tcg/sysemu/mips-semi.c | 1 + target/nios2/cpu.c | 2 +- target/nios2/nios2-semi.c | 1 + target/openrisc/gdbstub.c | 2 +- target/openrisc/interrupt.c | 2 +- target/openrisc/mmu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/ppc/gdbstub.c | 1 + target/riscv/gdbstub.c | 1 + target/rx/gdbstub.c | 2 +- target/s390x/gdbstub.c | 1 + target/s390x/helper.c | 2 +- target/sh4/gdbstub.c | 2 +- target/sparc/gdbstub.c | 2 +- target/tricore/gdbstub.c | 2 +- target/xtensa/core-dc232b.c | 2 +- target/xtensa/core-dc233c.c | 2 +- target/xtensa/core-de212.c | 2 +- target/xtensa/core-de233_fpu.c | 2 +- target/xtensa/core-dsp3400.c | 2 +- target/xtensa/core-fsf.c | 2 +- target/xtensa/core-lx106.c | 2 +- target/xtensa/core-sample_controller.c | 2 +- target/xtensa/core-test_kc705_be.c | 2 +- target/xtensa/core-test_mmuhifi_c3.c | 2 +- target/xtensa/gdbstub.c | 2 +- target/xtensa/helper.c | 2 +- target/xtensa/import_core.sh | 2 +- 48 files changed, 149 insertions(+), 121 deletions(-) create mode 100644 include/gdbstub/helpers.h diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 8fff5450ed..bb8a3928dd 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -110,92 +110,6 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_r= eg, int num_regs, const char *xml, int g_pos); =20 -#ifdef NEED_CPU_H -#include "cpu.h" - -/* - * The GDB remote protocol transfers values in target byte order. As - * the gdbstub may be batching up several register values we always - * append to the array. - */ - -static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) -{ - g_byte_array_append(buf, &val, 1); - return 1; -} - -static inline int gdb_get_reg16(GByteArray *buf, uint16_t val) -{ - uint16_t to_word =3D tswap16(val); - g_byte_array_append(buf, (uint8_t *) &to_word, 2); - return 2; -} - -static inline int gdb_get_reg32(GByteArray *buf, uint32_t val) -{ - uint32_t to_long =3D tswap32(val); - g_byte_array_append(buf, (uint8_t *) &to_long, 4); - return 4; -} - -static inline int gdb_get_reg64(GByteArray *buf, uint64_t val) -{ - uint64_t to_quad =3D tswap64(val); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); - return 8; -} - -static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi, - uint64_t val_lo) -{ - uint64_t to_quad; -#if TARGET_BIG_ENDIAN - to_quad =3D tswap64(val_hi); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); - to_quad =3D tswap64(val_lo); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); -#else - to_quad =3D tswap64(val_lo); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); - to_quad =3D tswap64(val_hi); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); -#endif - return 16; -} - -static inline int gdb_get_zeroes(GByteArray *array, size_t len) -{ - guint oldlen =3D array->len; - g_byte_array_set_size(array, oldlen + len); - memset(array->data + oldlen, 0, len); - - return len; -} - -/** - * gdb_get_reg_ptr: get pointer to start of last element - * @len: length of element - * - * This is a helper function to extract the pointer to the last - * element for additional processing. Some front-ends do additional - * dynamic swapping of the elements based on CPU state. - */ -static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len) -{ - return buf->data + buf->len - len; -} - -#if TARGET_LONG_BITS =3D=3D 64 -#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) -#define ldtul_p(addr) ldq_p(addr) -#else -#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val) -#define ldtul_p(addr) ldl_p(addr) -#endif - -#endif /* NEED_CPU_H */ - /** * gdbserver_start: start the gdb server * @port_or_device: connection spec for gdb diff --git a/include/gdbstub/helpers.h b/include/gdbstub/helpers.h new file mode 100644 index 0000000000..c573aef2dc --- /dev/null +++ b/include/gdbstub/helpers.h @@ -0,0 +1,103 @@ +/* + * gdbstub helpers + * + * These are all used by the various frontends and have to be host + * aware to ensure things are store in target order. + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _GDBSTUB_HELPERS_H_ +#define _GDBSTUB_HELPERS_H_ + +#ifdef NEED_CPU_H +#include "cpu.h" + +/* + * The GDB remote protocol transfers values in target byte order. As + * the gdbstub may be batching up several register values we always + * append to the array. + */ + +static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) +{ + g_byte_array_append(buf, &val, 1); + return 1; +} + +static inline int gdb_get_reg16(GByteArray *buf, uint16_t val) +{ + uint16_t to_word =3D tswap16(val); + g_byte_array_append(buf, (uint8_t *) &to_word, 2); + return 2; +} + +static inline int gdb_get_reg32(GByteArray *buf, uint32_t val) +{ + uint32_t to_long =3D tswap32(val); + g_byte_array_append(buf, (uint8_t *) &to_long, 4); + return 4; +} + +static inline int gdb_get_reg64(GByteArray *buf, uint64_t val) +{ + uint64_t to_quad =3D tswap64(val); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + return 8; +} + +static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi, + uint64_t val_lo) +{ + uint64_t to_quad; +#if TARGET_BIG_ENDIAN + to_quad =3D tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad =3D tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); +#else + to_quad =3D tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad =3D tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); +#endif + return 16; +} + +static inline int gdb_get_zeroes(GByteArray *array, size_t len) +{ + guint oldlen =3D array->len; + g_byte_array_set_size(array, oldlen + len); + memset(array->data + oldlen, 0, len); + + return len; +} + +/** + * gdb_get_reg_ptr: get pointer to start of last element + * @len: length of element + * + * This is a helper function to extract the pointer to the last + * element for additional processing. Some front-ends do additional + * dynamic swapping of the elements based on CPU state. + */ +static inline uint8_t *gdb_get_reg_ptr(GByteArray *buf, int len) +{ + return buf->data + buf->len - len; +} + +#if TARGET_LONG_BITS =3D=3D 64 +#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) +#define ldtul_p(addr) ldq_p(addr) +#else +#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val) +#define ldtul_p(addr) ldl_p(addr) +#endif + +#else +#error "gdbstub helpers should only be included by target specific code" +#endif + +#endif /* _GDBSTUB_HELPERS_H_ */ diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index e89992cf90..d69078899a 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -8,6 +8,7 @@ =20 #include "qemu/osdep.h" #include "exec/gdbstub.h" +#include "cpu.h" #include "semihosting/guestfd.h" #include "semihosting/syscalls.h" #include "semihosting/console.h" diff --git a/target/alpha/gdbstub.c b/target/alpha/gdbstub.c index 7db14f4431..0f8fa150f8 100644 --- a/target/alpha/gdbstub.c +++ b/target/alpha/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 2f806512d0..05d6eb802a 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "internals.h" #include "cpregs.h" =20 diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 07a6746944..48d2888b6f 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -20,7 +20,7 @@ #include "qemu/log.h" #include "cpu.h" #include "internals.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 0972a4bdd0..c3edf163be 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "qemu/log.h" diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index f94e87e728..e05da83af5 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "internals.h" +#include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/main-loop.h" #include "qemu/bitops.h" diff --git a/target/avr/gdbstub.c b/target/avr/gdbstub.c index 1c1b908c92..150344d8b9 100644 --- a/target/avr/gdbstub.c +++ b/target/avr/gdbstub.c @@ -19,7 +19,7 @@ */ =20 #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index 2418d575b1..25c0ca33a5 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index d152d01bfe..46083da620 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -16,7 +16,7 @@ */ =20 #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "cpu.h" #include "internal.h" =20 diff --git a/target/hppa/gdbstub.c b/target/hppa/gdbstub.c index 729c37b2ca..48a514384f 100644 --- a/target/hppa/gdbstub.c +++ b/target/hppa/gdbstub.c @@ -19,7 +19,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 786971284a..ebb000df6a 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "include/gdbstub/helpers.h" =20 #ifdef TARGET_X86_64 static const int gpr_map[16] =3D { diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 3d0c0b375f..52af81683c 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -12,7 +12,7 @@ #include "cpu.h" #include "exec/address-spaces.h" #include "exec/ioport.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/accel.h" #include "sysemu/whpx.h" #include "sysemu/cpus.h" diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index a4d1e28e36..fa3e034d15 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -10,6 +10,7 @@ #include "cpu.h" #include "internals.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 uint64_t read_fcc(CPULoongArchState *env) { diff --git a/target/m68k/gdbstub.c b/target/m68k/gdbstub.c index eb2d030e14..1e5f033a12 100644 --- a/target/m68k/gdbstub.c +++ b/target/m68k/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 4621cf2402..3b3a6ea8bd 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -23,6 +23,7 @@ #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h" +#include "gdbstub/helpers.h" #include "fpu/softfloat.h" #include "qemu/qemu-print.h" =20 diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 87b1314925..f753710d7d 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -21,6 +21,7 @@ =20 #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" #include "hw/boards.h" diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 8143fcae88..29ac6e9c0f 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 /* * GDB expects SREGs in the following order: diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index f1c2a2cf6d..62d7b72407 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "internal.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "fpu_helper.h" =20 int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mi= ps-semi.c index 85f0567a7f..4e6e759057 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -21,6 +21,7 @@ #include "cpu.h" #include "qemu/log.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" #include "semihosting/console.h" diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index cff30823da..bc5cbf81c2 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -23,7 +23,7 @@ #include "qapi/error.h" #include "cpu.h" #include "exec/log.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "hw/qdev-properties.h" =20 static void nios2_cpu_set_pc(CPUState *cs, vaddr value) diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index f76e8588c5..113b3f22aa 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" #include "qemu/log.h" diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index 095bf76c12..d1074a0581 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int = n) { diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index c31c6f12c4..3887812810 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -21,7 +21,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 0b8afdbacf..603c26715e 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -22,7 +22,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "hw/loader.h" =20 diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index d62ffe8a6f..0ce2e3c91d 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -20,7 +20,7 @@ =20 #include "qemu/osdep.h" #include "disas/dis-asm.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "kvm_ppc.h" #include "sysemu/cpus.h" #include "sysemu/hw_accel.h" diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 1a0b9ca82c..d2bc1d7c53 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "internal.h" =20 static int ppc_gdb_register_len_apple(int n) diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 6e7bbdbd5e..a542683901 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -18,6 +18,7 @@ =20 #include "qemu/osdep.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "cpu.h" =20 struct TypeSize { diff --git a/target/rx/gdbstub.c b/target/rx/gdbstub.c index 7eb2059a84..d7e0e6689b 100644 --- a/target/rx/gdbstub.c +++ b/target/rx/gdbstub.c @@ -17,7 +17,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index a5d69d0e0b..0cb69395b4 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -23,6 +23,7 @@ #include "s390x-internal.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/bitops.h" #include "sysemu/hw_accel.h" #include "sysemu/tcg.h" diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 473c8e51b0..2b363aa959 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -21,7 +21,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/timer.h" #include "hw/s390x/ioinst.h" #include "hw/s390x/pv.h" diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index 3488f68e32..d8e199fc06 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 /* Hint: Use "set architecture sh4" in GDB to see fpu registers */ /* FIXME: We should use XML for this. */ diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index 5d1e808e8c..a1c8fdc4d5 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 #ifdef TARGET_ABI32 #define gdb_get_rega(buf, val) gdb_get_reg32(buf, val) diff --git a/target/tricore/gdbstub.c b/target/tricore/gdbstub.c index 3a27a7e65d..e8f8e5e6ea 100644 --- a/target/tricore/gdbstub.c +++ b/target/tricore/gdbstub.c @@ -18,7 +18,7 @@ */ =20 #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" =20 =20 #define LCX_REGNUM 32 diff --git a/target/xtensa/core-dc232b.c b/target/xtensa/core-dc232b.c index c982d09c24..9aba2667e3 100644 --- a/target/xtensa/core-dc232b.c +++ b/target/xtensa/core-dc232b.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "qemu/timer.h" =20 diff --git a/target/xtensa/core-dc233c.c b/target/xtensa/core-dc233c.c index 595ab9a90f..9b0a625063 100644 --- a/target/xtensa/core-dc233c.c +++ b/target/xtensa/core-dc233c.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-dc233c/core-isa.h" diff --git a/target/xtensa/core-de212.c b/target/xtensa/core-de212.c index 50c995ba79..b08fe22e65 100644 --- a/target/xtensa/core-de212.c +++ b/target/xtensa/core-de212.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-de212/core-isa.h" diff --git a/target/xtensa/core-de233_fpu.c b/target/xtensa/core-de233_fpu.c index 41af8057fb..8845cdb592 100644 --- a/target/xtensa/core-de233_fpu.c +++ b/target/xtensa/core-de233_fpu.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-de233_fpu/core-isa.h" diff --git a/target/xtensa/core-dsp3400.c b/target/xtensa/core-dsp3400.c index 81e425c568..c0f94b9e27 100644 --- a/target/xtensa/core-dsp3400.c +++ b/target/xtensa/core-dsp3400.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-dsp3400/core-isa.h" diff --git a/target/xtensa/core-fsf.c b/target/xtensa/core-fsf.c index 3327c50b4f..310be8d61f 100644 --- a/target/xtensa/core-fsf.c +++ b/target/xtensa/core-fsf.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-fsf/core-isa.h" diff --git a/target/xtensa/core-lx106.c b/target/xtensa/core-lx106.c index 7a771d09a6..7f71d088f3 100644 --- a/target/xtensa/core-lx106.c +++ b/target/xtensa/core-lx106.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-lx106/core-isa.h" diff --git a/target/xtensa/core-sample_controller.c b/target/xtensa/core-sa= mple_controller.c index fd5de5576b..8867001aac 100644 --- a/target/xtensa/core-sample_controller.c +++ b/target/xtensa/core-sample_controller.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-sample_controller/core-isa.h" diff --git a/target/xtensa/core-test_kc705_be.c b/target/xtensa/core-test_k= c705_be.c index 294c16f2f4..bd082f49aa 100644 --- a/target/xtensa/core-test_kc705_be.c +++ b/target/xtensa/core-test_kc705_be.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-test_kc705_be/core-isa.h" diff --git a/target/xtensa/core-test_mmuhifi_c3.c b/target/xtensa/core-test= _mmuhifi_c3.c index c0e5d32d1e..3090dd01ed 100644 --- a/target/xtensa/core-test_mmuhifi_c3.c +++ b/target/xtensa/core-test_mmuhifi_c3.c @@ -27,7 +27,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-test_mmuhifi_c3/core-isa.h" diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index b6696063e5..4b3bfb7e59 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/log.h" =20 enum { diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index 2aa9777a8e..dbeb97a953 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -29,7 +29,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" diff --git a/target/xtensa/import_core.sh b/target/xtensa/import_core.sh index b4c15556c2..17dfec8957 100755 --- a/target/xtensa/import_core.sh +++ b/target/xtensa/import_core.sh @@ -41,7 +41,7 @@ tar -xf "$OVERLAY" -O binutils/xtensa-modules.c | \ cat < "${TARGET}.c" #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" =20 #include "core-$NAME/core-isa.h" --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784593; cv=none; d=zohomail.com; s=zohoarc; b=fv0Dx6yZUCHh6rVXC4RINVIBDeKdb0FSa2Uf/HeVcu1OvquFZxOx6490JZZZs9+d+/7H4e3Ks0jKg+e8kBTuK9TNVlfA3DsYXp/OIYVNklUcUgt9VxXl5iLGx5UyBjFYu48QcbpKXUj7iArWdp/PDh9XcNiAV4BPvSep8c7fHpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784593; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mu3qRCyDO4guc0nzRmGaSQnZxllkMZ61b4Vhvu/PJ/w=; b=SOiRbyr4gLFES8EPR/XWt5xSrmALmdlRF7acmKE3ZfQBocS3P29bp0f2K5c5Tp7sh9r6Q7lSNJvvcsTe6DzCFTn3S2naQCJ/jRcw7Vq4QUotIBZz4krAJH7trsBFfyitwm4ZFSO1VyGP29OTW24CJOVnekKy0brgNStsyelCcLU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784593661894.9117850741216; Thu, 2 Mar 2023 11:16:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoOR-0008J0-6H; Thu, 02 Mar 2023 14:15:07 -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 1pXoO6-0007OY-0X for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:46 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNo-0000mn-PD for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:45 -0500 Received: by mail-wr1-x430.google.com with SMTP id l1so116716wry.12 for ; Thu, 02 Mar 2023 11:14:24 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id j17-20020adff011000000b002c5a1bd527dsm136654wro.96.2023.03.02.11.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:21 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EF61D1FFBD; Thu, 2 Mar 2023 19:08:49 +0000 (GMT) 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=Mu3qRCyDO4guc0nzRmGaSQnZxllkMZ61b4Vhvu/PJ/w=; b=ITHg0PVWp/aG6JRcoHDiIcBvFb8K1tHiVqJOJ/T/BpLMad5DvyiLZHKUmi8N6vCrUL tugF8ezLBTCPKThyew9qqAQ6ge/tQVDRNXXFur+gT+kcJ1S4B2v60wF/x+T2BYp8Q8Pt bQpvHEY5Xec7mckiluTHg+AbliPmIKhhjrPk0T6jEBlCq2ea1xdbWRPK56NFMSpnjOS7 GGszvVfMWdQfLhlyXn1GGgDhrX+TmCYV9kVqn5fDAZ1cGDV/pKUm+M1gjLAr+lUMUD4V b9WnYp1MLO08zfjdiX3Aur4Esy4c2CQBSIyG+6C9T2yoDlmjSupdICqkTezG5F/ucXWe Hqmw== 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=Mu3qRCyDO4guc0nzRmGaSQnZxllkMZ61b4Vhvu/PJ/w=; b=BeyGQ/lhUh11F9E+p6tfABKota9PC8Hdo5AmgDHIVHsiDaqei/qKF9bpOJU58EVrvx CyvSh37RBZTZYHKhdo5RwWilL9OqJES17K6YidDs+GNVocga88PduLwj2SDmetaeeYn4 t/nFe0FSFAPP0W0zRF4+FirEMSwZCWy4W9LbIVNfXRMCMiMpqt4HD9kgMOqpyVeNRYTN GDy8vtjKK0b/PYVlMDOO069wbUTvrVzYAGaRS6viXdQadDgtPyBounO1OU6mUwMvzLbL Hm7CW+1uqLmBkqeDrwioq2oap38b+x3BFsHbQwBJOs6s7Fb9VyLI0xQKNwtR2nAhqUA9 OiGg== X-Gm-Message-State: AO0yUKUBj2sNUW7m792HO/kZAf0ctRmZVwwJEaG/DOafvBC++6s7NdsL KYaxC2M/ePpkDhD1AtIX740TvQ== X-Google-Smtp-Source: AK7set/hQ1rHrCpQHmTSWL07TymEFwYkdC2pqeF4uF0XpEqUUFFGALv/PTQxvb1bunF9wYHUNhuAqg== X-Received: by 2002:a5d:6449:0:b0:2c5:617a:5023 with SMTP id d9-20020a5d6449000000b002c5617a5023mr8114628wrw.71.1677784463785; Thu, 02 Mar 2023 11:14:23 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 21/26] gdbstub: move syscall handling to new file Date: Thu, 2 Mar 2023 19:08:41 +0000 Message-Id: <20230302190846.2593720-22-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784595031100003 Our GDB syscall support is the last chunk of code that needs target specific support so move it to a new file. We take the opportunity to move the syscall state into its own singleton instance and add in a few helpers for the main gdbstub to interact with the module. I also moved the gdb_exit() declaration into syscalls.h as it feels pretty related and most of the callers of it treat it as such. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v4 - checkpatch cleanups --- gdbstub/internals.h | 8 +- include/exec/gdbstub.h | 102 ------------- include/gdbstub/syscalls.h | 124 +++++++++++++++ gdbstub/gdbstub.c | 177 +--------------------- gdbstub/softmmu.c | 7 +- gdbstub/syscalls.c | 234 +++++++++++++++++++++++++++++ gdbstub/user.c | 1 + linux-user/exit.c | 2 +- semihosting/arm-compat-semi.c | 1 + semihosting/guestfd.c | 2 +- semihosting/syscalls.c | 2 +- softmmu/runstate.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/mips/tcg/sysemu/mips-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- gdbstub/meson.build | 4 + 16 files changed, 384 insertions(+), 288 deletions(-) create mode 100644 include/gdbstub/syscalls.h create mode 100644 gdbstub/syscalls.c diff --git a/gdbstub/internals.h b/gdbstub/internals.h index be0eef4850..8db61f7fb4 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -61,8 +61,6 @@ typedef struct GDBState { bool multiprocess; GDBProcess *processes; int process_num; - char syscall_buf[256]; - gdb_syscall_complete_cb current_syscall_cb; GString *str_buf; GByteArray *mem_buf; int sstep_flags; @@ -191,6 +189,12 @@ void gdb_handle_query_attached(GArray *params, void *u= ser_ctx); /* both */ void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx); void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx); =20 +/* sycall handling */ +void gdb_handle_file_io(GArray *params, void *user_ctx); +bool gdb_handled_syscall(void); +void gdb_disable_syscalls(void); +void gdb_syscall_reset(void); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index bb8a3928dd..7d743fe1e9 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -10,98 +10,6 @@ #define GDB_WATCHPOINT_READ 3 #define GDB_WATCHPOINT_ACCESS 4 =20 -/* For gdb file i/o remote protocol open flags. */ -#define GDB_O_RDONLY 0 -#define GDB_O_WRONLY 1 -#define GDB_O_RDWR 2 -#define GDB_O_APPEND 8 -#define GDB_O_CREAT 0x200 -#define GDB_O_TRUNC 0x400 -#define GDB_O_EXCL 0x800 - -/* For gdb file i/o remote protocol errno values */ -#define GDB_EPERM 1 -#define GDB_ENOENT 2 -#define GDB_EINTR 4 -#define GDB_EBADF 9 -#define GDB_EACCES 13 -#define GDB_EFAULT 14 -#define GDB_EBUSY 16 -#define GDB_EEXIST 17 -#define GDB_ENODEV 19 -#define GDB_ENOTDIR 20 -#define GDB_EISDIR 21 -#define GDB_EINVAL 22 -#define GDB_ENFILE 23 -#define GDB_EMFILE 24 -#define GDB_EFBIG 27 -#define GDB_ENOSPC 28 -#define GDB_ESPIPE 29 -#define GDB_EROFS 30 -#define GDB_ENAMETOOLONG 91 -#define GDB_EUNKNOWN 9999 - -/* For gdb file i/o remote protocol lseek whence. */ -#define GDB_SEEK_SET 0 -#define GDB_SEEK_CUR 1 -#define GDB_SEEK_END 2 - -/* For gdb file i/o stat/fstat. */ -typedef uint32_t gdb_mode_t; -typedef uint32_t gdb_time_t; - -struct gdb_stat { - uint32_t gdb_st_dev; /* device */ - uint32_t gdb_st_ino; /* inode */ - gdb_mode_t gdb_st_mode; /* protection */ - uint32_t gdb_st_nlink; /* number of hard links */ - uint32_t gdb_st_uid; /* user ID of owner */ - uint32_t gdb_st_gid; /* group ID of owner */ - uint32_t gdb_st_rdev; /* device type (if inode device) */ - uint64_t gdb_st_size; /* total size, in bytes */ - uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ - uint64_t gdb_st_blocks; /* number of blocks allocated */ - gdb_time_t gdb_st_atime; /* time of last access */ - gdb_time_t gdb_st_mtime; /* time of last modification */ - gdb_time_t gdb_st_ctime; /* time of last change */ -} QEMU_PACKED; - -struct gdb_timeval { - gdb_time_t tv_sec; /* second */ - uint64_t tv_usec; /* microsecond */ -} QEMU_PACKED; - -typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int e= rr); - -/** - * gdb_do_syscall: - * @cb: function to call when the system call has completed - * @fmt: gdb syscall format string - * ...: list of arguments to interpolate into @fmt - * - * Send a GDB syscall request. This function will return immediately; - * the callback function will be called later when the remote system - * call has completed. - * - * @fmt should be in the 'call-id,parameter,parameter...' format documented - * for the F request packet in the GDB remote protocol. A limited set of - * printf-style format specifiers is supported: - * %x - target_ulong argument printed in hex - * %lx - 64-bit argument printed in hex - * %s - string pointer (target_ulong) and length (int) pair - */ -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); -/** - * gdb_do_syscallv: - * @cb: function to call when the system call has completed - * @fmt: gdb syscall format string - * @va: arguments to interpolate into @fmt - * - * As gdb_do_syscall, but taking a va_list rather than a variable - * argument list. - */ -void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list = va); -int use_gdb_syscalls(void); =20 /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); @@ -120,16 +28,6 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); =20 -/** - * gdb_exit: exit gdb session, reporting inferior status - * @code: exit code reported - * - * This closes the session and sends a final packet to GDB reporting - * the exit status of the program. It also cleans up any connections - * detritus before returning. - */ -void gdb_exit(int code); - void gdb_set_stop_cpu(CPUState *cpu); =20 /** diff --git a/include/gdbstub/syscalls.h b/include/gdbstub/syscalls.h new file mode 100644 index 0000000000..5851a2c706 --- /dev/null +++ b/include/gdbstub/syscalls.h @@ -0,0 +1,124 @@ +/* + * GDB Syscall support + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#ifndef _SYSCALLS_H_ +#define _SYSCALLS_H_ + +/* For gdb file i/o remote protocol open flags. */ +#define GDB_O_RDONLY 0 +#define GDB_O_WRONLY 1 +#define GDB_O_RDWR 2 +#define GDB_O_APPEND 8 +#define GDB_O_CREAT 0x200 +#define GDB_O_TRUNC 0x400 +#define GDB_O_EXCL 0x800 + +/* For gdb file i/o remote protocol errno values */ +#define GDB_EPERM 1 +#define GDB_ENOENT 2 +#define GDB_EINTR 4 +#define GDB_EBADF 9 +#define GDB_EACCES 13 +#define GDB_EFAULT 14 +#define GDB_EBUSY 16 +#define GDB_EEXIST 17 +#define GDB_ENODEV 19 +#define GDB_ENOTDIR 20 +#define GDB_EISDIR 21 +#define GDB_EINVAL 22 +#define GDB_ENFILE 23 +#define GDB_EMFILE 24 +#define GDB_EFBIG 27 +#define GDB_ENOSPC 28 +#define GDB_ESPIPE 29 +#define GDB_EROFS 30 +#define GDB_ENAMETOOLONG 91 +#define GDB_EUNKNOWN 9999 + +/* For gdb file i/o remote protocol lseek whence. */ +#define GDB_SEEK_SET 0 +#define GDB_SEEK_CUR 1 +#define GDB_SEEK_END 2 + +/* For gdb file i/o stat/fstat. */ +typedef uint32_t gdb_mode_t; +typedef uint32_t gdb_time_t; + +struct gdb_stat { + uint32_t gdb_st_dev; /* device */ + uint32_t gdb_st_ino; /* inode */ + gdb_mode_t gdb_st_mode; /* protection */ + uint32_t gdb_st_nlink; /* number of hard links */ + uint32_t gdb_st_uid; /* user ID of owner */ + uint32_t gdb_st_gid; /* group ID of owner */ + uint32_t gdb_st_rdev; /* device type (if inode device) */ + uint64_t gdb_st_size; /* total size, in bytes */ + uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ + uint64_t gdb_st_blocks; /* number of blocks allocated */ + gdb_time_t gdb_st_atime; /* time of last access */ + gdb_time_t gdb_st_mtime; /* time of last modification */ + gdb_time_t gdb_st_ctime; /* time of last change */ +} QEMU_PACKED; + +struct gdb_timeval { + gdb_time_t tv_sec; /* second */ + uint64_t tv_usec; /* microsecond */ +} QEMU_PACKED; + +typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int e= rr); + +/** + * gdb_do_syscall: + * @cb: function to call when the system call has completed + * @fmt: gdb syscall format string + * ...: list of arguments to interpolate into @fmt + * + * Send a GDB syscall request. This function will return immediately; + * the callback function will be called later when the remote system + * call has completed. + * + * @fmt should be in the 'call-id,parameter,parameter...' format documented + * for the F request packet in the GDB remote protocol. A limited set of + * printf-style format specifiers is supported: + * %x - target_ulong argument printed in hex + * %lx - 64-bit argument printed in hex + * %s - string pointer (target_ulong) and length (int) pair + */ +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); + +/** + * gdb_do_syscallv: + * @cb: function to call when the system call has completed + * @fmt: gdb syscall format string + * @va: arguments to interpolate into @fmt + * + * As gdb_do_syscall, but taking a va_list rather than a variable + * argument list. + */ +void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list = va); + +/** + * use_gdb_syscalls() - report if GDB should be used for syscalls + * + * This is mostly driven by the semihosting mode the user configures + * but assuming GDB is allowed by that we report true if GDB is + * connected to the stub. + */ +int use_gdb_syscalls(void); + +/** + * gdb_exit: exit gdb session, reporting inferior status + * @code: exit code reported + * + * This closes the session and sends a final packet to GDB reporting + * the exit status of the program. It also cleans up any connections + * detritus before returning. + */ +void gdb_exit(int code); + +#endif /* _SYSCALLS_H_ */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index f1504af44f..e264ed04e7 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -29,6 +29,7 @@ #include "qemu/module.h" #include "trace.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #ifdef CONFIG_USER_ONLY #include "gdbstub/user.h" #else @@ -38,7 +39,6 @@ =20 #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#include "semihosting/semihost.h" #include "exec/exec-all.h" #include "exec/replay-core.h" #include "exec/tb-flush.h" @@ -78,41 +78,6 @@ void gdb_init_gdbserver_state(void) =20 bool gdb_has_xml; =20 -/* - * Return true if there is a GDB currently connected to the stub - * and attached to a CPU - */ -static bool gdb_attached(void) -{ - return gdbserver_state.init && gdbserver_state.c_cpu; -} - -static enum { - GDB_SYS_UNKNOWN, - GDB_SYS_ENABLED, - GDB_SYS_DISABLED, -} gdb_syscall_mode; - -/* Decide if either remote gdb syscalls or native file IO should be used. = */ -int use_gdb_syscalls(void) -{ - SemihostingTarget target =3D semihosting_get_target(); - if (target =3D=3D SEMIHOSTING_TARGET_NATIVE) { - /* -semihosting-config target=3Dnative */ - return false; - } else if (target =3D=3D SEMIHOSTING_TARGET_GDB) { - /* -semihosting-config target=3Dgdb */ - return true; - } - - /* -semihosting-config target=3Dauto */ - /* On the first call check if gdb is connected and remember. */ - if (gdb_syscall_mode =3D=3D GDB_SYS_UNKNOWN) { - gdb_syscall_mode =3D gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DI= SABLED; - } - return gdb_syscall_mode =3D=3D GDB_SYS_ENABLED; -} - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -922,7 +887,7 @@ static void handle_detach(GArray *params, void *user_ct= x) =20 if (!gdbserver_state.c_cpu) { /* No more process attached */ - gdb_syscall_mode =3D GDB_SYS_DISABLED; + gdb_disable_syscalls(); gdb_continue(); } gdb_put_packet("OK"); @@ -1235,60 +1200,6 @@ static void handle_read_all_regs(GArray *params, voi= d *user_ctx) gdb_put_strbuf(); } =20 -static void handle_file_io(GArray *params, void *user_ctx) -{ - if (params->len >=3D 1 && gdbserver_state.current_syscall_cb) { - uint64_t ret; - int err; - - ret =3D get_param(params, 0)->val_ull; - if (params->len >=3D 2) { - err =3D get_param(params, 1)->val_ull; - } else { - err =3D 0; - } - - /* Convert GDB error numbers back to host error numbers. */ -#define E(X) case GDB_E##X: err =3D E##X; break - switch (err) { - case 0: - break; - E(PERM); - E(NOENT); - E(INTR); - E(BADF); - E(ACCES); - E(FAULT); - E(BUSY); - E(EXIST); - E(NODEV); - E(NOTDIR); - E(ISDIR); - E(INVAL); - E(NFILE); - E(MFILE); - E(FBIG); - E(NOSPC); - E(SPIPE); - E(ROFS); - E(NAMETOOLONG); - default: - err =3D EINVAL; - break; - } -#undef E - - gdbserver_state.current_syscall_cb(gdbserver_state.c_cpu, ret, err= ); - gdbserver_state.current_syscall_cb =3D NULL; - } - - if (params->len >=3D 3 && get_param(params, 2)->opcode =3D=3D (uint8_t= )'C') { - gdb_put_packet("T02"); - return; - } - - gdb_continue(); -} =20 static void handle_step(GArray *params, void *user_ctx) { @@ -1894,7 +1805,7 @@ static int gdb_handle_packet(const char *line_buf) case 'F': { static const GdbCmdParseEntry file_io_cmd_desc =3D { - .handler =3D handle_file_io, + .handler =3D gdb_handle_file_io, .cmd =3D "F", .cmd_startswith =3D 1, .schema =3D "L,L,o0" @@ -2062,88 +1973,6 @@ void gdb_set_stop_cpu(CPUState *cpu) gdbserver_state.g_cpu =3D cpu; } =20 -/* Send a gdb syscall request. - This accepts limited printf-style format specifiers, specifically: - %x - target_ulong argument printed in hex. - %lx - 64-bit argument printed in hex. - %s - string pointer (target_ulong) and length (int) pair. */ -void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list = va) -{ - char *p; - char *p_end; - target_ulong addr; - uint64_t i64; - - if (!gdb_attached()) { - return; - } - - gdbserver_state.current_syscall_cb =3D cb; -#ifndef CONFIG_USER_ONLY - vm_stop(RUN_STATE_DEBUG); -#endif - p =3D &gdbserver_state.syscall_buf[0]; - p_end =3D &gdbserver_state.syscall_buf[sizeof(gdbserver_state.syscall_= buf)]; - *(p++) =3D 'F'; - while (*fmt) { - if (*fmt =3D=3D '%') { - fmt++; - switch (*fmt++) { - case 'x': - addr =3D va_arg(va, target_ulong); - p +=3D snprintf(p, p_end - p, TARGET_FMT_lx, addr); - break; - case 'l': - if (*(fmt++) !=3D 'x') - goto bad_format; - i64 =3D va_arg(va, uint64_t); - p +=3D snprintf(p, p_end - p, "%" PRIx64, i64); - break; - case 's': - addr =3D va_arg(va, target_ulong); - p +=3D snprintf(p, p_end - p, TARGET_FMT_lx "/%x", - addr, va_arg(va, int)); - break; - default: - bad_format: - error_report("gdbstub: Bad syscall format string '%s'", - fmt - 1); - break; - } - } else { - *(p++) =3D *(fmt++); - } - } - *p =3D 0; -#ifdef CONFIG_USER_ONLY - gdb_put_packet(gdbserver_state.syscall_buf); - /* Return control to gdb for it to process the syscall request. - * Since the protocol requires that gdb hands control back to us - * using a "here are the results" F packet, we don't need to check - * gdb_handlesig's return value (which is the signal to deliver if - * execution was resumed via a continue packet). - */ - gdb_handlesig(gdbserver_state.c_cpu, 0); -#else - /* In this case wait to send the syscall packet until notification that - the CPU has stopped. This must be done because if the packet is se= nt - now the reply from the syscall request could be received while the = CPU - is still in the running state, which can cause packets to be dropped - and state transition 'T' packets to be sent while the syscall is st= ill - being processed. */ - qemu_cpu_kick(gdbserver_state.c_cpu); -#endif -} - -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) -{ - va_list va; - - va_start(va, fmt); - gdb_do_syscallv(cb, fmt, va); - va_end(va); -} - void gdb_read_byte(uint8_t ch) { uint8_t reply; diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index d2863d0663..d3152fb6e7 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -15,6 +15,7 @@ #include "qemu/error-report.h" #include "qemu/cutils.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" #include "sysemu/cpus.h" @@ -113,9 +114,9 @@ static void gdb_vm_state_change(void *opaque, bool runn= ing, RunState state) if (running || gdbserver_state.state =3D=3D RS_INACTIVE) { return; } + /* Is there a GDB syscall waiting to be sent? */ - if (gdbserver_state.current_syscall_cb) { - gdb_put_packet(gdbserver_state.syscall_buf); + if (gdb_handled_syscall()) { return; } =20 @@ -384,7 +385,7 @@ int gdbserver_start(const char *device) } gdbserver_state.state =3D chr ? RS_IDLE : RS_INACTIVE; gdbserver_system_state.mon_chr =3D mon_chr; - gdbserver_state.current_syscall_cb =3D NULL; + gdb_syscall_reset(); =20 return 0; } diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c new file mode 100644 index 0000000000..f15b210958 --- /dev/null +++ b/gdbstub/syscalls.c @@ -0,0 +1,234 @@ +/* + * GDB Syscall Handling + * + * GDB can execute syscalls on the guests behalf, currently used by + * the various semihosting extensions. As this interfaces with a guest + * ABI we need to build it per-guest (although in reality its a 32 or + * 64 bit target_ulong that is the only difference). + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "semihosting/semihost.h" +#include "sysemu/runstate.h" +#include "gdbstub/user.h" +#include "gdbstub/syscalls.h" +#include "trace.h" +#include "internals.h" + +/* Syscall specific state */ +typedef struct { + char syscall_buf[256]; + gdb_syscall_complete_cb current_syscall_cb; +} GDBSyscallState; + +static GDBSyscallState gdbserver_syscall_state; + +/* + * Return true if there is a GDB currently connected to the stub + * and attached to a CPU + */ +static bool gdb_attached(void) +{ + return gdbserver_state.init && gdbserver_state.c_cpu; +} + +static enum { + GDB_SYS_UNKNOWN, + GDB_SYS_ENABLED, + GDB_SYS_DISABLED, +} gdb_syscall_mode; + +/* Decide if either remote gdb syscalls or native file IO should be used. = */ +int use_gdb_syscalls(void) +{ + SemihostingTarget target =3D semihosting_get_target(); + if (target =3D=3D SEMIHOSTING_TARGET_NATIVE) { + /* -semihosting-config target=3Dnative */ + return false; + } else if (target =3D=3D SEMIHOSTING_TARGET_GDB) { + /* -semihosting-config target=3Dgdb */ + return true; + } + + /* -semihosting-config target=3Dauto */ + /* On the first call check if gdb is connected and remember. */ + if (gdb_syscall_mode =3D=3D GDB_SYS_UNKNOWN) { + gdb_syscall_mode =3D gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DI= SABLED; + } + return gdb_syscall_mode =3D=3D GDB_SYS_ENABLED; +} + +/* called when the stub detaches */ +void gdb_disable_syscalls(void) +{ + gdb_syscall_mode =3D GDB_SYS_DISABLED; +} + +void gdb_syscall_reset(void) +{ + gdbserver_syscall_state.current_syscall_cb =3D NULL; +} + +bool gdb_handled_syscall(void) +{ + if (gdbserver_syscall_state.current_syscall_cb) { + gdb_put_packet(gdbserver_syscall_state.syscall_buf); + return true; + } + + return false; +} + +/* + * Send a gdb syscall request. + * This accepts limited printf-style format specifiers, specifically: + * %x - target_ulong argument printed in hex. + * %lx - 64-bit argument printed in hex. + * %s - string pointer (target_ulong) and length (int) pair. + */ +void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list = va) +{ + char *p; + char *p_end; + target_ulong addr; + uint64_t i64; + + if (!gdb_attached()) { + return; + } + + gdbserver_syscall_state.current_syscall_cb =3D cb; +#ifndef CONFIG_USER_ONLY + vm_stop(RUN_STATE_DEBUG); +#endif + p =3D &gdbserver_syscall_state.syscall_buf[0]; + p_end =3D &gdbserver_syscall_state.syscall_buf[sizeof(gdbserver_syscal= l_state.syscall_buf)]; + *(p++) =3D 'F'; + while (*fmt) { + if (*fmt =3D=3D '%') { + fmt++; + switch (*fmt++) { + case 'x': + addr =3D va_arg(va, target_ulong); + p +=3D snprintf(p, p_end - p, TARGET_FMT_lx, addr); + break; + case 'l': + if (*(fmt++) !=3D 'x') { + goto bad_format; + } + i64 =3D va_arg(va, uint64_t); + p +=3D snprintf(p, p_end - p, "%" PRIx64, i64); + break; + case 's': + addr =3D va_arg(va, target_ulong); + p +=3D snprintf(p, p_end - p, TARGET_FMT_lx "/%x", + addr, va_arg(va, int)); + break; + default: + bad_format: + error_report("gdbstub: Bad syscall format string '%s'", + fmt - 1); + break; + } + } else { + *(p++) =3D *(fmt++); + } + } + *p =3D 0; +#ifdef CONFIG_USER_ONLY + gdb_put_packet(gdbserver_syscall_state.syscall_buf); + /* + * Return control to gdb for it to process the syscall request. + * Since the protocol requires that gdb hands control back to us + * using a "here are the results" F packet, we don't need to check + * gdb_handlesig's return value (which is the signal to deliver if + * execution was resumed via a continue packet). + */ + gdb_handlesig(gdbserver_state.c_cpu, 0); +#else + /* + * In this case wait to send the syscall packet until notification that + * the CPU has stopped. This must be done because if the packet is se= nt + * now the reply from the syscall request could be received while the = CPU + * is still in the running state, which can cause packets to be dropped + * and state transition 'T' packets to be sent while the syscall is st= ill + * being processed. + */ + qemu_cpu_kick(gdbserver_state.c_cpu); +#endif +} + +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + gdb_do_syscallv(cb, fmt, va); + va_end(va); +} + +/* + * GDB Command Handlers + */ + +void gdb_handle_file_io(GArray *params, void *user_ctx) +{ + if (params->len >=3D 1 && gdbserver_syscall_state.current_syscall_cb) { + uint64_t ret; + int err; + + ret =3D get_param(params, 0)->val_ull; + if (params->len >=3D 2) { + err =3D get_param(params, 1)->val_ull; + } else { + err =3D 0; + } + + /* Convert GDB error numbers back to host error numbers. */ +#define E(X) case GDB_E##X: err =3D E##X; break + switch (err) { + case 0: + break; + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(ACCES); + E(FAULT); + E(BUSY); + E(EXIST); + E(NODEV); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + err =3D EINVAL; + break; + } +#undef E + + gdbserver_syscall_state.current_syscall_cb(gdbserver_state.c_cpu, + ret, err); + gdbserver_syscall_state.current_syscall_cb =3D NULL; + } + + if (params->len >=3D 3 && get_param(params, 2)->opcode =3D=3D (uint8_t= )'C') { + gdb_put_packet("T02"); + return; + } + + gdb_continue(); +} diff --git a/gdbstub/user.c b/gdbstub/user.c index 3f6183e66a..3da410e221 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -15,6 +15,7 @@ #include "exec/hwaddr.h" #include "exec/tb-flush.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/user.h" #include "hw/core/cpu.h" #include "trace.h" diff --git a/linux-user/exit.c b/linux-user/exit.c index 607b6da9fc..fd49d76f45 100644 --- a/linux-user/exit.c +++ b/linux-user/exit.c @@ -18,7 +18,7 @@ */ #include "qemu/osdep.h" #include "accel/tcg/perf.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "qemu.h" #include "user-internals.h" #ifdef CONFIG_GPROF diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 62d8bae97f..564fe17f75 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -34,6 +34,7 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/console.h" #include "semihosting/common-semi.h" diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c index b05c52f26f..acb86b50dd 100644 --- a/semihosting/guestfd.c +++ b/semihosting/guestfd.c @@ -9,7 +9,7 @@ */ =20 #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/guestfd.h" #ifdef CONFIG_USER_ONLY diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index d69078899a..42080ffdda 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -7,8 +7,8 @@ */ =20 #include "qemu/osdep.h" -#include "exec/gdbstub.h" #include "cpu.h" +#include "gdbstub/syscalls.h" #include "semihosting/guestfd.h" #include "semihosting/syscalls.h" #include "semihosting/console.h" diff --git a/softmmu/runstate.c b/softmmu/runstate.c index f9ad88e6a7..6ee622841d 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -30,7 +30,7 @@ #include "crypto/cipher.h" #include "crypto/init.h" #include "exec/cpu-common.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "hw/boards.h" #include "migration/misc.h" #include "migration/postcopy-ram.h" diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index f753710d7d..88ad9ba814 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" =20 #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mi= ps-semi.c index 4e6e759057..f3735df7b9 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "qemu/log.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/helpers.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 113b3f22aa..3738774976 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -23,7 +23,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" diff --git a/gdbstub/meson.build b/gdbstub/meson.build index 773bd4b9c9..c876222b9c 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -5,6 +5,10 @@ # =20 specific_ss.add(files('gdbstub.c')) + +# These have to built to the target ABI +specific_ss.add(files('syscalls.c')) + softmmu_ss.add(files('softmmu.c')) user_ss.add(files('user.c')) =20 --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784605; cv=none; d=zohomail.com; s=zohoarc; b=EkLwLre7M9UVCLvnBG35o9edxTs4SRjqkhz8zS3oYCtMIXUue0qqlDAomQeu7OiH4OD8Q2muGfmqFtNWxoN/0kz8Qasy1MQQ6tGe+VZJUwLsTeFF9bAplnS47/SVKCRSOYfrqIblijpYrk6gBxOOjw5LZ15GzLUZ7ir7p/X80o4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784605; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0nGJS3TcjePwhHIbOnspKgR49rDlBrdUVNx8YN4xopU=; b=EwK3DWpy7RdhwMSE9MIvIPyPmx+ymsKjfPy1rWRnkbFo2GVcg4gUmRTjhk0y2Ef/Ya2PAqt65nR4oBcxRCWF6eVX+tIi5iMkXZqSmJsK9BkQylXa+mUE0VGXmG3dheMoVawlQDgXGWov0GRaSPsameJxXbThNlce9vYwRd+QZqg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784605041416.1686335127157; Thu, 2 Mar 2023 11:16:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoNu-0006l0-Sg; Thu, 02 Mar 2023 14:14:34 -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 1pXoNs-0006fz-9a for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:32 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNj-0000kq-Ms for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:31 -0500 Received: by mail-wr1-x42b.google.com with SMTP id l1so116625wry.12 for ; Thu, 02 Mar 2023 11:14:23 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p1-20020a5d4581000000b002c55551e6e9sm132841wrq.108.2023.03.02.11.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:21 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 169191FFBF; Thu, 2 Mar 2023 19:08:50 +0000 (GMT) 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=0nGJS3TcjePwhHIbOnspKgR49rDlBrdUVNx8YN4xopU=; b=c2dzS+/vMLVsojBfKJnEcMJI5C2OOz7g80CJOtOK2sGwGB9UfyRI7b66Zc3u8JAhr7 tIZZPqcIjCZvniFrH7r32uHBud/Fiy3m+p3k1gSDIc7mNt4vR2EtGC98sXXRCyQ9/eFf dbKQSelNgujobyuQ0AWo8bW92pn2l31Rwwal9LQSpNcak4fTZ5REKqUQucip7T1sFwkn jp1BWroal/WWkMEdYmfJTGtzy/UaYpvygzL9MStYCAe3AOAXLZWIH9ffXLWwdttZ24cE Q6nwksCyebBOzkoFpUPoUagwvZJGbH9Xd+gPS4Xv75+1OqDBCDSY7vfRTF7oUfXm3m3B qgNQ== 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=0nGJS3TcjePwhHIbOnspKgR49rDlBrdUVNx8YN4xopU=; b=c+A/uuYQkvQhLRNsrp1pqzuglSXf6Wof4DqX7oZRQPsS6hHEt1cnaZKneaKwFETmvn iXyJsChkG8K1oj12C6+iVU0vMneHv6xpBGBgLaWFOLxZlrhr4+y4b99Oe+QwYrxAQbBS r8uffoO7aJ8j6zaM6yrkMsmQCBb9Et5LhfpZo3+TGqQrYS4hI276hMefpZxutcISPo00 Y/wdSfBQKXDIRyvGHtUGOWB0L8U2MkN2TCt1nzDrCVqs/7z/e5ncu0qHC0rmfYbSqK2t b449SilfRMjiqo1LPm1LOlN7HGmavcluMmmHxlX1V8z+mB4/Me5juFVQfpAUs7zYxPGe Yf0g== X-Gm-Message-State: AO0yUKUHxi0vvRPIcRD0ZXeSGlQXnUPw7DSM/6ciqN5ybN7P9nsRXRp1 TtF2xq7v/JgeUjSgL1vp3za4aQ== X-Google-Smtp-Source: AK7set+Q70UxKdpfAWTcqp8rXJI6MlAyYRt6imddI390dRCuIlRX5/AkaY1nmZEit+fxPIc10A9txA== X-Received: by 2002:a05:6000:108c:b0:242:1809:7e17 with SMTP id y12-20020a056000108c00b0024218097e17mr8349240wrw.6.1677784462023; Thu, 02 Mar 2023 11:14:22 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 22/26] gdbstub: only compile gdbstub twice for whole build Date: Thu, 2 Mar 2023 19:08:42 +0000 Message-Id: <20230302190846.2593720-23-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784607112100003 Now we have removed any target specific bits from the core gdbstub code we only need to build it twice. We have to jump a few meson hoops to manually define the CONFIG_USER_ONLY symbol but it seems to work. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- v3 - also include user and softmmu bits in the library v4 - include genh for config-poison.h --- gdbstub/gdbstub.c | 4 +--- gdbstub/meson.build | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index e264ed04e7..d9e9bf9294 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -39,9 +39,7 @@ =20 #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#include "exec/exec-all.h" #include "exec/replay-core.h" -#include "exec/tb-flush.h" #include "exec/hwaddr.h" =20 #include "internals.h" @@ -1612,7 +1610,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = =3D { .cmd_startswith =3D 1, .schema =3D "s:l,l0" }, -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) +#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX) { .handler =3D gdb_handle_query_xfer_auxv, .cmd =3D "Xfer:auxv:read::", diff --git a/gdbstub/meson.build b/gdbstub/meson.build index c876222b9c..d679c7ab86 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -4,13 +4,35 @@ # types such as hwaddr. # =20 -specific_ss.add(files('gdbstub.c')) +# We need to build the core gdb code via a library to be able to tweak +# cflags so: + +gdb_user_ss =3D ss.source_set() +gdb_softmmu_ss =3D ss.source_set() + +# We build two versions of gdbstub, one for each mode +gdb_user_ss.add(files('gdbstub.c', 'user.c')) +gdb_softmmu_ss.add(files('gdbstub.c', 'softmmu.c')) + +gdb_user_ss =3D gdb_user_ss.apply(config_host, strict: false) +gdb_softmmu_ss =3D gdb_softmmu_ss.apply(config_host, strict: false) + +libgdb_user =3D static_library('gdb_user', + gdb_user_ss.sources() + genh, + name_suffix: 'fa', + c_args: '-DCONFIG_USER_ONLY') + +libgdb_softmmu =3D static_library('gdb_softmmu', + gdb_softmmu_ss.sources() + genh, + name_suffix: 'fa') + +gdb_user =3D declare_dependency(link_whole: libgdb_user) +user_ss.add(gdb_user) +gdb_softmmu =3D declare_dependency(link_whole: libgdb_softmmu) +softmmu_ss.add(gdb_softmmu) =20 # These have to built to the target ABI specific_ss.add(files('syscalls.c')) =20 -softmmu_ss.add(files('softmmu.c')) -user_ss.add(files('user.c')) - # The user-target is specialised by the guest specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-target.c')) --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784569; cv=none; d=zohomail.com; s=zohoarc; b=ga+b2Y/JAsd4Z5oPVejguk59v+d8Ewv3gQdWXFNiGsjS9HYYgLaE04xiwS9x76My/nzZFgGuHlc+ZVivZ+tFdfPQlLljTqp8jpPO6/mzpUoS6299qMj/WSQ5E2CcJLphacVyzvmyobT6spOSnbi4/inA4qh/71Qgk1krRN3bs7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784569; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SHqP0mS63nM1LMhj8fwJgrUBh7QK4PmkZnnhc4Xo7qc=; b=cAYRP/le0WyGR7VZhpE3j2Sta0AHeSJQejb3a6dpRWZPSyGc0wHhKCMMqsdeRKi9rlxK0/H5sUiwiSOITTwOr3mChMsTAMx/9OIfos3WyPur1JNs0Wi0eDO+By8pUrlh7mZ0HCpEmLLtKw3X3CfXvY6CpgvUvir9mnTTnj+tN4U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784569253194.78575205135905; Thu, 2 Mar 2023 11:16:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoNq-0006Zn-3g; 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-0006Ws-M1 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:28 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNi-0000ju-Ne for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:27 -0500 Received: by mail-wm1-x32d.google.com with SMTP id az36so305649wmb.1 for ; Thu, 02 Mar 2023 11:14:22 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o13-20020a5d670d000000b002c8476dde7asm120991wru.114.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 3E8B91FFBE; Thu, 2 Mar 2023 19:08:50 +0000 (GMT) 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=SHqP0mS63nM1LMhj8fwJgrUBh7QK4PmkZnnhc4Xo7qc=; b=PDa/dcDpBdf7Yr/DlQC5v0nFm6bicQJa3gMfQr9zCWc/O2mMZdUA66hkUwZr3TWQQa ++eYUJCpL1OhQY7j9NaQyyIjvFQgS5xaZk3+XzPxaMLVXt2kz+M1aijI0+pSpWEAApQc PBY3jR0+j5DK2Q0QSMPeP0ymoF340mHvkakUHMIv05uJX1Hn6ruNPYEpErT73Xiqbrbx NqCf5JrB7+miCS8laKMpFsy3yGjibw+6EIbTKE+a6pLgU+0ZJKVQ3mTkDGnBOLkl5JzY anO0FFFqtKJXdfqfkiBkqGswtq3htwxR61fqNWsXLiZuRRz2zQsouFqvtHz/GrVhIJNT uhYg== 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=SHqP0mS63nM1LMhj8fwJgrUBh7QK4PmkZnnhc4Xo7qc=; b=y1qprabkKJ2F+kkU7X/gYE0iCnU8j0klCQR4jlmTrSYlfxlzPb9Iqx7vr29tJ9sR/L DE89FkSNumxn5DShsRjpIk+1/Tf36/kHy6lIZj50+cTXBQi1NSQeYpUpb1r/Ex5zt2QN FphfsSa1wK2LazOf4ocWKUgr6N1TFwr1DqM/dGrpR71pOC85pasdpw1iuGjDBLSb7QEq WR1h9Pf7TEHstflb4rCw3AL/pHYsvHaJk3+Wix0BiMjFDFiDtGAXiiFqXBQP58sUXEwC DuzdZFc5zlgLbf1eDl66HrhkNMbWNE4I0TCEqmMQL9IKIGv8/xj3/J94+c88tnL15yrz EoJQ== X-Gm-Message-State: AO0yUKWKGIg/0QBzI23DKogHK+obAnPY6KoM5k5BpLrP16dJWt8sdCu7 K/asTqUnAbOJK8aM6h8STnP2sw== X-Google-Smtp-Source: AK7set8Ioc1FNmoloOZrAJ5xaY7xQfST/RYkOOsYeAnORIav+mBmvD9I+biCCDSCw4ATGgxCqKL+Og== X-Received: by 2002:a05:600c:746:b0:3ea:e554:77fe with SMTP id j6-20020a05600c074600b003eae55477femr8390053wmn.12.1677784460910; Thu, 02 Mar 2023 11:14:20 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 23/26] testing: probe gdb for supported architectures ahead of time Date: Thu, 2 Mar 2023 19:08:43 +0000 Message-Id: <20230302190846.2593720-24-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784570103100001 Currently when we encounter a gdb that is old or not built with multiarch in mind we fail rather messily. Try and improve the situation by probing ahead of time and setting HOST_GDB_SUPPORTS_ARCH=3Dy in the relevant tcg configs. We can then skip and give a more meaningful message if we don't run the test. Signed-off-by: Alex Benn=C3=A9e Cc: Richard Henderson Cc: Paolo Bonzini Reviewed-by: Richard Henderson --- v4 - convert script to python, use mapping to set arches - update MAINTAINERS --- MAINTAINERS | 1 + configure | 8 ++ scripts/probe-gdb-support.py | 88 +++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- tests/tcg/multiarch/Makefile.target | 5 ++ .../multiarch/system/Makefile.softmmu-target | 6 +- tests/tcg/s390x/Makefile.target | 2 +- 7 files changed, 109 insertions(+), 3 deletions(-) create mode 100755 scripts/probe-gdb-support.py diff --git a/MAINTAINERS b/MAINTAINERS index c7a8e2307f..8d0113b8f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2739,6 +2739,7 @@ F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ F: scripts/feature_to_c.sh +F: scripts/probe-gdb-support.py =20 Memory API M: Paolo Bonzini diff --git a/configure b/configure index 50a0b80b27..f0cd3923f3 100755 --- a/configure +++ b/configure @@ -230,6 +230,7 @@ stack_protector=3D"" safe_stack=3D"" use_containers=3D"yes" gdb_bin=3D$(command -v "gdb-multiarch" || command -v "gdb") +gdb_arches=3D"" =20 if test -e "$source_path/.git" then @@ -2392,6 +2393,7 @@ if test -n "$gdb_bin"; then gdb_version=3D$($gdb_bin --version | head -n 1) if version_ge ${gdb_version##* } 9.1; then echo "HAVE_GDB_BIN=3D$gdb_bin" >> $config_host_mak + gdb_arches=3D$("$source_path/scripts/probe-gdb-support.py" $gdb_bi= n) else gdb_bin=3D"" fi @@ -2516,6 +2518,12 @@ for target in $target_list; do write_target_makefile "build-tcg-tests-$target" >> "$config_target_m= ak" echo "BUILD_STATIC=3D$build_static" >> "$config_target_mak" echo "QEMU=3D$PWD/$qemu" >> "$config_target_mak" + + # will GDB work with these binaries? + if test "${gdb_arches#*$arch}" !=3D "$gdb_arches"; then + echo "HOST_GDB_SUPPORTS_ARCH=3Dy" >> "$config_target_mak" + fi + echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs tcg_tests_targets=3D"$tcg_tests_targets $target" fi diff --git a/scripts/probe-gdb-support.py b/scripts/probe-gdb-support.py new file mode 100755 index 0000000000..c786b7620e --- /dev/null +++ b/scripts/probe-gdb-support.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# +# Probe gdb for supported architectures. +# +# This is required to support testing of the gdbstub as its hard to +# handle errors gracefully during the test. Instead this script when +# passed a GDB binary will probe its architecture support and return a +# string of supported arches, stripped of guff. +# +# Copyright 2023 Linaro Ltd +# +# Author: Alex Benn=C3=A9e +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import re +from subprocess import check_output, STDOUT + +# mappings from gdb arch to QEMU target +mappings =3D { + "alpha" : "alpha", + "aarch64" : ["aarch64", "aarch64_be"], + "armv7": "arm", + "armv8-a" : ["aarch64", "aarch64_be"], + "avr" : "avr", + "cris" : "cris", + # hexagon? + "hppa1.0" : "hppa", + "i386" : "i386", + "i386:x86-64" : "x86_64", + # loongarch? + "m68k" : "m68k", + "MicroBlaze" : "microblaze", + "mips:isa64" : ["mips64", "mips64el"], + "nios2" : "nios2", + "or1k" : "or1k", + "powerpc:common" : "ppc", + "powerpc:common64" : "ppc64", + "riscv:rv32" : "riscv32", + "riscv:rv64" : "riscv64", + "s390:64-bit" : "s390x", + "sh4" : ["sh4", "sh4eb"], + "sparc": "sparc", + "sparc:v8plus": "sparc32plus", + "sparc:v9a" : "sparc64", + # no tricore in upstream gdb + "xtensa" : ["xtensa", "xtensaeb"] +} + +def do_probe(gdb): + gdb_out =3D check_output([gdb, + "-ex", "set architecture", + "-ex", "quit"], stderr=3DSTDOUT) + + m =3D re.search(r"Valid arguments are (.*)", + gdb_out.decode("utf-8")) + + valid_arches =3D set() + + if m.group(1): + for arch in m.group(1).split(", "): + if arch in mappings: + mapping =3D mappings[arch] + if isinstance(mapping, str): + valid_arches.add(mapping) + else: + for entry in mapping: + valid_arches.add(entry) + + return valid_arches + +def main() -> None: + parser =3D argparse.ArgumentParser(description=3D'Probe GDB Architectu= res') + parser.add_argument('gdb', help=3D'Path to GDB binary.') + + args =3D parser.parse_args() + + supported =3D do_probe(args.gdb) + + print(" ".join(supported)) + +if __name__ =3D=3D '__main__': + main() diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index db122ab4ff..9e91a20b0d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -81,7 +81,7 @@ sha512-vector: sha512.c =20 TESTS +=3D sha512-vector =20 -ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 run-gdbstub-sysregs: sysregs diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index ae8b3d7268..373db69648 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -64,6 +64,7 @@ run-test-mmap-%: test-mmap $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) =20 ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 run-gdbstub-sha1: sha1 @@ -87,6 +88,10 @@ run-gdbstub-thread-breakpoint: testthread --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \ hitting a breakpoint on non-main thread) =20 +else +run-gdbstub-%: + $(call skip-test, "gdbstub test $*", "no guest arch support") +endif else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg= /multiarch/system/Makefile.softmmu-target index 368b64d531..5f432c95f3 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -15,6 +15,7 @@ MULTIARCH_TEST_SRCS=3D$(wildcard $(MULTIARCH_SYSTEM_SRC)/= *.c) MULTIARCH_TESTS =3D $(patsubst $(MULTIARCH_SYSTEM_SRC)/%.c, %, $(MULTIARCH= _TEST_SRCS)) =20 ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 run-gdbstub-memory: memory @@ -26,7 +27,10 @@ run-gdbstub-memory: memory "-monitor none -display none -chardev file$(COMMA)path=3D$<.out$(COMMA)i= d=3Doutput $(QEMU_OPTS)" \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ softmmu gdbstub support) - +else +run-gdbstub-%: + $(call skip-test, "gdbstub test $*", "no guest arch support") +endif else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.tar= get index 72ad309b27..b7f576f983 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -51,7 +51,7 @@ $(Z15_TESTS): CFLAGS+=3D-march=3Dz15 -O2 TESTS+=3D$(Z15_TESTS) endif =20 -ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 run-gdbstub-signals-s390x: signals-s390x --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784730; cv=none; d=zohomail.com; s=zohoarc; b=LMv4xgYQuI8suowgwqb0W7RjjNl/QfJ+HMAp60m24lTQQPChJV1xvDSkcg/9oRF4XlRX1zhFIaFYsAcVHYzOxPQS79q8Iw3Z7/qXr2tF4Sj3ywHmM6sQk8tVc2aqJG6oP+bzKHyJtG9bN28/JGF7zClQn1qBDZjEK1BNXg5Rc98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784730; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UgR0BafSwr/xFk3Gul6hkEhAD3BiZ8Amj/PZ/fIFDYU=; b=K13gmZhEbQAoD3VGQipFXPdkP+NJFyT8QseO0KlTSYYIJtMuon7aEgZxX64Wl5UJ2hZ3Qa6LUBpeEZvGZoPT4TnNg3ChDOcBAqcWKaPsAxH2ek4WRrxLqYWKdEGA/VIhG3bQkEOoMb87dZ49hby70972o5xsuihAEiSdqFIk024= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784730823599.8410471408329; Thu, 2 Mar 2023 11:18:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoNs-0006fZ-8R; Thu, 02 Mar 2023 14:14:32 -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 1pXoNp-0006Z7-9a for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:29 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNi-0000jl-SP for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:29 -0500 Received: by mail-wr1-x42a.google.com with SMTP id bw19so112023wrb.13 for ; Thu, 02 Mar 2023 11:14:22 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o1-20020a5d4081000000b002c71a32394dsm143542wrp.64.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 5CD101FFC9; Thu, 2 Mar 2023 19:08:50 +0000 (GMT) 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=UgR0BafSwr/xFk3Gul6hkEhAD3BiZ8Amj/PZ/fIFDYU=; b=CbQ/ZT0faM9y0BcdM4/6VmBVQdaipLI9UP9B1iQ79Lp2b+xsIx29VqLhFJKFZc/Ulu I+vQa5AX5fafjTFgTneZVDSJ5fI7Mv0XUwKU/WMCQFPyCVNpVIxeHYK+FpKkNdOrnQCJ uVcxVJX/6MQWS83Nyl/ojLyZt9sOXLzhLqO1lFMWVoW89twlu7QaKfjMcr1m7GS5Quui +P2G7VxnpzNAM0J/Xd68joRFn24GaOhNZF6J94Pdy5qXeD0NRhMRPjwVhCX/jdFsdqbv 4VzjrZbgbd4Yk4Pu4pHHXIO9RIodrQHrRtJqsW1d0xGWt29KcgMUw1Eib5ZXMF2Ot+P6 oOrQ== 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=UgR0BafSwr/xFk3Gul6hkEhAD3BiZ8Amj/PZ/fIFDYU=; b=ZxIO4JDcuQOfNe63DC71MwiLTirla73t2gM+KzqxrrFSsNUAdOaQs6Q1X4XCIJMU6L 4YwJk7BL50cCi5TvmtGzuVZD8ShasNMDmz48ikHmom0JN8pVKdUqn+SvcljbFjWcJwBQ uVVkbcuh/MtPEiir8DnztoYgjjG+5l8+QskPzDMS25S9+xJ2lZoGF+K2H67eOXMuEddi e+KxEOdYyJofR4zV6iculfU5Hj5gL6ATBYTn0BelRCNrzE2ECtyOGpWprcsfPgrLaAID 6q45jJHH2x3gFQqc34BGCpSNOlD71mIQjtT9/GC36+fRUAXleTkLi61ww80D1NB2/yWi ftzQ== X-Gm-Message-State: AO0yUKW7aXIXhIGmiDKgo3KNFRTx0d8EHcdLSazNMJ7NuFCXekaAWgn3 hQ2Asidu7H1G99xrcIEUOtustg== X-Google-Smtp-Source: AK7set8XhP7Tb7WaUT2oF6JYru6UyUgQidrCsZH6AblGaUVm28R7DrOCkQhKIja81uQTjnsQfkgr4w== X-Received: by 2002:adf:e84b:0:b0:2c7:995f:3030 with SMTP id d11-20020adfe84b000000b002c7995f3030mr7906944wrn.60.1677784460723; Thu, 02 Mar 2023 11:14:20 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 24/26] include: split target_long definition from cpu-defs Date: Thu, 2 Mar 2023 19:08:44 +0000 Message-Id: <20230302190846.2593720-25-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784732200100003 While we will continue to include this via cpu-defs it is useful to be able to define this separately for 32 and 64 bit versions of an otherwise target independent compilation unit. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e --- v4 - update MAINTAINERS --- MAINTAINERS | 1 + include/exec/cpu-defs.h | 19 +---------------- include/exec/target_long.h | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 include/exec/target_long.h diff --git a/MAINTAINERS b/MAINTAINERS index 8d0113b8f9..3ef68cd0cf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -137,6 +137,7 @@ F: docs/devel/tcg* F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/tb-flush.h +F: include/exec/target_long.h F: include/exec/helper*.h F: include/sysemu/cpus.h F: include/sysemu/tcg.h diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index be920d4208..cd8aa177cc 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -55,24 +55,7 @@ # endif #endif =20 -#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) - -/* target_ulong is the type of a virtual address */ -#if TARGET_LONG_SIZE =3D=3D 4 -typedef int32_t target_long; -typedef uint32_t target_ulong; -#define TARGET_FMT_lx "%08x" -#define TARGET_FMT_ld "%d" -#define TARGET_FMT_lu "%u" -#elif TARGET_LONG_SIZE =3D=3D 8 -typedef int64_t target_long; -typedef uint64_t target_ulong; -#define TARGET_FMT_lx "%016" PRIx64 -#define TARGET_FMT_ld "%" PRId64 -#define TARGET_FMT_lu "%" PRIu64 -#else -#error TARGET_LONG_SIZE undefined -#endif +#include "exec/target_long.h" =20 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) =20 diff --git a/include/exec/target_long.h b/include/exec/target_long.h new file mode 100644 index 0000000000..93c9472971 --- /dev/null +++ b/include/exec/target_long.h @@ -0,0 +1,42 @@ +/* + * Target Long Definitions + * + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _TARGET_LONG_H_ +#define _TARGET_LONG_H_ + +/* + * Usually this should only be included via cpu-defs.h however for + * certain cases where we want to build only two versions of a binary + * object we can include directly. However the build-system must + * ensure TARGET_LONG_BITS is defined directly. + */ +#ifndef TARGET_LONG_BITS +#error TARGET_LONG_BITS not defined +#endif + +#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) + +/* target_ulong is the type of a virtual address */ +#if TARGET_LONG_SIZE =3D=3D 4 +typedef int32_t target_long; +typedef uint32_t target_ulong; +#define TARGET_FMT_lx "%08x" +#define TARGET_FMT_ld "%d" +#define TARGET_FMT_lu "%u" +#elif TARGET_LONG_SIZE =3D=3D 8 +typedef int64_t target_long; +typedef uint64_t target_ulong; +#define TARGET_FMT_lx "%016" PRIx64 +#define TARGET_FMT_ld "%" PRId64 +#define TARGET_FMT_lu "%" PRIu64 +#else +#error TARGET_LONG_SIZE undefined +#endif + +#endif /* _TARGET_LONG_H_ */ --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784685; cv=none; d=zohomail.com; s=zohoarc; b=M78GWp6UWA4hUGDwkFq3i53aCbfxSWKXJ9sgiErF63SQsbbASZieqhs37afNL43KDeCT1yG94K/jAE1qjbZDtn3EO/+2juKLvxr+wrPsZMrcmp993gFahItsd4kL9vp40b79OyK1xLAieJj94tPqWsEmzZ63/uyaAcYEX6gkmKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784685; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KZ1bzurdoC+jowRyfZk2dA2rPNkKxibvGc1imFmhxks=; b=I97efHD88RkYQpl/4fx+bAbBxCrrQEIDO0ofk5vaYxRqb0Y9FXPjtbb61l0XqNRHUAc59Yw/zt9I/ZQYuIdj3IzQZkCKe06rJk0i/K3ewQjBWUWaEi8llnuImSjsrXubA2tuzZoseTnLmHTUAjYh2uistbjeIry3OkZFkIc8Mok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784685156733.084644140739; Thu, 2 Mar 2023 11:18:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoNy-00072T-Iw; Thu, 02 Mar 2023 14:14:38 -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 1pXoNv-0006qj-Js for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:35 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoNo-0000nR-Cw for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:14:35 -0500 Received: by mail-wr1-x42b.google.com with SMTP id bx12so122286wrb.11 for ; Thu, 02 Mar 2023 11:14:25 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h18-20020a5d4312000000b002c7107ce17fsm186010wrq.3.2023.03.02.11.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:14:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 80B491FFCA; Thu, 2 Mar 2023 19:08:50 +0000 (GMT) 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=KZ1bzurdoC+jowRyfZk2dA2rPNkKxibvGc1imFmhxks=; b=iiyS5GMcA7ksWgSh+I6plVtuEIoHFQ45VTTszckDYqHLaDajTxYx/sX1Rvfxhy69YG SAVS4/Kz4ggxsyxJuBu++OU6bnNYPQoDGeGVxXu2dawFC0KpWt+2gKdMb2NPmYiTvTPI 5xzWhVn/ZdC2waLe67u6QYICfXz6YMZ8mROwKmFfyLoFWNUQCXW23788s8mmgoXev51L iMKsdeZ6qGP720vAIx/P4B68YxCvgvkt/FQFG+4GLunKZ2frwmsInKsVWeKuHYl8nHSp WvtdfztrP6FJf1hEjmFfV1J9gjnqmATd9f45fdlo4h01KmX/aQS+uSWvpAJ/Dj+7Y4Pg lvVw== 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=KZ1bzurdoC+jowRyfZk2dA2rPNkKxibvGc1imFmhxks=; b=UzVI14yDOeXJkZUIAQm1+4KrWVdl3KE+P5yFA+gmu98OUjG0vd8yDcVbxHgvJElHa6 PG94I2KlqY9yBIewqGi4Yw70CuFAEhN7Gky2yptBaEE+6zrZw3escrL552WpHJpq6m04 fORYTB6pqBM/HGScI7mov9uwlC12d98MUQ3wmjuHcF6D+FnutFzvbDRI87tWVmPSU0pA EnjiUivk7zSVFHNzNG0VdRE1c3KF/noeXXAtNXlbI0udzrvdn/o30YJnoL2JkDKdlkey Dnw0Z7XNk5YBcITRzVPBCbOv3cauY21p8bMFgwAZ25z5drgxrcc0AkmPDUApSvBwlDMo GUgA== X-Gm-Message-State: AO0yUKXL7RmP0As1VKpoDLn6VH18Nkt/svqh5R7ZODfMHkJX9vVMSHoC r/cL1Newg0S25007aPfRiOt3EA== X-Google-Smtp-Source: AK7set9DSU6r1TNemmP4mTn0dJ3ZetGzBqAQsEAxD7m0DxYYbeyuBlVmdAoq0rTaYFCFGc1P0pdZrQ== X-Received: by 2002:adf:ef0c:0:b0:2c7:d56:777b with SMTP id e12-20020adfef0c000000b002c70d56777bmr8047214wro.64.1677784464789; Thu, 02 Mar 2023 11:14:24 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= Subject: [PATCH v4 25/26] gdbstub: split out softmmu/user specifics for syscall handling Date: Thu, 2 Mar 2023 19:08:45 +0000 Message-Id: <20230302190846.2593720-26-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784685950100001 Most of the syscall code is config agnostic aside from the size of target_ulong. In preparation for the next patch move the final bits of specialisation into the appropriate user and softmmu helpers. Signed-off-by: Alex Benn=C3=A9e --- v4 - checkpatch cleanups --- gdbstub/internals.h | 5 +++++ gdbstub/softmmu.c | 24 ++++++++++++++++++++++++ gdbstub/syscalls.c | 35 +++++++++++------------------------ gdbstub/user.c | 24 ++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 8db61f7fb4..65d75d9435 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -195,6 +195,11 @@ bool gdb_handled_syscall(void); void gdb_disable_syscalls(void); void gdb_syscall_reset(void); =20 +/* user/softmmu specific signal handling */ +void gdb_pre_syscall_handling(void); +bool gdb_send_syscall_now(void); +void gdb_post_syscall_handling(void); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index d3152fb6e7..02f3b41095 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -103,6 +103,30 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent e= vent) } } =20 +/* + * In softmmu mode we stop the VM and wait to send the syscall packet + * until notification that the CPU has stopped. This must be done + * because if the packet is sent now the reply from the syscall + * request could be received while the CPU is still in the running + * state, which can cause packets to be dropped and state transition + * 'T' packets to be sent while the syscall is still being processed. + */ + +void gdb_pre_syscall_handling(void) +{ + vm_stop(RUN_STATE_DEBUG); +} + +bool gdb_send_syscall_now(void) +{ + return false; +} + +void gdb_post_syscall_handling(void) +{ + qemu_cpu_kick(gdbserver_state.c_cpu); +} + static void gdb_vm_state_change(void *opaque, bool running, RunState state) { CPUState *cpu =3D gdbserver_state.c_cpu; diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index f15b210958..1ca3d81305 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -104,9 +104,10 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const= char *fmt, va_list va) } =20 gdbserver_syscall_state.current_syscall_cb =3D cb; -#ifndef CONFIG_USER_ONLY - vm_stop(RUN_STATE_DEBUG); -#endif + + /* user/softmmu specific handling */ + gdb_pre_syscall_handling(); + p =3D &gdbserver_syscall_state.syscall_buf[0]; p_end =3D &gdbserver_syscall_state.syscall_buf[sizeof(gdbserver_syscal= l_state.syscall_buf)]; *(p++) =3D 'F'; @@ -141,27 +142,13 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, cons= t char *fmt, va_list va) } } *p =3D 0; -#ifdef CONFIG_USER_ONLY - gdb_put_packet(gdbserver_syscall_state.syscall_buf); - /* - * Return control to gdb for it to process the syscall request. - * Since the protocol requires that gdb hands control back to us - * using a "here are the results" F packet, we don't need to check - * gdb_handlesig's return value (which is the signal to deliver if - * execution was resumed via a continue packet). - */ - gdb_handlesig(gdbserver_state.c_cpu, 0); -#else - /* - * In this case wait to send the syscall packet until notification that - * the CPU has stopped. This must be done because if the packet is se= nt - * now the reply from the syscall request could be received while the = CPU - * is still in the running state, which can cause packets to be dropped - * and state transition 'T' packets to be sent while the syscall is st= ill - * being processed. - */ - qemu_cpu_kick(gdbserver_state.c_cpu); -#endif + + if (gdb_send_syscall_now()) { /* true only for *-user */ + gdb_put_packet(gdbserver_syscall_state.syscall_buf); + } + + /* user/softmmu specific handling */ + gdb_post_syscall_handling(); } =20 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) diff --git a/gdbstub/user.c b/gdbstub/user.c index 3da410e221..583cc83898 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -472,3 +472,27 @@ void gdb_breakpoint_remove_all(CPUState *cs) { cpu_breakpoint_remove_all(cs, BP_GDB); } + +/* + * For user-mode syscall support we send the system call immediately + * and then return control to gdb for it to process the syscall request. + * Since the protocol requires that gdb hands control back to us + * using a "here are the results" F packet, we don't need to check + * gdb_handlesig's return value (which is the signal to deliver if + * execution was resumed via a continue packet). + */ + +void gdb_pre_syscall_handling(void) +{ + return; +} + +bool gdb_send_syscall_now(void) +{ + return true; +} + +void gdb_post_syscall_handling(void) +{ + gdb_handlesig(gdbserver_state.c_cpu, 0); +} --=20 2.39.2 From nobody Mon May 6 03:32:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677784377; cv=none; d=zohomail.com; s=zohoarc; b=N+rguiCSyCNJ5tLL1vdaprJcR6M+nOU82FUJu/fB+L8zz1dGFWvM4dIt18ByRmm/ElD8TmyNhp0Q13fTIXkh/Q+auj/uiIrSQCFX9rYckP41KV5B3A7b77YpymbD5lf8lb/Trck6em5h1uIW9+KZmzAiWY1pchUabI1vD3bPuQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677784377; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MqZnXo7hFBLHq1osD92qYOTfq2ZgDdz/ouY2s2JD3s4=; b=ly7k5wM/X/Hm1ORCJL4Icnm+8JBPToeNPwXac2BxWvPd4THwn3GZOzZianS6BQI3nOXvy+U2Wzyy9y9KOGcAkr/JC5iTCxrDKlGbBy/h4rDfmTGjN0I/RPD+HLmAaKh43URenpIpnkWMibFIRXRsxwQCDeRrmD6aZ18erbBPEz0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677784377331148.5419971393785; Thu, 2 Mar 2023 11:12:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXoIp-0007nc-LH; Thu, 02 Mar 2023 14:09:19 -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 1pXoIn-0007fW-EV for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:17 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIR-0004Zq-Df for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:17 -0500 Received: by mail-wr1-x42d.google.com with SMTP id v16so191333wrn.0 for ; Thu, 02 Mar 2023 11:08:54 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a12-20020a056000100c00b002c55ec7f661sm190603wrx.5.2023.03.02.11.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:53 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A063E1FFD0; Thu, 2 Mar 2023 19:08:50 +0000 (GMT) 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=MqZnXo7hFBLHq1osD92qYOTfq2ZgDdz/ouY2s2JD3s4=; b=fOR2byWfCCcJXjXfwKA46URGir/fGPkWaGXjvyaUgzbeHfEdk+5+rMh8/ZWbZSyatP 0ODUvIcB0kpuSPwdT3VpN7Y/ItmmWXOXCM5GYBnwogvyhtzfBfT2ic/U2IM2PdcKBh7z FpZX2SmOXyLbWDtzIvURSf4W6ozOFlGlY/kSvWiM6O55YwbaV3bUmgz2ELDtEF7+potP OoOfd0ldZcJX+A3T6bBMS+IiGWAdhZiESkj/pAan4toAgMNH0Ef53jFKN6q/JGeNehmg JYwd3xCpfUEcOtPXnEGJSkg9XyrjsnyXjhEpvqMhUYswkJU7P1n80aZDHT+ssIlZcFXl OPLQ== 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=MqZnXo7hFBLHq1osD92qYOTfq2ZgDdz/ouY2s2JD3s4=; b=lYIlcfMz4r7nWkYW//0mFgKvfrX2JMBf+MBPpWOzdC6P+03+O1aPW3LI2ZQQi0agVL +TdIwGhhcuWjdVcMz/7ucieK/0QsDh4zE4KgRC0V9wWK2IsgiQcQG85zOew2yKhjR1o3 AlrW6R0XfyPvNWZeSbO/A08kXVWVSlCIFYZnqf9ZdsYkmLGgx0sI7S7uN57ChdvyU65d pKmYtLqfS08O0vobl9b9VkXbn/WdwUtaopUQ1wmBaieSFwIWgH5xG5ExoRY3NKiAZdmM GEsCCIm85ogcsKdEcoEq+qLrRiqhX2SZNEotPn1gjJFhUajAz23iP3Sd78WudBaXujN3 ZEPQ== X-Gm-Message-State: AO0yUKWOvWlHI2SuLrjUt0iTsHFRnP8QomVAX3cSut8rvnuMYjHBk300 QwVokexjSIh34bb6mgZ6byBUmg== X-Google-Smtp-Source: AK7set/GbLEkr34A33zpv5kh6AkqolZvhydftjLJJ27qgEGaUEAiZ0H0oRqb4S9ufCLxgSPqV3tmtg== X-Received: by 2002:a05:6000:c8:b0:2c3:e0a0:93f with SMTP id q8-20020a05600000c800b002c3e0a0093fmr8547360wrx.8.1677784133847; Thu, 02 Mar 2023 11:08:53 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , 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=20Mathieu-Daud=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=20Benn=C3=A9e?= , Mads Ynddal Subject: [PATCH v4 26/26] gdbstub: move update guest debug to accel ops Date: Thu, 2 Mar 2023 19:08:46 +0000 Message-Id: <20230302190846.2593720-27-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677784379109100003 From: Mads Ynddal Continuing the refactor of a48e7d9e52 (gdbstub: move guest debug support check to ops) by removing hardcoded kvm_enabled() from generic cpu.c code, and replace it with a property of AccelOpsClass. Signed-off-by: Mads Ynddal Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230207131721.49233-1-mads@ynddal.dk> [AJB: add ifdef around update_guest_debug_ops, fix brace] Signed-off-by: Alex Benn=C3=A9e --- include/sysemu/accel-ops.h | 1 + accel/kvm/kvm-accel-ops.c | 8 ++++++++ cpu.c | 11 ++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 30690c71bd..3c1fab4b1e 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -48,6 +48,7 @@ struct AccelOpsClass { =20 /* gdbstub hooks */ bool (*supports_guest_debug)(void); + int (*update_guest_debug)(CPUState *cpu); int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr le= n); int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr le= n); void (*remove_all_breakpoints)(CPUState *cpu); diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index fbf4fe3497..457eafa380 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -86,6 +86,13 @@ static bool kvm_cpus_are_resettable(void) return !kvm_enabled() || kvm_cpu_check_are_resettable(); } =20 +#ifdef KVM_CAP_SET_GUEST_DEBUG +static int kvm_update_guest_debug_ops(CPUState *cpu) +{ + return kvm_update_guest_debug(cpu, 0); +} +#endif + static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops =3D ACCEL_OPS_CLASS(oc); @@ -99,6 +106,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, vo= id *data) ops->synchronize_pre_loadvm =3D kvm_cpu_synchronize_pre_loadvm; =20 #ifdef KVM_CAP_SET_GUEST_DEBUG + ops->update_guest_debug =3D kvm_update_guest_debug_ops; ops->supports_guest_debug =3D kvm_supports_guest_debug; ops->insert_breakpoint =3D kvm_insert_breakpoint; ops->remove_breakpoint =3D kvm_remove_breakpoint; diff --git a/cpu.c b/cpu.c index e6abc6c76c..567b23af46 100644 --- a/cpu.c +++ b/cpu.c @@ -31,8 +31,8 @@ #include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" #endif +#include "sysemu/cpus.h" #include "sysemu/tcg.h" -#include "sysemu/kvm.h" #include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" @@ -326,9 +326,14 @@ void cpu_single_step(CPUState *cpu, int enabled) { if (cpu->singlestep_enabled !=3D enabled) { cpu->singlestep_enabled =3D enabled; - if (kvm_enabled()) { - kvm_update_guest_debug(cpu, 0); + +#if !defined(CONFIG_USER_ONLY) + const AccelOpsClass *ops =3D cpus_get_accel(); + if (ops->update_guest_debug) { + ops->update_guest_debug(cpu); } +#endif + trace_breakpoint_singlestep(cpu->cpu_index, enabled); } } --=20 2.39.2