From nobody Mon May 20 01:44:46 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=1677812323; cv=none; d=zohomail.com; s=zohoarc; b=f/hr05g93F6oOjX1iN/qENEUmHjW7tZc8yWc5lay9/aSyg2pJv4JVSkpL7ieLwAWH/lCpt6yMz3gDp8+xaI00EHyv2kzwimPA2VRGLXhIB47PIVSJ5l0QQ8sLOvnAyB9ZTut0VvFilyjgP8VWmiwvafYaKulk1hk7urgnr0b8cM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812323; 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=TEtYCrcrznZmhowtmX9YimePEBwlx4D0eZxGxnMge0Q=; b=dD2XxHV01u9V6Z6EdBMGExD61u/LPiQOOo66l3Au8aVjbufT64VZNNhaUJxzD0ymIUQ3P79EYbAtmrFXH67ltRX3CbFLJNj3hgUf/o4vuaYNM/UcWMCzOisdrJXbqhK8eylb0CK+UUAhuHjkI2e7iFqUgmr2WgbcC2wFZ8LdJ3w= 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 1677812323012744.68905602249; Thu, 2 Mar 2023 18:58:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcg-0007Qv-Nr; Thu, 02 Mar 2023 21:58:18 -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 1pXvcZ-0007P9-Iq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:11 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcY-0001lc-2t for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:11 -0500 Received: by mail-pj1-x102c.google.com with SMTP id l1so1173378pjt.2 for ; Thu, 02 Mar 2023 18:58:09 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812288; 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=TEtYCrcrznZmhowtmX9YimePEBwlx4D0eZxGxnMge0Q=; b=laxhOAuFtXBcu0sBUJuq2dfEL2+Obz/NrMQk961r+Lee8PZj0qEv0vI/gqs45oQckg d3z2b4e/TbNXtGh4/N9ZNnpAr5KviD5crFxNX4l04WYVYM0Ko0NbGtBi864/TRgMbnCW FpX/3yO7qEr6Qn56szPTPaGV3yhefCe7pI53eCJ+LVm4ewTgnNc3Mfawp4XekAXMVABR kZ3MBQVcoWzNEsS5i1QuU97oeDarjSlivtyUuVe4i2W3895wuWBZEQC3urt3a/RHmlGh bDUrTt6NDIpNLItQs0tRiKbvSkGZ14byQ4oFuEQLOoisqfVadGaQwlCsVdNFRxu/19aZ 4Sog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812288; 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=TEtYCrcrznZmhowtmX9YimePEBwlx4D0eZxGxnMge0Q=; b=vtum7JNweegHi70FYMCoUwh67xO5XOMK6PYmKO8B7Cphb+S9moOq/BBejQrpnJapLg 7gmD5IvLcWeKbK5L+Un4ar4q7uP7R/nY6UyZ8UfY91yaDAc3d2HhZeZwYsZwNJk41XRg r7vQHWFyCKcWsjYF3+iqPSuMhqBUYtLA1hdtb5pBAt4olDA94o0TsMBZL+aOiQbEmWp2 Oef6MA4pqDDhMTfCYaZVeiBn9ozdY1eGAgB3z3rcyWPZGWSY8nUeHtxBEYr2HRUFXj/7 Vgl95ukvwjZ0MYE1Shn5XaKQeZD+ssZSsvcHIHbxvd3d5eWY9EhEHUg9iSZ9GJEy1QhX Ys5Q== X-Gm-Message-State: AO0yUKWVmXbcfnVNtwu/di2/cxVy3D+CxKidc2zHj8wDgmJkf/jgK564 Dkj1Qiv8V7L7hwF8IcrhYKAcaDEyBsMsQL4tDsM= X-Google-Smtp-Source: AK7set9QQ+ofmEVOCEPBvLwMPz0YLU3amDxVytiaTUZP4Ib3pz5dSpKOJKvr5YUQ5Xu/JqnG7X++Fg== X-Received: by 2002:a17:903:228b:b0:19c:bae2:681a with SMTP id b11-20020a170903228b00b0019cbae2681amr448690plh.66.1677812288352; Thu, 02 Mar 2023 18:58:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Bin Meng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 01/29] gdbstub/internals.h: clean up include guard Date: Thu, 2 Mar 2023 18:57:37 -0800 Message-Id: <20230303025805.625589-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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: 1677812324165100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-2-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812434; cv=none; d=zohomail.com; s=zohoarc; b=ZDYPYkjhIWezwgscjxGsCdIUhRqoc/ZUKNjvK05uqygVuxSj7vyX2yLktbsqJPmg6EVEgchxN7L+sWhMSNfKjtxWf2qYk/nt9QeLXM1WAslA03auZ7vKpjXvxOUqVASRd1dL9dJidq0zMabodwPYTnHe4FfYlD69r6my0t6/96g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812434; 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=d4wGdJDq5Z3S9B978lEtV+HF+zdV67+9n1J0Csb0VjI=; b=iHjFWWV9gVSJ1RzZKDnVlQwva/S36aY9of1Wcf/Mkl5hg+hBainaASolqjiwdHE5QU0biqDkGg4fvIRgHo2DR/M0XLk3rIs22H4F8F5JTmtCnsC6ljFJt/5uZE5mxcWM+Zy2C3hDUnNpooT7QdgZaA5wBoJ2KkN7SHiQzb8xkAQ= 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 1677812434195171.78861323160413; Thu, 2 Mar 2023 19:00:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvch-0007Rr-Rr; Thu, 02 Mar 2023 21:58: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 1pXvcb-0007Pc-FB for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcZ-0001mZ-Vz for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: by mail-pj1-x102b.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851459pjh.0 for ; Thu, 02 Mar 2023 18:58:11 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812289; 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=d4wGdJDq5Z3S9B978lEtV+HF+zdV67+9n1J0Csb0VjI=; b=o7QGBGw1fd+TnjQWqbJR6B/4Dd9rjnnS/qRyFuN1FgRjAY+cVWVtYfj7edzy92ro7v 3VvREFo3nWDg6tii5xNeN/elmpsr6D00O+GZcuUbBLT/Ap3gkt09mVrgIKHKI3X19yAw S7UwrL1RLgZlWFseMRBEq1msZd9f/RSt4OvXXXdq56hwPLoyKSuAcav5RHXqjl7+k8T4 OHsVMyxsLW4pDn+lv9PbW60oowUHHFvjdLvGgCOi/YeMq1ck98N+VG31q4FjyEnQpW8w WTDA0SHO0q0VehV44fXZsnoUdxNVg57nx9GE63D/upzKrACNvQP5KIZYt01LR9WghjRp ui7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812289; 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=d4wGdJDq5Z3S9B978lEtV+HF+zdV67+9n1J0Csb0VjI=; b=hKikqd95CqrelHTqeebXXKBxU0tTdU4akX+WQr7aiyl03qSg4Og3zh2DpDqrvgQC6R QndeiTX3Z4dF3+wNZxZ9JHi9FRw4+vrK8vgxjz6adsJJxLi3YnSnlIbUJrrSKbdeqizM cgSZkrF9hs/yLUKN5B2xfR6H9lJ/wjTSs4oJR/Xn4f5muVUAP3EGETH4GQEDp5JhSPq2 +xamHBxLX0cLAZ4ipsOTLhqy3Zc5R3U+A+XEp0rH+s+AhOmiJztgKGwrVcYfq20TTn3B c8rlddGLq9f3MDtsYGRkcX1ctZItHmDun98io1puHoMrlGOFUxMXqOHb+87jEqc7kdfm 1CnA== X-Gm-Message-State: AO0yUKXPp5nGHm49y4fmnu3JCsG6puKM1WPadNZzlY5Jwvp/x7e5bcxf N/CHt9beT+4vH7YmJcn1xInOu/WvmVuqbXLt/Wg= X-Google-Smtp-Source: AK7set+ee/rLw5sSnSiu80tIM2EHoieJCFdBh54fT04GVCoPSFexs2HUAiXDksvdWdJVSIIMagahTQ== X-Received: by 2002:a17:903:283:b0:19c:d309:4612 with SMTP id j3-20020a170903028300b0019cd3094612mr655758plr.6.1677812289333; Thu, 02 Mar 2023 18:58:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 02/29] gdbstub: fix-up copyright and license files Date: Thu, 2 Mar 2023 18:57:38 -0800 Message-Id: <20230303025805.625589-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 1677812434850100007 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-3-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812558; cv=none; d=zohomail.com; s=zohoarc; b=FbNRaX62SXn4qP0CnE0WGhwXVngjNy9Z8o5+vWzzME65aIgFgyqF3hX4aPs4MBj6ZGbJ7vOtF57CZ2s6KJEpoO3GabQcaeIhpc7KssQwpit5VWpvdppAyuU7tiMRaRa1uucQMEl9cnbWb+Wtnf/UzceaA0mV1twxBhwl3P6WYLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812558; 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=OEtCGKXwc5R5woyG/cv3/9an/+vnS/RcluuE2Zr/HR4=; b=OQsgqcxpsat2hMRaAeRdqYcD7B1BXf2W1FqFqs2Dar4aawKDwW27CRg8WNHfMH3reKI/FafQcOie/H49xaj5YKn1BDa9E0TnK6RV0x7XybQb8wedrrrl5PdZUQO8Safa5bYOnmy0y6zP0wHTtSBTLztPNzoUB8nHoA9oWCSGcF4= 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 1677812558440451.6438093131894; Thu, 2 Mar 2023 19:02:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvco-0007VU-14; Thu, 02 Mar 2023 21:58:26 -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 1pXvcb-0007Pd-KC for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcZ-0001o8-Vq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: by mail-pl1-x62a.google.com with SMTP id i10so1322252plr.9 for ; Thu, 02 Mar 2023 18:58:11 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812290; 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=OEtCGKXwc5R5woyG/cv3/9an/+vnS/RcluuE2Zr/HR4=; b=ma6jETDKNQbGFVQe7d9Ly+86QJKjlO8SZVCIATBQ96evOAQsbbseHBXbj+L4gD0Zey secRSGC7JhPGlHaW4TtbBiz3UZJZirGYRdwYY+p65AHQ1a+BYG3ry3CsG0FHNEOpErp6 BMsjoToi24PE1CLzTrxaS5+rlTt/aKgqOExwcE06/n0IZAmva8+4Zoc5MFkAEWACPnGy WmBXuGxBwAijCOzBK6hTNEQHQQ1Jtp0d3/MIAYGjz5cDkA5YKXScvRBhySVnwPFz6/yE Qz1AxzEfRhH5kWXDM6xM7VM5rtZfzQT4PxVrNnYOwS6Q5ESD9f+TwqskBkBgPe4q1mRR qM3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812290; 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=OEtCGKXwc5R5woyG/cv3/9an/+vnS/RcluuE2Zr/HR4=; b=FfV5V+woj1SyIjZlH0wX1srJs1W+gF/Mn8tY6/SMXB4u5qjQ4X4ZKkMS9GF63biDz+ Fy6qtzY20nXLxGKDa2GjSix6JWSp5JUP+6Bun3UX2GZZoOc4hNl6y/4MGg4TgJR1Ozfm +wxKyxZO/3aLxki19cut4M/0Wrg8KJJK5Xtff0G/CxGPHh7SPekCw5GepcoHX0T2qWxL VuV4q4A4Aa21RVy75bHg9tT8K7rPiLNbP8iVTMFHpWhF+cGt5b47fE3vRSPmxGemuXsZ 4huaA/JVE6iG9N9L63dBNMF6r1WMnFvm5qiQ0byxVRwHqEzIStpsIuiwqWQafXQNlXRD yVAQ== X-Gm-Message-State: AO0yUKWtlVrf2gzaI0FbOoPj1cUXIuE8g0if0maV13abIGoUssehbQHk vDGV0YY1CHCzxZCeBRtinc24TjqVaMhTVEgPuxw= X-Google-Smtp-Source: AK7set8Bei/bq/MsqIq7qbHiieTU65RK+BvubYCyuQ6xhW2GANWJTXAwIMhQWkr8Qwjotialmw3PoA== X-Received: by 2002:a17:903:11c3:b0:19e:6657:2c21 with SMTP id q3-20020a17090311c300b0019e66572c21mr516711plh.7.1677812290351; Thu, 02 Mar 2023 18:58:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 03/29] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs Date: Thu, 2 Mar 2023 18:57:39 -0800 Message-Id: <20230303025805.625589-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1677812559751100003 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 Message-Id: <20230302190846.2593720-4-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812432; cv=none; d=zohomail.com; s=zohoarc; b=SdtaVWPuj+DjxffoInD+H2ouzQi+8IiM2XOMqGyxVbp39kvspZCaX+VBWhKELyIWcuUMhknFmtgE8oa6SZUQYMWN7z/jtj9EOz3gElySh57WO+tSV9i0wnHNnz9nvGzvdysI4B56KhupQlIJmXmYl8zmElsSxQtY7HXOlR3ZiQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812432; 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=vbTFZ1f//WCKqJl3a99CsWy+g64MYDHqVH/YBzELWfQ=; b=Opn/RznWji9MMHMeJPKNQnwgrPZ463cgAGtMT9ohImjyfJSmJdcwyJcxtL8MVfVPPsF8kD0giDwu1numBp0S3OLPTn9isXRHee7XenQgnoG+6LuGxGvnTL+qZaahvZeUtufN5RH/KIBXjnF7FQxhAqM4lQSQL4l+7zNCihpZXjE= 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 1677812432906865.3078021010324; Thu, 2 Mar 2023 19:00:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcn-0007VL-Iw; Thu, 02 Mar 2023 21:58:25 -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 1pXvce-0007QL-Iu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:17 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvca-0001oU-Qu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:14 -0500 Received: by mail-pj1-x102d.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851499pjh.0 for ; Thu, 02 Mar 2023 18:58:12 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812291; 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=vbTFZ1f//WCKqJl3a99CsWy+g64MYDHqVH/YBzELWfQ=; b=PdQhN+5WzOLuvf9oh8UeVRam1saPkfblLm1VMWgrwjxS/M8iEYkEcNHkvXnguipXtn +4EJkwyxPCsL1BTwrH+5i0XeSPAwxx1Ii55QYn/P4d29SGhOy1PVm+CbggSGZpHVsE8N CrE8q7ofNAAZwiZxx+E2sGX+zqWEX7JpdXWz8Dfv7tbCvgSxnxLmgjE7VHyxI4rvJpnS 5XjqV0VUqyBfaoLuMZOc5TtW5FylxiE6+2Ztn9XMxGuSOp98ZAvgXhwDEVhOcnTn5h8F v1pjo27tqzB95TCXl5XEcLu9EFfP89dMRWdh4NMKU1vqOFqF2yjqVkOTSNOkIrpYgiuw Jorw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812291; 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=vbTFZ1f//WCKqJl3a99CsWy+g64MYDHqVH/YBzELWfQ=; b=mzocMwjyN6JiIEiKIFVZPp0REzGVDGus9kSbRo+A78eJgyM9PchlQLxN671PdGlh/L NGrv0L8IuzkUzvVsruzD1TbfNJI/FBMY0C/+d3nEfksOl0+zuyw0KrLX4GkpEEpkrLY9 XqmGUNdoQuiu5r7aLzii2rw9r5d1H9rq07I+3ZDQ/7dp+USfm+hZ3A7LEwesfclNKPDd CFvx0s9j057wDR0Fl2rqhzI8EuzTYWOZSiKgscJAoAYH8RryBGnAyK5XT00LHiSVEzk+ thpNAiE2fO31Optzv3OcEAJcLL3uI9MYJ96nV/5iJHkGhGJ4Hub1qOD38hto6llqlYmo sTqw== X-Gm-Message-State: AO0yUKVFqU9zWwpeSIkdnkw7EQMXHOAlbDyw1tPRHT7sqlKnkmZb/pMl 9cCFKLiQqVqkd//SXfQPd1LbKOSCHLAY4CJ4hq4= X-Google-Smtp-Source: AK7set+ADXOFQAsm3gMWqAT3/3d0ZKVYZ72mgyfcnF3dFV9kdcjP9CljLnMbtuvLzlQHfYik9pGPbA== X-Received: by 2002:a17:903:22ce:b0:19d:90f:6c6c with SMTP id y14-20020a17090322ce00b0019d090f6c6cmr698619plg.17.1677812291174; Thu, 02 Mar 2023 18:58:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 04/29] gdbstub: clean-up indent on gdb_exit Date: Thu, 2 Mar 2023 18:57:40 -0800 Message-Id: <20230303025805.625589-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: 1677812434852100008 From: Alex Benn=C3=A9e 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: Richard Henderson Message-Id: <20230302190846.2593720-5-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812348; cv=none; d=zohomail.com; s=zohoarc; b=I2M0e8lrk5jPzuP0xX+Iwbc4FbIrq7uA2kRISX7PH3F6DZOVbIEMZ0+2obHCQeTJz/TnYUO5805eK+xF3OpuFE62Cl75gpu4oIlRq0j1UZOmtOoW+Zrmacjd0ndxMTBd0LrP/WBxi7cZCcI5JQ1UK6Zs2BX+38zvIX//M04s2d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812348; 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=4pRbYqRY0VGEczpozM4adTEzmEIYOjfBRmRXe4bR2kk=; b=X4TngQADnegn9evXFXVgrDtYswv493Q2uPv8U1OKbjXamfQ0IDg2qVKRvla8gsZ7qHsybUPx0GvTJBoQRZNXZZvHGAFpRpBlC9kM+Hb2ApLw6siEgwwODUM1mUWObu28+eNdLQaMA5f5UaN2+MnAFC6bLZHhAN63y87Ol3knj4I= 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 1677812348828261.4699107683332; Thu, 2 Mar 2023 18:59:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvci-0007S5-HA; Thu, 02 Mar 2023 21:58:20 -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 1pXvce-0007QM-It for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:17 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcb-0001oX-GX for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:15 -0500 Received: by mail-pj1-x1029.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so4666977pjn.1 for ; Thu, 02 Mar 2023 18:58:13 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812292; 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=4pRbYqRY0VGEczpozM4adTEzmEIYOjfBRmRXe4bR2kk=; b=Lj5VwkC/JiuoekgfDDEN6rCbPaZzybHf4YEMCtoVZyd3aHa2sJp40EwJesaX/t7sno ErQ3TXBmoN71VPiIHWmTqomf3jFXgz2lnXwc1vX2cFMgYirSKfMk06GaKD9zYCN1gS2l R8ZDI44gQOfbHYQmUDmDLvGZZy2P6zMCZZQKvovod+IRujRtNNlxfnd5Nd6YP32AgiQc 3jhLLl7GlcT5BlFHR60B9WTkYx/+KgZszjqtbYHxAUyqA2rUpBHY4eC/oggJ8+LtKGCQ eRxz5wm50d/iJNNPmheco6OFIL+To8t+e6VPENh3zatklKVNWiXB8GUnvZuLOPhhhYbG U0Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812292; 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=4pRbYqRY0VGEczpozM4adTEzmEIYOjfBRmRXe4bR2kk=; b=eEmPPGDif4aJsyXInyeldC1O+XkJkW1zNdLLv3DsoOvMk2xlr4hBUBK6YMB4oNPemR px8K6OgTyekkPPaceELYqiZwNBfhQELdrx4pTt26RB8K31ikNMQs9BpWKTflQYoB0dWc owPIVQiZMZhp9qvwAwruxgUmg7kE62O3xF8mxiaMUHkHwfoFWgpUj10HQrJoldF2ARxd 5ydMsAF4oBwbGsf3OpM6Yav086ybkIDqxJl3X0Eh6ZLrHsXbWgGDUcvYbx8QmMJDZODE 8qO1H6IfaiwX36bfbZsEmdY2QMyvPZYz6In/+0ezVwINni5v3oKm1qnbZcNsey+m+vWq I7pA== X-Gm-Message-State: AO0yUKVRmuTN8R+zriHtWW2qt5UPLHZ7wG/01TTNoLWF5TOXuUFzdQ+5 1TaPoGYhxErJV9irGXkReLMOZOKKBBij4sAAWQQ= X-Google-Smtp-Source: AK7set/C8zoCb31ByGj4HtmKWO+hV02r5eCUJ9b+25j7Mf0JZbxmtPFV4kKIe1aB3TrO4CRYYho/9w== X-Received: by 2002:a17:902:bc42:b0:19c:faaf:b9d6 with SMTP id t2-20020a170902bc4200b0019cfaafb9d6mr499760plz.8.1677812291901; Thu, 02 Mar 2023 18:58:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 05/29] gdbstub: define separate user/system structures Date: Thu, 2 Mar 2023 18:57:41 -0800 Message-Id: <20230303025805.625589-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: 1677812350257100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-6-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812344; cv=none; d=zohomail.com; s=zohoarc; b=Us01jB2xGgkq58/F3TZXZZ03zRmWqFIU108jNKBHmWBcthCi/lDGVIMxaosrjheNnTrYuE076IGOFMOSdc6vnqjlMneuhL8EJ2v/Lfg4pjQaBKutxh2yGn057PQ+vpY+UDl5UB1EKmrzKJoCqlbO0GEh9pcu7lNZ8uphBOlTF5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812344; 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=afKJl9J8dwmJwl5uT+DP4MXGN3pCqi29VExi2VZVhL8=; b=T+x354ypGXHFJMp7oJkwU9no5r52uRbi4k5t43UaVh/tMIyw3UrUtR/tWg2vwMcScABLpu4K1RpqhWaWyc7d+JIDf6OIM0PssO1n2P67SuMPAvV1FtDpTd/RNYf8WWZcDh9aGmJcKVz/Ck+NPLghQ7muTaNEkmfDl4FlNpwTotQ= 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 1677812344279468.96671422064696; Thu, 2 Mar 2023 18:59:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvci-0007Sd-TY; Thu, 02 Mar 2023 21:58:20 -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 1pXvcg-0007Qa-1F for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:18 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcd-0001od-VT for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:17 -0500 Received: by mail-pl1-x62a.google.com with SMTP id a9so1308359plh.11 for ; Thu, 02 Mar 2023 18:58:13 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812293; 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=afKJl9J8dwmJwl5uT+DP4MXGN3pCqi29VExi2VZVhL8=; b=g3/qSbu6whqbjnjm/Zgt8MiU15NnECCLDiJJjMIkCF/VSOc5/dq5RM5u+5/UIStxMn KkCuxY3VlewnU8yHIwNFjoAnQwZ8Q0sRtLJterV47Won0Obe8Kv3VqyBi+OmXGJ0icaH 0DvEHhPHJNVuEeOnwC2I/Ltg6mjyNwmRBiOHiQ1Hu7we8krjsXt39PFvbR3qHC3qXBH6 122qZvNpKC6686ozVKaqDfQdQOlaptb6NDqF/qUBXJyM20IKnPriOXVoLfrrQbCSw61b H6lrf4ZIYfuwzMlFiqL3UYCdZQNFufegKjTuX3JubpqavOvquKpb1PUFhzGA+7zeFMuS 272A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812293; 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=afKJl9J8dwmJwl5uT+DP4MXGN3pCqi29VExi2VZVhL8=; b=btEmpp1CjE60HQmAqc6bt4HnUJ2q5Q9IeEWfvBZwVdTTOY9Lh/LRPLGHzDxB+vfPsK XaMr7zHWrZxtrYKBbjOVhgUyyvcZZohQKel5/c9LU/+nRStQ0H2wEQ774mVDCMmaxpM3 vX+/xsf0mTSOZXrl+2SOc1HEyYinqrRKjus/XzqfiE2SkZEQf3NsK6i0/1ZyKkFGnc/z 9Dl5nVsTolrMxeonsN4Sd+TKhIXWzmp4hC1I4SgPIGEhp1G2AFvvBsEzy/FZ4WHPViST Ut9UF4UNCnOx56WmWGi9YzOHuzUUouGfkgijbh81ceLZVCvag5tVn0ejZ565AFRqhUQN E/HA== X-Gm-Message-State: AO0yUKUiaange7KMK4O30MnpVneW6cDXWyZlTEobkvtsnv296gYzr797 OMpflfHwpFzrh9LyNREWH25rxkH1LBZs2n8DES4= X-Google-Smtp-Source: AK7set9B0TK2eEWC5+yZ9wRSHHtR4O1ShI1LI2au9ljSzNy26XKWtNUKJSnUoj/6zzmCdGK2CiyZUw== X-Received: by 2002:a17:902:db0b:b0:19e:524a:657 with SMTP id m11-20020a170902db0b00b0019e524a0657mr457407plx.56.1677812292624; Thu, 02 Mar 2023 18:58:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 06/29] gdbstub: move GDBState to shared internals header Date: Thu, 2 Mar 2023 18:57:42 -0800 Message-Id: <20230303025805.625589-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: 1677812346185100005 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-7-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812529; cv=none; d=zohomail.com; s=zohoarc; b=dNeYTBTjdInCEGEWcoHVd1S4h9FTtfXdWMT4kgvKqor1GA4poX2pOw8XeZmraX2lS6pTr2kkDU60LLbH5ud5R9j0daVAsy+9YwrHJFtuXQYq2cnySn/wb9tejST8bV11hWq2z9vA4BnLrnx0ykhiUKnMUPh0hUayTdgryB5TggQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812529; 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=B9W3wFs03k7dis/zJ2ZqM32MFlhRl5WhqJ+IbJHjQRQ=; b=jexfoXIYmFwEXTOAudazVsJqTJ66k8Wgy21OpUPtMG3Qnwivm3DcqP2xcFQfx3svu4GQ88a538+ttL8w3EERFFhcrtmydIMFHgKlqjEY2ifcr9pxc2AOHHBh3ieCpb6b5057iant4hdL0PKR6xgbEOrs63E6lWOc2rO7V7Xdw6k= 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 1677812529261243.35617188049855; Thu, 2 Mar 2023 19:02:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvco-0007VV-1o; Thu, 02 Mar 2023 21:58:26 -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 1pXvcg-0007RS-T1 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:18 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvce-0001ou-BT for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:18 -0500 Received: by mail-pj1-x1031.google.com with SMTP id x34so1209780pjj.0 for ; Thu, 02 Mar 2023 18:58:14 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812293; 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=B9W3wFs03k7dis/zJ2ZqM32MFlhRl5WhqJ+IbJHjQRQ=; b=AhMuzVjn+9fvkhe/m4AycOCKTsYEm/L1A0zDs4Mv5SC3NaUjvuZZ2v3LZetGiVumoR Ik4td76+JYrIqbDfz8I17oTdosHRo64Ztja+PdiyltSRE/d/JQh+mugpaRaaGqGRqKb/ 9HyH9ptuxonKCE9OWrCw7TSe+M0JJbmt8tKjSzlE1YkznTh807MgMYtUDTziSrrvdJ8k D9YjCjXGoFF9omZE9gPS13zdqPO9JE8wJ1rxQFAyimLRFbZUPgCQXz4n0elMW1YxuMqJ rcEaXvGRw6yW66+rac7NKHxKpHuibzhkHf8jb2HYxPTDY1Eg0hEbDFXIs6LvZyfalve4 ifHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812293; 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=B9W3wFs03k7dis/zJ2ZqM32MFlhRl5WhqJ+IbJHjQRQ=; b=bo/qBw1y/LyLhq1Tsw2fMADS0YHp1hqA3X//hkQYstJJVFBGY/RKsRWoaBk+d1EUSd jEM9a4uh7KuG/3mrX1MsgDQYSlIb7JlJMI8tSXCdCDzQOD2cXVnN3H7sTnEV6TIhOBBH u86qGsOYT3oNsvtDF6GKNNXjvYu4Qn4Vns6Z/kZXkUG5ppe89XUzDF0wLfH45UHcjxHx Nu8w+Lk5sBjU4919iaCQBAVQ8LEhHtxMi6D2SaHnUwLipck3ahXnqXBRwuKollhVbkJ4 oN/AEv2CCclL3P+chfF7E8m+NztVVIra8tFIrHg4dtam7rHF4yUfUOXjviOopQDfapjn WyrA== X-Gm-Message-State: AO0yUKVhRaUKhxTExfR4xLnoUTsbraMk0ugRRGRx7Aq2D+rJB4yuUuAF IZGNRKH6tjPlCPKKBE/t2lzgsnO3SbLFjb4SVGE= X-Google-Smtp-Source: AK7set9HuFDAbdfGpP/EWbMg9cb7e0Yzsd15lT+O9mG7uMfIi8Eg7K+ThDmd6/yFTEUhfyjzRTtqGQ== X-Received: by 2002:a17:902:740a:b0:19c:bcb1:d75c with SMTP id g10-20020a170902740a00b0019cbcb1d75cmr425836pll.30.1677812293548; Thu, 02 Mar 2023 18:58:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 07/29] includes: move tb_flush into its own header Date: Thu, 2 Mar 2023 18:57:43 -0800 Message-Id: <20230303025805.625589-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1677812529730100001 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-8-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812323; cv=none; d=zohomail.com; s=zohoarc; b=cGeOlvKCRA1D+EPL31zw0WBu7XaRcr0FmFjsIqCA9InHGnBv0i98vT2cB0lJauijz3iCEwc13Rf8UsNsm+JXErgrKm9v64xn3fy9J4Y5IsC6/YINsDYNeJY+4OrMQavof9KLXGfrQQnp/6PBDBiIPCsNNPoHQbT0MuB0fkp0RN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812323; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=G9iWO+3Hy2hck2BIPaiZbvwt5GYdxrGrNNABayyodZuhekLNFSEmYgbi0BHCDLkT4F3nvbbEi0Wec5TZwEOLoxqVE4n1gnckZdQX8fK7D/WKOJk6wOX8ilc9NlNfmN72GkGZBXa4dZ5eBWNwfPVWHrR3IJBZQd0capBCALcqLls= 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 167781232300995.67437652375759; Thu, 2 Mar 2023 18:58:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcj-0007T7-KN; Thu, 02 Mar 2023 21:58:21 -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 1pXvch-0007Rn-Lu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:19 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvce-0001mZ-Bf for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:19 -0500 Received: by mail-pj1-x102b.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851598pjh.0 for ; Thu, 02 Mar 2023 18:58:14 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812294; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=NUnIy20LGnEP/1vY3HMnYooszgnMBv2svb75F64iQhCevUdpJc+szWcujV3BgNfMKV E7ieC0VjgVljadSCgf8Q6Ne/mJE8E4kdo7jAdv+vxmIs17BF+e0UVnegC9ohwoCMW+8z A54S27MJpCPkd2g1Irc33pIZ99HbMBVUFofaqQKUIrKg5OM+XzoV4dbZLY1bsWhbLKlL JoANFIe4+UANDC/q5Xe4im8CmmigxbKIY9Ss9GhyKE4YmzMXs0yDMYzblQESfDGhRnEF MTGmEUZW7Tv4e9A+5rClanHWtw+JhpzAXiA5rlRdCIwNzVtXJuHUWx7BF8Aa5FqQvgiM RMeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812294; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=NOsG8qnL+RnJZagE8XyqJT1n/tYfAsGLMoNwDI6hYQU5UubeITaKEbogS3xcuAYjJE vEkwgHFDsKbylKavEJxfi26z2FWCixGVc5MexqbiwKetYjqFe/Yf/MVAixFVlo44ad/N 45pvLnNIMVx6jXQcx9k73MJYKmFwNMT84xj8hxvy4cgzhDUp+hQtaVvFze1wwq3o+WRv BYcpJQYCSdhKE+gDAOxCLb/+2V8blZChvMKe3Uh5+uYKcO7TZhfB+eP0WohIWJ1YZIAE pz/GbjdoTSaPVxXJikE/YMIsdn1Z00G0k7RDmiPiQeqCV7PaGgJBGxcT7Mz6B6GJ/d9U vAtw== X-Gm-Message-State: AO0yUKVQUMTn/6m7X1Vvgt1xGZ3impyTXIy+UxkqIVNRK5KJ4Do737+W dmyFJeQJuGAtzkdpwA02x0o9m69zP/8NsDAj5XM= X-Google-Smtp-Source: AK7set9HwVmWyOFKFfWtMXFe27MetJgf00FDTLwbWxl1oEI5D6TBGZ5x/NwY8avnQLwBg1gy+D9yhQ== X-Received: by 2002:a17:902:c40b:b0:19e:8bfe:7d68 with SMTP id k11-20020a170902c40b00b0019e8bfe7d68mr711206plk.11.1677812294264; Thu, 02 Mar 2023 18:58:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 08/29] gdbstub: move fromhex/tohex routines to internals Date: Thu, 2 Mar 2023 18:57:44 -0800 Message-Id: <20230303025805.625589-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 1677812324196100004 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-9-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812344; cv=none; d=zohomail.com; s=zohoarc; b=WVTjRNQBHFW0ibXJXoAeePrRgD8D1hnJB1LsM5OzWs/NhOS3Qa3XANagahNT8R5o0cGh4+1L4L6S+hu61kuDzCckoq08rclf5VZNRU6KEbAmXFIuiUq1tXPxKb+R2FnYvQT1hjNwBBXTs7Zadbz0V+hhv/kLkH+wqpWedZSrimg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812344; 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=lNe1YMP2dmWkf8DanyKvPtkKJTZWMU8+m3WZiOqSMdY=; b=Hqq/nt7K5qq98S8qshK2mbKYSKdh6fsnjhTPHlnAxPTLzkmNz42OPJasu6Q3jarChvzb87f69C3AtAnR3/rzs/kNuiij/zjHrpU9JT8UqA61jo3QP0X3CYR1KeKzX8ykqMCGo3yUXCWmUDbP89laO3zs5hAkHw3SS6oGCCKdKyQ= 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 1677812344021226.24685502335035; Thu, 2 Mar 2023 18:59:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvck-0007Td-CV; Thu, 02 Mar 2023 21:58:22 -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 1pXvcj-0007Sn-7F for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcf-0001pC-2o for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:20 -0500 Received: by mail-pl1-x62b.google.com with SMTP id p20so1298654plw.13 for ; Thu, 02 Mar 2023 18:58:16 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812295; 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=lNe1YMP2dmWkf8DanyKvPtkKJTZWMU8+m3WZiOqSMdY=; b=oG4ekm8Kno02Kd2FEYFBM7xmhXH5GrZANFw0vFbzLC6v8aAf4MGOJeWUC0CESB3AtD 1J+aLrVN+kGVfuzgN2Pv9u+3UZzUhOBkT+HICSfr5sMCq4eh10nhtpjYganohcfYYyLc Yc9itX4H3Zawd7SZlGvpjePqgdD8vi/1/vUmaS80qZdO6PIZ/NwIDdwCYRbKj20b3dkQ VrNosRN4cRSkc4s/peewzx1Zbz994hcKhjtShbo69EXVMDoqm8cScIsiM2Dxyf29cFtZ AJJpJtp0d+YWSpF15nHWv06Fdpw+icX2z38xQ2ym+xiLmWyD8h2pCqlrk+4q8XWJpv5U Yk0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812295; 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=lNe1YMP2dmWkf8DanyKvPtkKJTZWMU8+m3WZiOqSMdY=; b=U6G0+qHyqjHPxqDLu0FfM+U0sFAjURT/1W8bbpuIMu17ocVrYlYSq0eUfERA7NaXXW by5ebNmksOeFdnwXEOskSuxqA0CnCrU5t2xU0zgGAnZSpGBZ/XvNBRFrS+gs9T73b9Pw 1Sy5rkdHY1ERITas4qBwjHyPTFreztjAV+EnRNMQRnlb/UEml5ysCxD7vfiVGaDwN7l4 o4CCBaZmQHvWpofNqGSb5Lo8PsadYh0+Je74D9ZfdBg8oymbvXxrF/yisvphBSyrysW/ ImZVaeb8AjJbjQppIuUQQYKezZynRe7ynJJMmFPUEz2vys653MCZuxFymQfyuw+py6vS 9CfA== X-Gm-Message-State: AO0yUKUGJAx9jFAMx2/S2+xkcuMYUzFdQs7iGKVJv92mhdaS9qIT7PLX 79dFHYKkMeLbf9qfWYYk3X3vBIb98Q7O3Sz1cpg= X-Google-Smtp-Source: AK7set9CGWzQTj3QZTYJwfz9F2jRFAa4d/BHRrYvenUPOBWGt0peOBy2I778CDts95zcZDAet8RkAw== X-Received: by 2002:a17:902:d4cc:b0:19b:dbf7:f9ca with SMTP id o12-20020a170902d4cc00b0019bdbf7f9camr804850plg.0.1677812295291; Thu, 02 Mar 2023 18:58:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 09/29] gdbstub: make various helpers visible to the rest of the module Date: Thu, 2 Mar 2023 18:57:45 -0800 Message-Id: <20230303025805.625589-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1677812346253100007 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-10-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812431; cv=none; d=zohomail.com; s=zohoarc; b=ajFWrSinT1cON2P1SlOTeEKCcWZxhZ4ekkyq6K++wUvvifs5hjwOb3WyuR1TmgzNrT5p8oGUL6AZTX4k7MVuePt9W29upW0+n/2GvU5cEcCWwLx7ndPisxA3MKOqrfLbOa+n7Y1Z2RbtdTlJ/ggtwYIDwZRrKXVVL993rv0IkwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812431; 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=Dr5ZJ6RSvGIveGs5vu2KHNRRPm2g/6dLEOqHDvmuzV8=; b=lThg/NXYDkxBdazvNydPwX1fhS3yWenI1fUUo5fcz20ZAaUmeWsPjNL7XQgKx7DJqxoVXGVTmxdp/HiN1tRkdnYD6HBn26O67gNxSHzskoAWfbtYOhBQogpBvfDLH4M/NUhOOOWnQ8uGfad+R8E7iTzWDzjGdjuG5VLyV6lnAs8= 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 1677812431636948.4433340350964; Thu, 2 Mar 2023 19:00:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcl-0007UM-Al; Thu, 02 Mar 2023 21:58:23 -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 1pXvcj-0007St-AW for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcf-0001pQ-Pi for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: by mail-pl1-x644.google.com with SMTP id p6so1415418plf.0 for ; Thu, 02 Mar 2023 18:58:17 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812296; 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=Dr5ZJ6RSvGIveGs5vu2KHNRRPm2g/6dLEOqHDvmuzV8=; b=ShwwhJUsNmfpTE2RP634dXN3y7m4S9uHyD5HGSywLW/qOgmtXrmpwG7XfriWEqrW/J i97jC7D+jsodkcIUwb1xyA9qRrv+i9WeF/JrWzcFB/OgH5rG5upzTI1hkwgj81JIsSZj Qa3SEg6d3fnn+/E2lXe9iWa7iXlwvP6u0fjPt1jDVUP7gzAwwKQl1QKVFnCCJYkUIxg7 tYB/VuJ7/EmOsYrU3/1y7NxEjh1Bq5jjjeMa5Ydzk8neLVwdVg6CUHACtR+FwSTFsyHs k8JwT6bsBthysICvy3GhwklaRt/4wHYelQWxCWx/ZAKJObgB325CRvMhYhUCTxOc6Wck 01zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812296; 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=Dr5ZJ6RSvGIveGs5vu2KHNRRPm2g/6dLEOqHDvmuzV8=; b=RYnwt28kHYOKOxXZRTn5bTTxg++xZcX+pndlRW/lPB2pKH6s4yM0QFRaycYqfHsBJg 0xjoeTxTThvL0wSmA/2Yb3Tpqm3cn3xC/KqguiJi5bBLiHdPMpbTeFnNkSbohr3+tQs+ EN9tHkgI+IPWCIfG/lO7zzxOvuSMbqHEHk9vEmvuS33g9VYrGm+MztOXNnN3xwsIrF+z eUjJKiIs1W1AuWn4gfFIB/QnfuQAqdYVMPvTXhE1QRAA181yKvGMw8JCi980fMRyCCeJ p5MBxNkT5y3xrV5GiCPL9E9AU2cc3+0wwJi+T06zBWmy15tSa+xuEBS1N4pt3EmHO8WL I18Q== X-Gm-Message-State: AO0yUKWVpqguNDAHcug9DZBH2LrPQ+4nak164cat5rZULjnmcqENAfBV DO/tLgYTsWFfIUKWv67Uf/QM2nW5r2+kv0DSVScFkA== X-Google-Smtp-Source: AK7set/7ZcZh9zEpDe+fi7Hv2sMH2n58raODdv0c+5JYo9Q4LhgjAlSVPH10orV1a1X7tr4vWzzHsA== X-Received: by 2002:a17:902:ec88:b0:19a:e762:a1af with SMTP id x8-20020a170902ec8800b0019ae762a1afmr3993421plg.33.1677812296125; Thu, 02 Mar 2023 18:58:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Fabiano Rosas Subject: [PATCH v4.5 10/29] gdbstub: move chunk of softmmu functionality to own file Date: Thu, 2 Mar 2023 18:57:46 -0800 Message-Id: <20230303025805.625589-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.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: 1677812432924100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-11-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812381; cv=none; d=zohomail.com; s=zohoarc; b=SPbR/B1MT3T7s/8c84AdY4BcJ2lVmwCvU+Zr2NIS7BoR7pMvIn9Jk40VWeQt5BNmGwWOe/8uWau8TBBkM0qpleQTBYKmeThAgTpZgt2WTcpf23+o0fzf1btsL/cAio1Deygo2rLJIQMOJzjvRCS97fjNy57fniXxDv3OHdZEL8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812381; 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=ZtobSpYZ6l+5unCyBqtXSqtTCL27TdAYvJ1i9vgXn+c=; b=nSNnmayYFxxoe+qWM0B9OODVFvoMhtrnrKUJIa7AKP79g3rB9nSqvZ7DLTC68DNSaplGVD1xkfJwn8zw/wWWYG7dEw7mT+k+IlrV3zQ/W2EpoEHcWlacoM7ShU5QiXbDHrdtNsZ+U2BFsakxP1JfDyMnQVbiB0DNlyRjPee36iw= 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 1677812381008323.16625593510673; Thu, 2 Mar 2023 18:59:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcm-0007Ux-B5; Thu, 02 Mar 2023 21:58:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXvck-0007Ts-Mk for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcg-0001pV-Eu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: by mail-pj1-x102b.google.com with SMTP id x34so1209887pjj.0 for ; Thu, 02 Mar 2023 18:58:18 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812297; 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=ZtobSpYZ6l+5unCyBqtXSqtTCL27TdAYvJ1i9vgXn+c=; b=wsQ3XtYy2cMbgf8n7Kse/Y8XE7F5pNktBfjQhYyflUU77JH/awpfZS3QHq4kkRMtSA tf87QXsT7ZHLIbvh9xiE0M+ZUYzXtbC0y0qE5G44kkMBSDiS+dzbFVkPlZc7ie+s2i2D WrSUlQzi1nHJQ0gEri9/ZCr9t5JWAEWL+GkhHtdYb5Kpfd6D/7jvxb61iiN8YfBgCH3I eAdipevqIH/JuGtELdMo+swiKwsHzLfwE1ygmjdr3LRy7zYIMUUZOui3YCeNgYWBKEYM E3ivJ3FaX6tLjXJhVYbl2E5WHBq6+A+zAND3f3HKbCOcG44ql2dqcpVe+0oPf+Ahgo7A ifIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812297; 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=ZtobSpYZ6l+5unCyBqtXSqtTCL27TdAYvJ1i9vgXn+c=; b=qYDvO4Q4iAo3vapgk1v7e0BZSnGr+6jaMWU78seqZSBV2xN5qeFOGyD7sDbBJmYSzB v8Z6lW0rf82sJyvjsnRQdpXKzZ5NDIoSe4EDs3eaW3SkIS6UMSF5eRP7qa0BtSPZAFcy laByeEh8hw7GYEWGisOuZOaBvSMlbYTU//TV8sYn/Dw/Pf3IqC/mX4QvFxFMVZYE7ead iw06a3xgs/zU/Svao1zG25Yy3KCEB5dBwW2aQO5+pZcYfXEpMABJpUk5wOoccbJYHzne ce51m7sK5HCtfpm1U8LpFOuQRjUvdLuxusJ2+pXENJQaLxoGAhYK8YJKp5tBqpswAgFf D6Ag== X-Gm-Message-State: AO0yUKXRzMwEBY7B2uGcKTjB7g+AENMqf4PsnHh0pDCey0e4lwxx43zk FB2uWMUe9zn9ZaPNPzHM5FTy3QGK8KouToZsPZk= X-Google-Smtp-Source: AK7set9mLSP7bDMBgljXNSc+FDDliGYehZvcGZl22bWrWExZbccC8WREv0DWNvxtq3L7DC7kOzs91A== X-Received: by 2002:a17:902:c94c:b0:19b:33c0:4091 with SMTP id i12-20020a170902c94c00b0019b33c04091mr547789pla.52.1677812297006; Thu, 02 Mar 2023 18:58:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Fabiano Rosas Subject: [PATCH v4.5 11/29] gdbstub: move chunks of user code into own files Date: Thu, 2 Mar 2023 18:57:47 -0800 Message-Id: <20230303025805.625589-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 1677812382564100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-12-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812455; cv=none; d=zohomail.com; s=zohoarc; b=cgTsrx++WZRia8uksmX6XMt36FdWKVH45votBX3NcrBI6vWp+v2zwyN8KtbuxuuILfU6UtJAZv0NioSoKkaFDmYUNBwDk58+ygRZDkFFV6XIG9UpvL17YGSLRZX2AcCj69s0UU1yYuTP+PVQESXGlUpHMGQUwzMWNwm7uYybIdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812455; 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=mzQlLd9zUuaRJux4t6YnHFCedCjY2bATUZGlQrOk4kk=; b=G+9oI2vPnidLCZfHPCrVLk9fXN9kGQBP25OluJxl/G+f1Yp7hPsfPVhPIrvQEMyjvKrGm3bCFG0u9wHq9BS+IvSAk88dyy9sYVmjRKNAWYSfclg2GmmwcAw2k0aww+5EV3nvnscsL6xOxX4ztJiexdYrN/eAavqWkKbGRN0QSAk= 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 1677812455762115.03544129919987; Thu, 2 Mar 2023 19:00:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcm-0007Ut-43; Thu, 02 Mar 2023 21:58:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXvcj-0007Sh-2k for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvch-0001pk-EY for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:20 -0500 Received: by mail-pl1-x632.google.com with SMTP id ky4so1363141plb.3 for ; Thu, 02 Mar 2023 18:58:18 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812298; 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=mzQlLd9zUuaRJux4t6YnHFCedCjY2bATUZGlQrOk4kk=; b=qq5GgzVXiFtb7paXe24HRWNpHl4VWdQqJbfqpdqEnYKpVQHUVCyEzd6csff+ybYZTp ZqUiugksfFt9qSpL17V2Vghs0Gt/1Wn6ICdVbKu8d6wGY47fM+sF6ZEJniMMNPORRiif eLzLMEcapxYvd+PflyyKBH5G5rb7lI9fXaKMmO+7cDGFKcMdzpD33D7Y9oWA+OYpkBjl 16S5b6UfwDBuR/YVPHb8BMp+LXqYO1fR9DAl4qZ4uviwpK1kltmfE525Q4yEAaMD3d5T SGWPdyL949YyeVe65aZGJvbkZMHAvEkIPQHiVxc2/l35QGofSa16ZgildD9FgCvQwzCl Laig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812298; 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=mzQlLd9zUuaRJux4t6YnHFCedCjY2bATUZGlQrOk4kk=; b=ohO5DNfBn4BxChxRBwjk9eIWBM0d9eudKorCjaSaY8ETp2gP7C8ljyUSryy7hggYw4 lUjtQXEYnvw5qUwpT9Ii0O8L8uIsKDller2yGscwz9eqQ5953/nsZ4zr83OyDF6fPROx a+YmvdAY4Zimx9KImLsKwZKYEaqrFnlEZvGbqi8j3/XzbmxYCTJv1xejDkYa/JU9BxpP bXxEEwVGwVNUFLbDjgnXlZS3lcf4s83xlStzTdfMxfi/28RaQu5EjRKsS3LF0PVlbzbA PL3BlL2OF0rrRMBsWGcIX7pLKhWoPjhPewKERZXRez0d2SKAobt7id7uN/7r2voE5HH1 5KpQ== X-Gm-Message-State: AO0yUKWibLZ7B7BrotORvDq0TQgj3wpFvSUjMJxx9/y7pYhRL43cq+is wcPPfyPbljnNkxuxM6qGbwxecFbAnlib01KdLNA= X-Google-Smtp-Source: AK7set87bx/HKRI+FUVkym728A4Wfc4DTfaBEOOZCcTP2fS7PE/LGna8wWCt1k8ZqWsRorw0Kwt6xg== X-Received: by 2002:a17:903:32cf:b0:19a:8e52:ce0 with SMTP id i15-20020a17090332cf00b0019a8e520ce0mr585261plr.58.1677812297862; Thu, 02 Mar 2023 18:58:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 12/29] gdbstub: rationalise signal mapping in softmmu Date: Thu, 2 Mar 2023 18:57:48 -0800 Message-Id: <20230303025805.625589-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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: 1677812457028100006 From: Alex Benn=C3=A9e We don't really need a table for mapping two symbols. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20230302190846.2593720-13-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812530; cv=none; d=zohomail.com; s=zohoarc; b=Elr/gRev++qamn6tya0LOmsR+rkMlwjZ7NW2IbDFSwicQEXVtWmmdhJDu7ZpY5fpLhdMh9SZn79mOCbVAdSpcAaEwE5kPZP5Yh3J8B1UBBSidwPfm4oFnDxVd1CCf1JSezvQwcXL7zO6AT6HcSyUoSCFw5DFKnmeMrwNzAYUckQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812530; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=Nf2QnjnnP9cIk/R8ETMsfU95cHrN+Ab/pvVHx+w7xjGDGZAdirVjWHJGWv20f/SMjPbQ4tNHdFbJoshW1smTyHRxxvb4UR7Ai5fufzwFqdEnCdml+Q4DLvzfgwsVyaAf9MjdNC0ncOlCSD8UngF+MnA/oMMpbBB0dMfDOP83rJE= 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 1677812530862962.1026986787225; Thu, 2 Mar 2023 19:02:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcm-0007VA-Qt; Thu, 02 Mar 2023 21:58:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXvck-0007TV-3c for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvci-0001q5-4C for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304041plf.12 for ; Thu, 02 Mar 2023 18:58:19 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812298; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=tNoX1P+AvR2lfZ4RIfaACCRNfL9YBFi+v/pdn6GOD03pA1IIjwvKKxQ3iKrA80f4BF J5WwOV6pM5Kj9QTT70nAUfY0WH5Tc516ekin8mh3QCWHY8AdGRLQPQbg0G66Ex7bQ21J jM1AFPM+UO53i8BLwOHJKtJInML/xDmdZr/ziZ6OndFdJd+QDRPd1kl9nboE7sAhe0l8 igyzZV4XHK8Sn8WWVtKhscG9b/g2r+NYQhRxDrYj8RjGgfLvzWWhsxERBfsSLQ8epUxZ GAntPsDBp1XwW+/P98RL2NAy2PoxIXLLNnkFz7OeaBMm9Ifpunggak3jVwtx/t6mAX2v NUQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812298; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=pTkFutbMFcMGy6eYG4CJDOUKD1Ys3pijNvpMLWVIeHs03n5imELxuXnfqr9HRNdciw zaAx/H3DEIbnD1jbTAuAp9wk/rWSO1XMKhcWy+KGa1d+M0JYxqRCJz+urik4AiOrAdv9 NVygwydpvf7szQjzH/Go/WS2UCkZaJnrgqXMP4DsRGid0JjjHxEwyHA1jKGB1UMAg5gl xb4L+9Am3UtxE5sNZC7V6ZDGxE0wHfzTkBRegaDyBWSBmZ+y3cUt8nBIXTnMdq7PfOOK GRNJ0o3EiIaUJ//qS8DM1LvUehthACX9L1spsboIpnwdIqUU6gRA6qQM8P1ZlC8K/J7K 6Maw== X-Gm-Message-State: AO0yUKUYs2yivZjZFb6H+5Atj6+tIgReU+LSu9qTz7jZS1iUrtzox59R Rh8N925aTCIScAvSloscVO5+frypBcrv2iVX9+Q= X-Google-Smtp-Source: AK7set+C8yuP3ChTB87Wruq6OzVesocnlGQhYv0w6RYLjDNbbSHYohoXrAZGnFH4vk5AyC2y4+kucw== X-Received: by 2002:a17:902:e842:b0:19e:4173:38b3 with SMTP id t2-20020a170902e84200b0019e417338b3mr611153plg.46.1677812298579; Thu, 02 Mar 2023 18:58:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 13/29] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Thu, 2 Mar 2023 18:57:49 -0800 Message-Id: <20230303025805.625589-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: 1677812531680100005 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-14-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812494; cv=none; d=zohomail.com; s=zohoarc; b=ZGqwL035UZa7ptigORIOaZ9aTQgxVgz5EureHMvu7xbt7qyyZil5JJs8oZcF8TrY6OXEnrPLqiqEoj+OfVVKMbUP7bF0pzKGXpIkQoqx82dO/P0k2kbA9uSdVQPTUtrQjikE8HWdl6vLJVvdObpHgxLAC56fpbepAh+4XSSMGak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812494; 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=eLmx2eJEzrcuefRjyJcG44ypWKcZev5YnQRPSJMGOkQ=; b=mQbE0ooxhmP0bX8jQdqPS2HmVBvYoHz4nWgKtWliLI0rXs+E7viosXrIWtP4psAbLLA+5fgmK8iNQbpXbqOhaIvQlPauDxN/r4rhaB24CHNiZ3fDEqicelbyCyDqoTbUCT/D7k00uR5iLvvG+3UR5aFpDkKiWoGz66DpNx1jTbg= 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 1677812494034655.1346996269933; Thu, 2 Mar 2023 19:01:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvco-0007WB-Lx; Thu, 02 Mar 2023 21:58:26 -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 1pXvck-0007Tj-EM for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvci-0001qG-K0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: by mail-pj1-x102d.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so967570pjp.2 for ; Thu, 02 Mar 2023 18:58:20 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812299; 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=eLmx2eJEzrcuefRjyJcG44ypWKcZev5YnQRPSJMGOkQ=; b=EOPJ71RO/fkKGs8g/MCBwM9kCbc4f0MSBSeB76VvG/FL1T2K3brPGOGy7hcuzXe/vR f72pPwH6MTef97wJDPBDUXxCQ8t9RFUZDKbfbwTDr+bvzAAqQsKIzmCSUcjSViE0leSz 4PxO/y8/6cRnkPy+khNhYa6slCol9HHz0R0H31EcKl2zmeyGg1CFk1nLGYocXj5/tw7O QSCBx46kpW11tCJOb4leHCf7bXcf7JAyfoUY9buCI4yBj98M+GalTZ754D+a/TMwnNyJ viOoq3NKZ7K9dw5ttw6tP2hE8m79FBXPU4n1pedg0/eYVs0RBQBSlTY6qzTYhCapsI6I 4qUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812299; 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=eLmx2eJEzrcuefRjyJcG44ypWKcZev5YnQRPSJMGOkQ=; b=4FJnqgPJdgj0Bqmc7d63r86c8sh2cvIZhOEFN8OuczTvng5ioAbUxEsj/UZgVj7SEs rSJ1vwCuXTTax+CLCb1+iYsUUpzLvVtBXj9KZSWlLhyKyal+ur09jR89kQPRmpMotxVe bT76en8g8T/ELQg0uTbWVGG0sKv9MylVSyboVZC7rjo33Qp0XxYBq2t1pWcLNnIuL55a /R+NlRmTNp3IUN8ZEe8a5EzfElePfKXDWZKRTs/2QZdnQ9eS7uxWIu/S/m4bLW65PykO E7A29MkLkaKVVt+l1GUPgJnxTDgB9DnIZysR2FvRr8apNMkOojf4zNemIyxZdWSPNC2T aGBQ== X-Gm-Message-State: AO0yUKUVwEYhZudTBHd+opQf3m3FFu1M2e9qII8X9aQMzwwUu6TOgk8D wn3mup2YzQmg8dETrc0QkO244yaOXillDQ5F8rU= X-Google-Smtp-Source: AK7set9Nsh8HfbZgRXWsbxx7qj6paQUikICJXJIUF8yMrwEieDwFWr5BKxIWeBWBW+1vI+1fSiX/AQ== X-Received: by 2002:a17:902:f54b:b0:19c:f16c:5cb4 with SMTP id h11-20020a170902f54b00b0019cf16c5cb4mr653004plf.1.1677812299238; Thu, 02 Mar 2023 18:58:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 14/29] gdbstub: specialise handle_query_attached Date: Thu, 2 Mar 2023 18:57:50 -0800 Message-Id: <20230303025805.625589-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: 1677812495429100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-15-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812550; cv=none; d=zohomail.com; s=zohoarc; b=gpvxcoOxfZ2Y6+Tneo/q4q2MszqNSpq59PDVu55jgUgedSIvYWlwmkTg8MWagogkc0oyxIMcmE9sxf0iCqnWtXTgD0H9FYx7/Ce/ydEUa79cBHJelNf1dGKNSOXUoeLQwFNtNhIZHtkuLJbnDce4ddkL0oJTL+1rX7ZqKW7muc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812550; 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=gsYB/ur4MioSCASzY7iISb0rzEcvUMh2PpjKeCB3a8Y=; b=hdFaCbcVfV5cFDEeCcTkiBPkc3RYsVnWoTyQmQiz8yYXcpcIq5HC3c/+1nR0kRUjCvzHg2i1yxP0fA8w+u3fFWmlXU2Kf8FhPO0dQZc1iIHUn0scSN8O5PwbG+HeDZTK9SBTWwJ/SFm/hNRYJXOXAFtoDHh72eMWRve2j7KLrEo= 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 1677812550284187.54741022316102; Thu, 2 Mar 2023 19:02:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcn-0007VJ-E8; Thu, 02 Mar 2023 21:58:25 -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 1pXvcl-0007UR-CS for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcj-0001qW-DO for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: by mail-pj1-x1031.google.com with SMTP id kb15so1177007pjb.1 for ; Thu, 02 Mar 2023 18:58:21 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812300; 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=gsYB/ur4MioSCASzY7iISb0rzEcvUMh2PpjKeCB3a8Y=; b=N2KvnZpymBBvzZkQ9N8dAq8fMc3eIlfbboZ1jj8uK5+OgxnHnBJN5H7GPI+YCZsx/w gMrl1ILq5fKIjfhpbU7PDTQQUDuZNilgUqf/6gaYsJeEhp8Dc+kLrkXBqi1oOEfr4Xbh hZ2KBRQmroCU/wEN1+U6v8+EhlnaNgxGyEdc/YkVk8+gWLw/rr8H38njU9ogcveHsCQO ArNXGLBwoMZYmuH8Q0VXcrrp0KbzgEjQZzC8rFCLDUSpBJPR2iyEd0rbVZ0ak8MyK3Rk 8c0ithjDAxKD/n31yJC4bE3c0fghrdlrv2Y4VVg4XSFvG3MULDzsOJdrqBqBv72FgbVp Ahng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812300; 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=gsYB/ur4MioSCASzY7iISb0rzEcvUMh2PpjKeCB3a8Y=; b=2XClq/1sLomy0S3timSJJ4IexLgl6H15cWsKKxEcFb47sKKhhHRSY1izNwOKPk6odx tW2uivDgjqcNNacZspbJkXNg5kth9a6erTRoehaSJjWgOk66hECs30/gX4KHulvzchYc btADZGB9s7sjQ0uzZBjvowbNppC5cdA4Hfhi3spQwCNIuDvBuPYjjF5BKWKY7oRrzZaT 5uNMCDbOGkQ1z/mlCd58vnV1TjzCL8jNkMNotkzEuDOkOnDzmPCS8mGPWnh25jyBpojQ Nyre5UloCuaYrDDDp37Pg6/6ka+YQOoIs446KVwdX62UIDQQTydl+KqbJ99EHykKdD+n uuGQ== X-Gm-Message-State: AO0yUKWhlHCb3LkIxeEkTCtG+TgK5RNwu49qaUXEws/nDDKSP7nZ2xsv cZ9lzbWTGRAW40C3Yu9YbD3eV2f2fBCXRj/dJLc= X-Google-Smtp-Source: AK7set+MGd8Wg2qnH/bCqfAvOz2RbDImLCP4CrP87dWA07KR8/bFP9fI93bi/8nhSvdRxUHOkDzM0w== X-Received: by 2002:a17:902:e5d2:b0:19a:75b8:f50c with SMTP id u18-20020a170902e5d200b0019a75b8f50cmr570890plf.31.1677812300071; Thu, 02 Mar 2023 18:58:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 15/29] gdbstub: specialise target_memory_rw_debug Date: Thu, 2 Mar 2023 18:57:51 -0800 Message-Id: <20230303025805.625589-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1677812551733100007 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-16-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812478; cv=none; d=zohomail.com; s=zohoarc; b=dJnClX8uNLsLiay309tMgFp6GYUCLKVRHDgy5uxHXM8gQwv7/XXqwzhtOlSAFiklWv8SKCEnLSAuDfVUYmK1ikp+wsh+ssxje9Yn75lghVlQc8i2hRO4l4q8tBTg7KJNvmy3ceRu6TxcreivjDw6w5Ogm2H2onWEP9J9rqy1C40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812478; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=e4LJ1KHuoGK23yDNnYqJ5r30S3DyQBThNOX/d5vZ/FaidXY+/fVPHBMRAjOVmMYabZ0TTcohGMO54KEI5CSLpJlEZ5vF3ykpSz6IpFaf/u9W2t3vzDCNSwduRK5OsE/w3LdvR0hdPIl1aP1YL9pxmFD0gahc5T4kpvQjh/jMqxA= 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 1677812478903228.5165567761452; Thu, 2 Mar 2023 19:01:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvco-0007WE-MB; Thu, 02 Mar 2023 21:58:26 -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 1pXvcl-0007Ua-E0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcj-0001ou-MD for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: by mail-pj1-x1031.google.com with SMTP id x34so1210009pjj.0 for ; Thu, 02 Mar 2023 18:58:21 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812301; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=KksIPJN2jDvsGZjjtxBd96APwfcAAkQTUQzr5RgyG8to8hnhVD8BrCWSKVulK20iQP f+BmpEiWOKM11NT1kWWYWJjFQtBvK+ubSTe0uwRVxU+tWNEnNML8Y8w5qgumyE1e4Jpt oC09KQaZM1WzOLHF6iuiiWVAECsz4krJj9tpXl4HzWJqBwRt73fE1GvM/fExZA2HGdWC 3zs79m+Rtz1Idl8ezm1DpwcDtRPEnNzCZ1xW+6WwL2rQyB19Ez+bxBW9Ji+HvdWRkFI1 mVYPdzPFOMFklEo1D8XOWNWVf1MgakrDNT+3ogxZTKwzxz+KMcCdquMEx0YKftNDCIxd 56jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812301; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=V3ekmxUJeY8eYz4/DEQcnA6ad1l3M0jAFPURhz81RswLEPcmuiDVpUfPtt48DMpTbL vJFdVT9cxJrxQPpgFd6OPM1UZLx2PGHA6kLWH4LLN5c/R7268bx93GcAGUv2wpjiw5A+ p1UkU8wwTfCLLHOHyzbWV1P1gkQ+A0p4HXszSRzXtXnKSZszvYFg5IFTWbRkqq4GDxmK CVaDH2w3RezA6IJL/d/dhCnsNqjUW85e+MoXHQJxUVscKD4FGzivAVxPmKqQ2fhtkYXN ZC4bdoBkqqi8mn5Sr5sMyuV7wOdmjeRp5s9yw41SoZVgcX7n2F2elmc7p5MNn5QBEHB6 4lVw== X-Gm-Message-State: AO0yUKVlZAqLsP2iIgKmI2jzpAl4aqId82rEAuVo2wVtfLH4qoGos0Z4 cBRn0IUNtXH0vjnBWELTs04AU9EmIBB0Tjmimbo= X-Google-Smtp-Source: AK7set/yQPTHoZdM7zP3mzt9Sj+vDpMpr1/EYA6LaPXRe/QTWEi2UhnfZfSP247hH4r8t0gDc7G95w== X-Received: by 2002:a17:903:1d2:b0:19c:be07:4af2 with SMTP id e18-20020a17090301d200b0019cbe074af2mr594838plh.45.1677812300880; Thu, 02 Mar 2023 18:58:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 16/29] gdbstub: introduce gdb_get_max_cpus Date: Thu, 2 Mar 2023 18:57:52 -0800 Message-Id: <20230303025805.625589-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: 1677812479117100001 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-17-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812560; cv=none; d=zohomail.com; s=zohoarc; b=jafRkKt1s56u8DIw69Y/XgSm9KudVJxZ742c0MRfO/c92KK0bS90Qz+zLRY63gpXTuqCWBdlNWkssaLunEAgxA5EvIhfqOyZhEXTWUG//2cxUErqw6R+67wXBmAd5Qb4fQ51yYQzkrE4nHsxUM6ezAFYKf18OhmOss0/gXW+wvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812560; 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=IZ1Q69yObMWzKVjZpAHDz6uWngdi7nRVdbETM5dlXlg=; b=dx27YY7G6CzZYQwuRnE/QP3R3aRKmoWfCjloyhRj5Yb9YnuE3a4nrgoatbwAEsvgJpEp16isHmzj1ecXRFQArCGZOcxBW9aEWHRnQCQG/oahVATxDkAbgyf5euFnEcx1pglqf1Jg0e0I4X6lUVJmPmKR3ALBuNYBnCSHbE2L8sg= 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 167781256064518.109079122718526; Thu, 2 Mar 2023 19:02:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvco-0007Va-8O; Thu, 02 Mar 2023 21:58:26 -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 1pXvcn-0007VB-0x for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:25 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcl-0001r7-8m for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:24 -0500 Received: by mail-pl1-x62d.google.com with SMTP id h8so1315993plf.10 for ; Thu, 02 Mar 2023 18:58:22 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812302; 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=IZ1Q69yObMWzKVjZpAHDz6uWngdi7nRVdbETM5dlXlg=; b=xo0UXvk1TGZ1HfUuDaj07iZE2n10h20QkBB1xcTnOwUvjTcn1L+eavlpIIMeh8/0fx e6Kybe/IJluDRHGee0fDAdRkvj4uZVx074uZcyRgfNJytG0Qsoh4oxzgZdW4IaBzSC+M GrNZVWBOfS9i4YsXnTvWmHL9ajRevmOxTpLtHdfDk1Y82nvaCJZlvZb1HvYxXJzgTdnS f6W5lIvaeQXo97Rpx364i7rWU9hplhFux/kfOFp7H8rkUDpL3c9ozn1FxMBYU5Xlmjth 9Eo7CudXVGZNx1xQrLKv9TNwyf1txnl5LogXrCUSWu0qIBmwulZIvBGmVAgUXBIVT+8n qjTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812302; 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=IZ1Q69yObMWzKVjZpAHDz6uWngdi7nRVdbETM5dlXlg=; b=fIPtwx4gLjM3CTzf0PZslqmKHzT2cHEYDNQ2Ys67OElCzmAX/wTF5AwveglaQx5pPF iNKzhUWmk+BjNkzNIiiBcLdsLqPD1FeHY025O9BFUsSwR2Z2bZ8n3k2FpUrKAPCoAlBG eUwcnLHA709TqDBYtgtYn6fzVN/7kIEkh2hiEQmbnGrUw9pvxx+M62pMdcmk1eGXK3wf GfNlG3zBrcfB9rxGraYOEyu3M+tlwSnjWPZTw7aBIZBHiDgLNujoIWLv/W777Sx+QMiw Eumaf0q3RN1hUPBTgTK/3IgFOzsql+/bnQDT8Bd6fj5CIui95LdrOWY16/5z7WnSB0b+ d+9A== X-Gm-Message-State: AO0yUKX1WEkx7NCrtP3XUfbyHtmKN3Pz/d8srQmsq5zd7Da9LivSKDQ9 K6WU8kb47IM8OVotWOwgmvI04ZukRoABWbWsmAo= X-Google-Smtp-Source: AK7set8BptIQgqjMiTZwwj28w+Cz0x45lf5aD4wvnN7wGhYVhz/rfhx90k97arIQzkt5LosA3+YtRA== X-Received: by 2002:a17:902:c94f:b0:19e:73df:b0e9 with SMTP id i15-20020a170902c94f00b0019e73dfb0e9mr560756pla.21.1677812301696; Thu, 02 Mar 2023 18:58:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 17/29] gdbstub: specialise stub_can_reverse Date: Thu, 2 Mar 2023 18:57:53 -0800 Message-Id: <20230303025805.625589-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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: 1677812561766100005 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-18-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812455; cv=none; d=zohomail.com; s=zohoarc; b=aX4NZ3dxDiWIfupn0oXmd00Z+PMfx8cicGovu6DvHI35P2EJ2dDvjUckLwBSyseWHsIt+pwe6L2flh7qjkU7rzYsLx7zDq3z4gWtgH9liIFq9ySeRF42ItUO3nBt7djs+j7s4tqBIzC4NFCqWhdjQU0pDTUyJYYnSxOJPQ1JD6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812455; 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=Wh4TGmta6KxxW4dXBB2Rrca4W4QJFWocfsDlY9pkBAI=; b=E2DikgT3bKCCYK0FPVnWA1irrxxlcVNatF/2jutHVPPnUxw3NZUURzYqFCo3aVqnVuRXq4cl5tYq3v7oDdGKCYrkYV1Avzpt2J8aiD6e4PKsk1Ehf8k1o3TcoqmV9MrOz8iVs1/AdboQTm6q+em2HblsvgH+u2AX7K/0lJQoeUY= 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 1677812455057522.5562137228186; Thu, 2 Mar 2023 19:00:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcp-0007XL-Sp; Thu, 02 Mar 2023 21:58:27 -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 1pXvco-0007Vk-CV for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:26 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcl-0001s6-Vq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:26 -0500 Received: by mail-pl1-x62b.google.com with SMTP id a2so1357344plm.4 for ; Thu, 02 Mar 2023 18:58:23 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812302; 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=Wh4TGmta6KxxW4dXBB2Rrca4W4QJFWocfsDlY9pkBAI=; b=ZDa5PO+zBCiVL2e0e6EO7+8jePdHFOXeUPD3s/Qks0ANq4FahMk39oKhOwOV2EFNLo 6u6YKkrJgXrAXbJa0VshPjxP2iEzox31MckeA+yYbaxgj+RIP8D43Ihxpo6WxEmmGdOj 0tb0UNFbTAieu8M0lHBMo0K7/a9v44UByCd5oGRDMZgDNBlZyrfhtX9WJ9pN2sr2TXYX mgrYxt5lkficjeoSQkVwLqfmvq1x57njBR7dY7NRul2/zABzYrb4gwObrJPoF+dLwySt 1BqkwmIM6h/2leA32kAnkqUg5FZ+SNc6MQm7wWbnTeyeWUlW7GDv/xOokxedqVcvV0zA 0xHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812302; 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=Wh4TGmta6KxxW4dXBB2Rrca4W4QJFWocfsDlY9pkBAI=; b=tyIbFpmZEXxDXnBsSosKJUaBLXGQA+A5Ym2W4FExn/CqB4lc0qh6avw72kv6BKvLOK Kt604+v779ue4onRTEZC9le2z4DY8OL6/d8a5hipMBtVntoM5TQGevFyXe/rGBee7a+t g4KH7Y+pXhVZ+rFVCxXkoHBAyJ2lSfP7LRdqs+qtmzbND3gRQ4sa+9scR6rCm9BprxdP jLijfG3PsRwAvS91Koogo37Bq1GxvKY7/D1tT61jRad4RWvpjFRLKgXLEqno+wKF9jtb ENvQntruJodWpj7IUQCSXFfiwk5BYFMf0d5u3p7zzmRxJFavXK0VddxQDcnGSrlZoJJr gRcg== X-Gm-Message-State: AO0yUKW6YJEzmSQF+NjCC+YpCN0zEIFMWVEGfszEE7wS5rWlpMTh4dcE DOsRN8FI3kDz2Z0UHJIM2YGITMcmM+0SdMLm2aM= X-Google-Smtp-Source: AK7set8FHUFnG9AKLOPjDl86RwU1t07WIE6SLtF4YGDOH7yn0+iWkCYZN+gJnwNr1iXoC6Kb5rLkag== X-Received: by 2002:a17:902:e54f:b0:19c:b4e3:c65b with SMTP id n15-20020a170902e54f00b0019cb4e3c65bmr659386plf.8.1677812302499; Thu, 02 Mar 2023 18:58:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 18/29] gdbstub: fix address type of gdb_set_cpu_pc Date: Thu, 2 Mar 2023 18:57:54 -0800 Message-Id: <20230303025805.625589-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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: 1677812457020100005 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-19-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812457; cv=none; d=zohomail.com; s=zohoarc; b=XmRJrO3Ut6zB+hTG/RuUGHvOgEYjStKuCJHTbSt81iBYKlNieXZstzVxtaxDqhEj/N5rlugos+iWhwiAsO2z26BVoakTEzkY0QpxKiZxz6HNjI8wc6rVs2LrXTID6JRuvByU8EW3/yx/1JOwA89DVPYPdgq0D6AZ8cS1WcpqP4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812457; 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=KJ4GfexeOkE0loC2ShPfg/ZNhK8OhXGDTJcqqyP7xeg=; b=UonqPSsbahUZstqw5ROBMWtA0froceEV4E5s0FBvCCELuPvrkDv6c3luqbh2S0Hc9G8yN7LiyjzrJM8rojXEXmJGkwOjkkUV1KW3bWk3cNT0ztYD5l4FbHt8dgGS3Ul7ep0X5G8DJdM0PmGh8l7LM/Gw0FLlTz6uXBAUPiHyb4c= 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 1677812457054700.4891579329648; Thu, 2 Mar 2023 19:00:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcp-0007Wk-AN; Thu, 02 Mar 2023 21:58:27 -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 1pXvcn-0007VM-Ib for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:25 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcl-0001q5-Uz for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:25 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304207plf.12 for ; Thu, 02 Mar 2023 18:58:23 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812303; 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=KJ4GfexeOkE0loC2ShPfg/ZNhK8OhXGDTJcqqyP7xeg=; b=WvfKREH74zSU6SOrM+cbWJhy58mfCltqdqf9hbiCj/XijbahjhE9aP6rL52vvdvrp7 iXHjug+5eeg72ws8OgHS0HhW8GT0/FvTROCm0BqO4EAHjsBhFVlawWnunbvHlHWVvUv2 lVIOA+xTMsBzmMLlvX1izslg/aGeLH1ncac2wCFKSp6zq/kbITmAF/e1nNt49oNuiQGc 24hrgD5ub/kDk98VaGBB5fTxoQqn1EjPcIWrXC3Gog3rCoQVm0wJkEjCZd98cL0JCvxV 2rjFQLwqcpPU2GX0qJpFaFcMf47fkiB0Pqco34uBVRcPC041J2MRAGb8x8cdjQv5zR3B Gmzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812303; 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=KJ4GfexeOkE0loC2ShPfg/ZNhK8OhXGDTJcqqyP7xeg=; b=U3Jjw+pSH6lRDiszb/7ODSY3UCcYMH+y1INP/AAKC6cUDXhIT0au24ypn5Kvlc20tD dfc93kWZB7N9gbDYUqjR333a/9OD5+ugZiF/X/twhAx+m66oECXAWM4F78F66bx6tH/d 8sRnmwYnXZhhUKMZRHhyhLFaMD0iSa2WV5QeIxBIpb4f5Tb0gvULQp+RPQnV/Q18gioo pXW1/2OoiEyp6o6Hghwl2HjiFCqxVxPhIpJrWFRm1NXJPGG+E6C7PKA2XqVC3YuVLLRB 0hjKXsj/fiXslokTszJouNJa/NJoQ9Cf4C/ChIK7x2tuWi+ibjafn3fWi7+jhKqbfKo7 nhQw== X-Gm-Message-State: AO0yUKVWXB/OYFVkkc1dtxQfAgJUgoWvwtLzjf0sM+xzHANXi1XksECT QIBwdh+duJe3UyhaqVvOyEJ1GonBLMOwchJcGqs= X-Google-Smtp-Source: AK7set+ZHI06TC6rKfSKRO14Oj/pUm+BM4G8gnwinygdz52p1AqM1+sl3jAs2dOeIyDkgM7G0ttAYw== X-Received: by 2002:a17:902:e549:b0:19e:76c4:2d30 with SMTP id n9-20020a170902e54900b0019e76c42d30mr542646plf.61.1677812303207; Thu, 02 Mar 2023 18:58:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 19/29] gdbstub: don't use target_ulong while handling registers Date: Thu, 2 Mar 2023 18:57:55 -0800 Message-Id: <20230303025805.625589-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: 1677812459032100011 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-20-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812438; cv=none; d=zohomail.com; s=zohoarc; b=Xvs+h+ineNgEd2L3b0YBQe7AqB3QsspaB5+WrbDR5hDtypjFDtg12mE64gNfC4qFJvJKVtcSgEBAvxUdX1grG9DzgI6duC9ryG+kwMD+6kqMeqOiTfnplItj/xJW3PtbJL2lIdvdvglHa/ZKWgs3SN/noIizyrjQWRUqbq2D4k8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812438; 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=CMWr8hu2DUhhMopayYGFX1AvPPyHQPBspx9QuL7Pv04=; b=kw3dQ8yU/LZnbyNVGWWCe3Rb3Xt45r+vXOyHymD51gBqokZYOkUUFe9fBSVJ6mxH2X/7Dio++YG5E+qYaWVzPY0M8OYKwUL+HkEjGKRHFC15YdmcUjn1s+AGaEDz5Q0akWMO381ZA6C3R3FHqK7hIoN5HEMNVkFNAneDtpBEDbw= 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 1677812438833201.95946698827015; Thu, 2 Mar 2023 19:00:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcs-0007as-HX; Thu, 02 Mar 2023 21:58: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 1pXvcr-0007a5-05 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:29 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcn-0001t1-Qn for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:28 -0500 Received: by mail-pl1-x635.google.com with SMTP id n6so1349474plf.5 for ; Thu, 02 Mar 2023 18:58:25 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812304; 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=CMWr8hu2DUhhMopayYGFX1AvPPyHQPBspx9QuL7Pv04=; b=j1xzuovAaNsIROvcsbkqSGUMectFMHoRYkFqSPO4SGGp/lqqs0ZQQam1Yu0c1EnS2B ypI50q2hAqR8uRMSzO0fk65OuSed7QyWkOAaObgJpkIscUy3VLoe4Je3gMS3tNfbhKnh S0nVrwkBYc4ZnwPfWRjJ5NY+A6/alXVSppoqj8SlL/R2dm1pSoFlMy1/vnO9VACo0c+m 7VUCxRMx6KTAn+cmBTziqkAOx4Pm14tBPSN0EI6hIsHZZPWzB/JBXZyzi4zKfbqkWopC EWBkdI7t+P3h84fCBgoCPc7DdVdzZISjipoVlAqK0dP4HE74nwh+WV53rwlAfkDqClAj bwuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812304; 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=CMWr8hu2DUhhMopayYGFX1AvPPyHQPBspx9QuL7Pv04=; b=bFAqqcUtJ0fX5Bw3p/aLHopJjkV4xy3om6ZGcTYhXkA+Ba4MvIb3PDwK7uYTnO3ISx gOp//HGnKKVABLpdZ5oqA5+t9y9lafAdAOAwuAeCijToeXx6CTvmk1DSmcfKec0JctyF +E+ljMDARQdABYr6UVQGvRElQSX3vkx1yooVLgm1E/CAgCbzjcdzx/0bBqQkdlbftJ1n HY+bw4cUpIGJWrhg8Y3m2SqrBLDAxLigQn+mZniN0644Rp8ydPBxul0ZxlauBIMh3CsT FIAblcL2r5r2CSwMJy34Ltp+BtqyeXhecR6nJiJg81Yzb2FfiImcpLpkuNIMSHKqQb3D vY1w== X-Gm-Message-State: AO0yUKUeB0oqPRFyc+vDZFQAH3uHEeYfjax8ZfP/mrZzqUYM/5tlU7V8 L2rCprKFHoVOG1mBCaEMnvKZhGnJ4vIdJ+zWohk= X-Google-Smtp-Source: AK7set/Bx6JBJe6yhKwtyB42wq4fzo18J3B8PnuyFs//nYSIKuwhdd33A54kKBUz9poPxMLfGy+kkQ== X-Received: by 2002:a17:902:8bcb:b0:19e:664e:fcaf with SMTP id r11-20020a1709028bcb00b0019e664efcafmr546141plo.0.1677812304142; Thu, 02 Mar 2023 18:58:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Taylor Simpson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 20/29] gdbstub: move register helpers into standalone include Date: Thu, 2 Mar 2023 18:57:56 -0800 Message-Id: <20230303025805.625589-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: 1677812441066100019 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-21-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812547; cv=none; d=zohomail.com; s=zohoarc; b=JnEk17eZzaddHMU4NI1kzgk9x3e2s4DBfWkfVCWI5OAwoViEnLVB0yr/AxsW8nEJNolKagnwc3MqH/6lgTGrByPoGbLxADkrqCFydheaVleILXetbZcKjCwJzS5iFdtC+k/9FBoyO06h9Z3f/+pq3Jb1wGwMJwgqNwDVQUsdgR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812547; 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=oTgZp/DZKamIAO2jWKpBJfhOTy0YYMt8DRlfYchj4Zw=; b=jiwegGjToX+gEBd/JL1LqJ14CetK7wWYQfnGiT1AqqiCww7xKyQCjaHyHpjIYtwCCzy3aTWDNK3xpPCJnR8i5npAXJMVQ3Q9hp5K9DyYLXD0VZZRt2EuaJUrKEXL29gnYri3hz//bOd4MS9ZTPNTuQY3e6u2LMAdzrej8yuTVoo= 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 1677812547934217.72933828167072; Thu, 2 Mar 2023 19:02:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvct-0007bx-Vt; Thu, 02 Mar 2023 21:58: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 1pXvcs-0007ac-6x for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvco-0001tJ-RO for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:29 -0500 Received: by mail-pj1-x1034.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso947927pjs.3 for ; Thu, 02 Mar 2023 18:58:26 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812305; 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=oTgZp/DZKamIAO2jWKpBJfhOTy0YYMt8DRlfYchj4Zw=; b=nqWBY8yVwX3rT6bnvSZ2VdW1YMPRcNcjVOtThI5QRQ/1x9BleEIXpLPx6JMITW7agb hXDkMxZ8U93XPcxeEb5zq9OTyLY4OlrMo7iLaw6gTRBU84HrxXSobReFpeWRuZ7gRnQ5 iYZthb60r8oukvF4Q040Y2gNoH0sVbSepWObCyacunHPAHlDLOZUbKDYR+29CdoNVgi1 SFOuI2Av3m4BC6w+012Z3Vk/pUTSAoOC4pb7UHLFEDCe7SU60sB7Cu81w6N5AZrTY8vI /z1+shOI3F+jjWSsj+CSZF/ywrkEZDqL2RjSm1QCf2MXj4U9ihvMvHPUHdvxKJyPGw36 IwHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812305; 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=oTgZp/DZKamIAO2jWKpBJfhOTy0YYMt8DRlfYchj4Zw=; b=O9jJGgO/3029ihcriDJ6MvgsGrMXAxLSVjcGzpltxevMH/3xbYjuIF3qMzKh+UtzQR VT3wlo0+/H+21ODc9VH5zjigE4gRXpNBkXp1tbkH+m3KTPH7LGKaUsoStsHydrN0+ZfL ILBBelictljGtR7rVXPvCXIG/ZDhg5w5kcRggINf4SIn/0zkszNPNggElt/nZufqRJHw dSK7ywY5Z0gjmz1b68Mw69frldOml45GFJvdH1LneKkfuWrWwa84K39/P2NqdGl948Ic scDzFKAjkx8VhyXlWQjnpGEc3e4+OkuDRLjIE9vYJT5PVqNOsEomGcKr4SVeju4SKf9v AySw== X-Gm-Message-State: AO0yUKVuN3715K1Njy+ispCgzw0nCo8mmAbeedSnTz+14niRZTt4D4Mf qmVwo8Z/gfdnaZIqRRQ6o10edSIWYAavoeHEIsk= X-Google-Smtp-Source: AK7set+bSrR6N5cStiRrkQYQdOoYbDsl5MfgH23GW48szMZiGg1vtL5Rk2UyEAgUj1jkMI8PZFeakA== X-Received: by 2002:a17:902:d48b:b0:19a:7622:23e5 with SMTP id c11-20020a170902d48b00b0019a762223e5mr715260plg.4.1677812305031; Thu, 02 Mar 2023 18:58:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 21/29] gdbstub: move syscall handling to new file Date: Thu, 2 Mar 2023 18:57:57 -0800 Message-Id: <20230303025805.625589-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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: 1677812549763100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-22-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812540; cv=none; d=zohomail.com; s=zohoarc; b=TWjkv7FiEJ90AkpkUCgugz1mG6N4ZIfSEmdVdE2Z2DoX93BFM/gK7K7jEWXPT/sVHvav5DgFuUFkglJCGobIU3tt4LMTJXYy7OqbSzZkpl2SPOYkFAxhb48F72pTVaD20ghge3RsAfncnD7tc9020fEXh9njRnRIHe8R0SvwiY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812540; 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=pf0gnzU22Lq1Q1Kv39Okh1QPjAe7PNl3a36TYlU7/jI=; b=XbhcIeUIcYv1LBFbj/HJFXopDWywEuWvNerIa3Baa7bds/DakbS6TcFM9+TVu9tC3u6dMQp1qvwzSm9MgvNKnjnwGH+b1eXADVybSfxw+02NZljzqODuERQXXYcWujA1XX8771R/9+90U+9SZoOR9mDvqEs1205n8gW7LFNIOHw= 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 1677812540261933.5479631017066; Thu, 2 Mar 2023 19:02:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvct-0007bN-Ae; Thu, 02 Mar 2023 21:58:31 -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 1pXvcr-0007a7-3B for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:29 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcp-0001tO-A1 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:28 -0500 Received: by mail-pj1-x1035.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso947939pjs.3 for ; Thu, 02 Mar 2023 18:58:26 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812306; 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=pf0gnzU22Lq1Q1Kv39Okh1QPjAe7PNl3a36TYlU7/jI=; b=VF7U7mEJYwo4wJH8QP5k/Lpj5n48C59nIe3K1GWafjnexVPbchkUezF9lbR1RBhODF gXsWtCoFvnpo5H/e28jBCiSX+pG6UT7cMRa6Pxlt6+OvWfVVapKxLob60NiD1GK3PlIV nVt2ewVwq6Wj0Hv9DffOab0tHHvxnFYnPwJ4Bvj429A8G3oZweIsZTVMM0WTrdQYs8b5 2F2x35daleTzlrRwKkAcizkoVyTQKscOHTmR++Dw+RdWyYQtcV+8xhpJKoS1Jka5w5ef jFCnUt3zlXhjSDp5Tehc6cRHxa1gGCtvgiaEphrjKLx55YD8wyc+OsOXMgzWMerrFn1B 5GQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812306; 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=pf0gnzU22Lq1Q1Kv39Okh1QPjAe7PNl3a36TYlU7/jI=; b=dU+9r1QKL8vMFS8I833CIqVi2sjoykFHaxa4BqdjjQH4yRbAKQAhU65PwgzRTEBtsT 5Dw+XfFhPnluPHpbsRitXWxxjrzDOTWLjWZ2kXb59wOSKVfosMA33JTwIKEi4Y1cXcTI gxFpADONdlkSs+W31VyeNnNIgaNSnXafb4nmyRUCZuvr/45UolulPXANwTdGuoUPLHFj cVt3R4rOI9Xh7z8g70s2WU7W9uAbEEY8XCMo8+8fz/pm/U4TSr/fiV+LVJxArQ+Xe04I Voe8LoyrBPburdMJ5xXbLLu8sJInCUjMERRa4CFlPsOUrCTTOkp+5HklChE4oJGcdEm3 R52A== X-Gm-Message-State: AO0yUKXNt7NpmlxrfmFSJtmAi0f+PUSUI+0HFpaNIHYrJdhXRximFbMq 5xlAYmCQi4VmplsN7F4A5MjSM/jSc/uJwR0P4hg= X-Google-Smtp-Source: AK7set9JD4FPlRqTLoZGX/aAidM8OqSBV2YX4Mi5k7GX1QIJ36+ymxpE9iqHJyDwjIlGEcmVMApkXA== X-Received: by 2002:a17:902:d4cc:b0:19b:dbf7:f9ca with SMTP id o12-20020a170902d4cc00b0019bdbf7f9camr805339plg.0.1677812305829; Thu, 02 Mar 2023 18:58:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 22/29] gdbstub: only compile gdbstub twice for whole build Date: Thu, 2 Mar 2023 18:57:58 -0800 Message-Id: <20230303025805.625589-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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: 1677812541666100003 From: Alex Benn=C3=A9e 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. Reviewed-by: Richard Henderson Signed-off-by: Alex Benn=C3=A9e Message-Id: <20230302190846.2593720-23-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812426; cv=none; d=zohomail.com; s=zohoarc; b=oBZiB+NU/+A/jyAw1DlLQafz/0W0v/siazVuiYlWlunJi0Y6eUneMZIN1g23NpxTqHsWTFn1xW+NhPB6ztozltAKn3QeOdDzsAQjcfUgC5L6lqAT5otonaaLdJEXWU0OAZBbJjPUbeRYArRnaZAKPSDC4rKX5Us4queYuJtbC4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812426; 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=DyucSr1+mDuhxSYgjTJ7OboyUx9A5mZckDpsrPxpF7I=; b=lfN7gcp/ASRYn7uexoUbAnSGC54DLoEqmcnOqj05XxU9DNOYVfUhyvkdu51N16xpIr4UxrPE7T19z9OUgEyXiKW4aPCjAEJZPi83s3WHX96SrB0JZhuvBneDFBFuidkL4C/RWyV4819hAD6lRk80lz1+WK6ZduF/Kbcd6tZOSbw= 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 1677812426550487.7732476235527; Thu, 2 Mar 2023 19:00:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcu-0007cH-HX; Thu, 02 Mar 2023 21:58: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 1pXvcs-0007b6-Qq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcq-0001tX-4F for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: by mail-pl1-x62f.google.com with SMTP id p6so1415782plf.0 for ; Thu, 02 Mar 2023 18:58:27 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812306; 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=DyucSr1+mDuhxSYgjTJ7OboyUx9A5mZckDpsrPxpF7I=; b=KfqJioYD/XSiAq/2scJYp5XLqWjcGKgbbCuVRIRVRkMQDXwNJbTnRZXEg12a9hVJ7N 4SBvdN06vI1YdN/wrIqb2YPpQsGjV1fnm9rL897dxRnpbLGC7l5Byn0bxzSE0BZw36fM zThfYBVEiVcs4QpybbnmxclbtoEiHv27Oj9Bn9dQw+OR2kbKYS7krz+nPUtoioUsZNf6 IqRk8W7lwJolVwFk+Ex4zuH5T55CozrCrJTOgp+xAK2SYSWDlrTKcnP/lIYSUG8BQfWj 4+VcH3J5zMzvpeG2kfb8SsltiIYQK4kiM1et2G6dvXRf+PSiDM/yWTiGVBIQw/zvwAKi K4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812306; 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=DyucSr1+mDuhxSYgjTJ7OboyUx9A5mZckDpsrPxpF7I=; b=uED7xHlqoeIdS2uhxbsUGp1KTEfs/xeOGE0o4T+yq+BFMAl3ix29l4tJ6VhJ+eoGqD wLYhcJKoRE8tl8u6bQHzyeGozke/AeF8v4GN1IPcWh+fM0R1FMdsgdKYN/oyAMVwCcJ8 Jwhy1U7lv4I8Qu/SOn+QQtkyfyyJ7j9N9QY/qMA0Tc14ZSXmkOv4ncbwOOZC7IEDTCHx ADnkXG4W+i7GwiYEUUWuSnebYFfHvPzoxTd0SM3VgrgvSVnZUjbWqSZ2Xy6g+UwqubrL eN4nXtkFqq65TGx/j9ZIsttcRzykVfZFEbbJ1qAZX6tREpX1tgBsEgCJQiux7GXb0cUu JQTQ== X-Gm-Message-State: AO0yUKX042Yrq2tHnPoGkLn03R3gT9QONbXAMQ5OzmLeJObX+0ml2PGJ keaH6GcP2ZO0erXMiyeay3gMHnZJYJTmnJi03/g= X-Google-Smtp-Source: AK7set+mmShR/sJaMOQATibbNjVAmq56+WuuDAkX7j+1taMHtu0d1SpuiYWO9BvEN/NGHMpJie6H9A== X-Received: by 2002:a17:902:e5c8:b0:19d:1dfe:eab4 with SMTP id u8-20020a170902e5c800b0019d1dfeeab4mr529330plf.41.1677812306558; Thu, 02 Mar 2023 18:58:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Paolo Bonzini Subject: [PATCH v4.5 23/29] testing: probe gdb for supported architectures ahead of time Date: Thu, 2 Mar 2023 18:57:59 -0800 Message-Id: <20230303025805.625589-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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: 1677812427010100001 From: Alex Benn=C3=A9e 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. Cc: Paolo Bonzini Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson Message-Id: <20230302190846.2593720-24-alex.bennee@linaro.org> --- 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..35219f555c --- /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", + "Loongarch64" : "loongarch64", + "m68k" : "m68k", + "MicroBlaze" : "microblaze", + "mips:isa64" : ["mips64", "mips64el"], + "nios2" : "nios2", + "or1k" : "or1k", + "powerpc:common" : "ppc", + "powerpc:common64" : ["ppc64", "ppc64le"], + "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.34.1 From nobody Mon May 20 01:44:46 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=1677812511; cv=none; d=zohomail.com; s=zohoarc; b=iXNB1wPKCugowZayU4mc/fgU0r1hvf/AyuuuMuW4Zbie6RwYHcXtfy/3h1iDfsraYSRC4fjClVnzYeHmDgpzicMG/H79dpsZPLEXL5YU48z1ymTTpgU44KVbaEsEqatZ+xVrDDyvoJKv30PgAXHMP9X/BMs0/6WwURFMvyVpqHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812511; 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=KRaITTDPU/D6klVb43sMtjcQy7hN+w0/N4+Vvipb27U=; b=huFF+BnYIF8uo8P4Ni0Pd9Ythpq0tchpBsgtwIqhtiNYXH5s9sQ9n5mCcLGC1dFwtNm+nAVu3RpYGg+qxDMS9Et3h1DRDrAnqKDrgn0AgZBVzZDTmDGUiBFee6H/y/kHOgVcJqtGtP9wDz2e71oAZNBc8ZAqiUsSNlSlh+ew0lA= 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 1677812511943735.9981639234708; Thu, 2 Mar 2023 19:01:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcu-0007cA-Cz; Thu, 02 Mar 2023 21:58: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 1pXvcs-0007ax-J4 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcq-0001ta-Po for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: by mail-pl1-x630.google.com with SMTP id n6so1349585plf.5 for ; Thu, 02 Mar 2023 18:58:28 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812307; 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=KRaITTDPU/D6klVb43sMtjcQy7hN+w0/N4+Vvipb27U=; b=gp+rIZITTpoVxoZKl80/YVSUEdXSkc1kvrWIKz/5Jj9skHq5OWGrmscm6uuN8bP0bl 8QGo/BGPaPzvMeWWgzCz5HqzFPnMb9n9duFJ8uG/9LughwRXvI+lP5G7XMNAbTORHTnG MgH1W2fsbzZiPhmWvvYHgXp7jKC6U6kxfjB51N4Zh/iKuTd9aftisZOgZWdGfc6SqYbo mBSb0AX90zOLUAFyDKlHuNuFeF8HLy3/Gf5zLxY9PhbtIAX3dxUwQQ4mxKRKwWyTFjkn LtDP0OKRnSHhx8gph17UTIgE6YnEo2JKnil5Vn7jsJNO665/LaLfNIrI+6doporIpCUz M+Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812307; 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=KRaITTDPU/D6klVb43sMtjcQy7hN+w0/N4+Vvipb27U=; b=2i1tWpDBdObyEtPi1mQtPRBWtFEy+ICeieYnvAh0/DMFU+X3MGG1wfPQHzZ7UsFFk2 UEj+kxtTzKrl5tSEccrkT32Ml5iuXLmYY82Ra1mdKuWHgA3zi+6JYEWPpj/101RhJXNU D1IB+exLLJQ0MBU2MqLkg/cVb86IgGx8/SNv29LBGnyHcUTQLjefzA8CcyfeF2J8rNsF KHJOFL75TXv+YDea0DHcjWkuKp90ADIPOwIo8mzK4gx/dN1zYtm75zxeCny+/QBqStPG h25Fr81VW28RRQ7knO6yzU/iuYjBsVHsebEQyKpK1raBqNbDbd/BLguV42ZW3ixEkzKC s5Wg== X-Gm-Message-State: AO0yUKWkILSFz8+JVpgLFAC419HuMBQvL6JfnFBOPu+QTUNPUrrbn5hI xOGlzSvUS5mJJ+XL2kq9IFnxaH6P3S7A4vzuzOw= X-Google-Smtp-Source: AK7set/hB9m08UNthc7Ug26KRkEJKbIOErC8PshPAwWzLYOT8LqwBllzuPrsKL18Dg6PXoGZJvTG8w== X-Received: by 2002:a17:902:db01:b0:19b:c37:25e7 with SMTP id m1-20020a170902db0100b0019b0c3725e7mr431698plx.66.1677812307293; Thu, 02 Mar 2023 18:58:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 24/29] include: split target_long definition from cpu-defs Date: Thu, 2 Mar 2023 18:58:00 -0800 Message-Id: <20230303025805.625589-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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: 1677812513557100003 From: Alex Benn=C3=A9e 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 Message-Id: <20230302190846.2593720-25-alex.bennee@linaro.org> --- 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.34.1 From nobody Mon May 20 01:44:46 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=1677812438; cv=none; d=zohomail.com; s=zohoarc; b=OM7ww5fNmAht3RgUYylp6/GQx4SRWJB+hngA3k8NSOaiBgrVVgGXpeZENYXfC9EuRmo7UsyNVQJ2bRVuDtHZAFs1tC36AS7VjTQiFEyx/pZkJElfgLg82TXCUetupLfEfBhDZzi+A9CmxagdnST8/rD5V9HQkCu0paM/mG9y1wI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812438; 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=6d5cuY6swY8U6e//2djcuW9/WFKA+am2NtOsQtC3Xo4=; b=dxmfcx/hMajjR5pgtWWGtrUrIbpNqXzjzi8CaqPINNJyG/v8gVDUudP55Mp9cPGHFPD9rD7jnpNLGtDskL8Jqd1v1OSmJAslstu6f3NeqsKTYdF/h5p9ORYh9bnYiUHOlxHuMbaRW+A5tk3p7fE90zJFG7RylmTzbGS6aqpJ7Cg= 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 1677812438071209.03481492739445; Thu, 2 Mar 2023 19:00:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcv-0007co-Lk; Thu, 02 Mar 2023 21:58:33 -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 1pXvct-0007bf-Ld for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcr-0001ti-Gs for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: by mail-pl1-x631.google.com with SMTP id i5so1367106pla.2 for ; Thu, 02 Mar 2023 18:58:29 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812308; 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=6d5cuY6swY8U6e//2djcuW9/WFKA+am2NtOsQtC3Xo4=; b=hHYpkzksNrat8BA3PYARXUxXH1R2SflMSwePo8EImrDoYFC7kji1Qrr1s5RiiWlLdP 0PiomXrDunwVCrl1ueWvL+gIDpG6WeA0NHhPyihQZGXfCw/rYojzwc+NlVq7M7nU3wUM R4gOAPS3cYatrV5f87UDnVDmKmM/r6EOb+TMDd5s2GkN/bcR+k1q1knLcieuhJX0JXFS fbearFxrPbv7clLpMxxFocpflLxxQaBdNQhLvHv7jDCwgdjTJtTrRMR+5jjGb1AuIbQv GxqpdyadPNuGmK9L3RVyPdkMNGbFFuT8WgF6Ckb8KwwzfpUUsCUou6A4Z3B32mSDwGxq ALPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812308; 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=6d5cuY6swY8U6e//2djcuW9/WFKA+am2NtOsQtC3Xo4=; b=c2NZ66fNXHZvjx7duhqEKY1qLRKQ2qtqpJItDO+15t+jbhrLYrodBhTQl33EZOvnG4 Is+pW89l+dsIRTwvzypaivUEuvYcgLmUqo3qRXjKSIOB+qsOLMWrofS3MhtYk5q2lRs/ aaESDAnZCpw9C0fUzOFwcRDN35OQvmuTZwR8v//WO/cp20BHowflaBP3z/RogjO6yiWC LEUhLo8Xh7lZi0rFnFx8UX6h1nKRLtQhGo8LrE/onXqRgoK8XZrkD7IcnWjX3lACj5kR DeLEl1pgz4zyA2JmyU3pI17boKA64cTvsI09RA/7qayNXaLsuEu87paEvVTtTAD9hDvf JyZA== X-Gm-Message-State: AO0yUKV7tbF9oqWq4kUNpzpVwsJR1uHJ1HJ2YzRw/RZMbPgm7O8lEUoL 3qWIKRHJf4TCY+AueZ1EVdX9cln+xTalILSg+Jo= X-Google-Smtp-Source: AK7set/0SYfzKFP6O2Br6mI7iBNZfVsZc2EXbK6etfa5w7oaW1B9KUff7WM2wVHuKbx7Z2F5Dc6CSw== X-Received: by 2002:a17:902:8bcb:b0:19e:664e:fcaf with SMTP id r11-20020a1709028bcb00b0019e664efcafmr546260plo.0.1677812308062; Thu, 02 Mar 2023 18:58:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 25/29] gdbstub: split out softmmu/user specifics for syscall handling Date: Thu, 2 Mar 2023 18:58:01 -0800 Message-Id: <20230303025805.625589-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: 1677812438989100015 From: Alex Benn=C3=A9e 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 Reviewed-by: Richard Henderson Message-Id: <20230302190846.2593720-26-alex.bennee@linaro.org> --- gdbstub/internals.h | 3 +++ gdbstub/softmmu.c | 14 ++++++++++++++ gdbstub/syscalls.c | 27 +++------------------------ gdbstub/user.c | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 8db61f7fb4..94ddff4495 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -195,6 +195,9 @@ bool gdb_handled_syscall(void); void gdb_disable_syscalls(void); void gdb_syscall_reset(void); =20 +/* user/softmmu specific syscall handling */ +void gdb_syscall_handling(const char *syscall_packet); + /* * 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..22ecd09d04 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -103,6 +103,20 @@ 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_syscall_handling(const char *syscall_packet) +{ + vm_stop(RUN_STATE_DEBUG); + 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..0a48f58d70 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -104,9 +104,7 @@ 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 + 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 +139,8 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const= 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 + + gdb_syscall_handling(gdbserver_syscall_state.syscall_buf); } =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..80488b6bb9 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -472,3 +472,17 @@ 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_syscall_handling(const char *syscall_packet) +{ + gdb_put_packet(syscall_packet); + gdb_handlesig(gdbserver_state.c_cpu, 0); +} --=20 2.34.1 From nobody Mon May 20 01:44:46 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=1677812461; cv=none; d=zohomail.com; s=zohoarc; b=CMQHyNASAfctGZ2TUgm7RszyfKSSdQiNWosA/+GN8MvumB7cA+Zh3lCkDPjd+Q/WmBa3SdmABhSrUx1prLNuO183+yX0n3WRKZ3uh6sK8Z3srLBX19TbUOYcGAHQOLL7XJqi3kXuo2yBY4AKUa+whh0f6a7/u5lZlxuI90LVgE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812461; h=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=CWVGvsm0VObLmtXd6+IOdcWIt2VbqCAgLdqZOqtIWuY=; b=SXk30NK+OfI7quaYbOnRFrNJ/w8VwjSFq3WA5TIHY0cz5mTcWp3SkGfYU9moLENInMMKAR18gThnz/3O9m908uMSZ3dsRAmwVNa4smKtiooavUQ3b6+35CjS8TbqC4jovqi2XzzInxv/NZMF1BHuGDkvyXCWotRhPPec7XuLnQo= 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 1677812461358625.170330588875; Thu, 2 Mar 2023 19:01:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcv-0007cJ-0m; Thu, 02 Mar 2023 21:58:33 -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 1pXvct-0007bI-4r for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcr-0001q5-H0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304391plf.12 for ; Thu, 02 Mar 2023 18:58:29 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812309; 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=CWVGvsm0VObLmtXd6+IOdcWIt2VbqCAgLdqZOqtIWuY=; b=IYGO5mGIcZ7UaHZbX7HYumvxijAinMeQIwqDcOkL3c0sUA+tSZdLz2l+gC0QSVBgrE MWgoihozps1NJ6dgAvPq0LpMl7yuVdiPBWPHOkii4CCiH7kwERVgeS9U3seQ2FJjhNfm 4eunSQprzqSB+jaaduU0G+7w7i0vkGHgozHiQMMwjQv0AvwUEjHtZW0h8dago+U0bF6S RZ3/lD9qTY/kXQ1cCVTyggZCIozem47t1ixLTajqwMVrUhvUHtSNQR8S4QN6YeRTtzHe D4yPs2/raZYDzBIF19TyXZlZh+YBN+8TLMPkcKkQs+bNvNjhgC5uhcnHjQ4o8jR7fkg0 zwcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812309; 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=CWVGvsm0VObLmtXd6+IOdcWIt2VbqCAgLdqZOqtIWuY=; b=5eMT7QT8WnlSFjHCqnYG8qjA5ujt/HK0aaKp+lEJ1CbGIA2Yc+JN2NY2Haau3ZQJjN xXks+vlNIHl3mnh4zp5yUxu6yQ4keA/2BX1fD7nOf42aB12nR2j2AFIIxlG0qn3waQ31 dLODZWS0EWOSjAqvtZLVsm6vY21sgifXQEPrEExaVW2xg3oE9g6nH6HwZ0L5WStD2y/T h7Az98aiHoOi9QyZ8nRBNGUMqbqgX2pQ1ETyBhnwmHwK5fQfH3WYcNmooZEAjfwn/O4S XpGf/rSOoRqc32iWdZK4qUkzKYwLZTmOsEYB5Dfhg5cPXPS0mk6c+RSAzdkfayDZLZId 7iTw== X-Gm-Message-State: AO0yUKVxHJMNF9v7xIfBHC/y0Syh1Fq1xhRcFA63Lpe/vuy8DpLbIxTv 7ICjWlSNG7gIfhapCpZ73fwDcXDRTOI3cJsBEvY= X-Google-Smtp-Source: AK7set/AN4PYG0XP2E77dSaT0E6qT/LEjAb080Sq4Srmruap/D3xERkzuGa/kNwHr+gqGzLTEAKbNQ== X-Received: by 2002:a17:902:d54f:b0:19e:73a9:c21b with SMTP id z15-20020a170902d54f00b0019e73a9c21bmr516795plf.45.1677812308751; Thu, 02 Mar 2023 18:58:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 26/29] gdbstub: Remove gdb_do_syscallv Date: Thu, 2 Mar 2023 18:58:02 -0800 Message-Id: <20230303025805.625589-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: 1677812463054100003 Content-Type: text/plain; charset="utf-8" This function is unused, except to implement gdb_do_syscall. Fold the implementations together. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/gdbstub/syscalls.h | 11 ----------- gdbstub/syscalls.c | 26 ++++++++++---------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/include/gdbstub/syscalls.h b/include/gdbstub/syscalls.h index 5851a2c706..243eaf8ce4 100644 --- a/include/gdbstub/syscalls.h +++ b/include/gdbstub/syscalls.h @@ -91,17 +91,6 @@ typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, u= int64_t ret, int err); */ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); =20 -/** - * 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 * diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index 0a48f58d70..af42e244f9 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -92,24 +92,26 @@ bool gdb_handled_syscall(void) * %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) +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) { - char *p; - char *p_end; - target_ulong addr; - uint64_t i64; + char *p, *p_end; + va_list va; =20 if (!gdb_attached()) { return; } =20 gdbserver_syscall_state.current_syscall_cb =3D cb; + va_start(va, fmt); =20 - 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 gdbserver_syscall_state.syscall_buf; + p_end =3D p + sizeof(gdbserver_syscall_state.syscall_buf); *(p++) =3D 'F'; while (*fmt) { if (*fmt =3D=3D '%') { + target_ulong addr; + uint64_t i64; + fmt++; switch (*fmt++) { case 'x': @@ -140,16 +142,8 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const= char *fmt, va_list va) } *p =3D 0; =20 - gdb_syscall_handling(gdbserver_syscall_state.syscall_buf); -} - -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_syscall_handling(gdbserver_syscall_state.syscall_buf); } =20 /* --=20 2.34.1 From nobody Mon May 20 01:44:46 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=1677812448; cv=none; d=zohomail.com; s=zohoarc; b=Q6ZlKDlwUMN1MEfMgULYm7SAKrfUdaMO6wiaPfvLsUrOzYKH3g9hCkrelOO8QtMe10LSUyW8d/XKhvVrZrQCf8MQA7N+h9jVAJUmL2my5Csm2oy4YTbGJv+Kh3ZiYa7rTYJ3BHQj65lIZVo2pifS9eWfCLxGvfArHmq3lqSf+ww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812448; h=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=kpo/p9yzI64Tx7SaKYcCkvRfvTqYOcBW+5MSbV4gbos=; b=XVsdpjOQYME0aLkKae3KkcyZeYYEhrIUsUWiCLocik2QogSjB+3iE0NKcGzrKMI67OSvJeUj514i1GD3W8qZJUT8uMiWlr8vv5MpUqWA8Frg0YWyJTAiKhN2rEpAbk2Z0Ig+6OyLZ8ZQJ3duoXTSdLCb+l6XalJtn0eEO1+UwlY= 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 1677812448493854.4038285156083; Thu, 2 Mar 2023 19:00:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcv-0007cL-4T; Thu, 02 Mar 2023 21:58:33 -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 1pXvcu-0007c7-7g for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:32 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcs-0001qG-8P for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: by mail-pj1-x102d.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so967885pjp.2 for ; Thu, 02 Mar 2023 18:58:29 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812309; 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=kpo/p9yzI64Tx7SaKYcCkvRfvTqYOcBW+5MSbV4gbos=; b=I6fkVpJUcgLB0yPqniPC8TiaQMFcnbl/WJ/GKCyxW/t+JwQOLwnlJXg1rGYcKsYiQT NK1E1KxHEOCUkKEK2son5OOPX4XdMtatq+Ot1wPsihtOtYDZiuuLeLcs4ckvR7S7IBja B8LWpnh6gAmNkv69ff2icYijrGhCm+xMe7PEvQ5626CnzAWufGydPe2nqa2+VlgkB1jg 9bTDjyUq0K+oDtHdL5649a2w44cBEUdrf6y4m3viTc8pk4Rdfh0X8mjpOCKq+3IM6BYM 4ahS9ZMYUAjx95SCLrft8gpKapTHF7Z8JR/iQjk/YQf5u66J6GFk7Rx5mVIUV0l7AFKP a8mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812309; 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=kpo/p9yzI64Tx7SaKYcCkvRfvTqYOcBW+5MSbV4gbos=; b=HEzygRGDh/dhtw8p5yl4kqewsCiY0+Z9n7LgdgzWOlT6kps0u0fQ7N+MIDlKEtOdwp Cxep17CEZ9L97Dz0tEV5c2xRaUMQBBNuCEASMWsTgLXNl79RwDHVcPJ1iqAk9Q7uTskD WoxvQxJsfwjDYoIGZTGKRA6mdiRPYAet3gD1pUmMM8bFsBsKSNkfiKLSqy8nOwnNkane S63FnFjy70ibHZYfMmcSt1Ftm6EDo2v4cVloEIQx02A6z5mONCqnFvcZw0T9WnC7rUR5 dK8tvb8Tl5pMh128sM4NIQ+wCewkr8XqDvRVrFUw91n7sI4p9npBmdmlFNpqbXOF29K9 z+Tw== X-Gm-Message-State: AO0yUKUxbn+e/M8UthftnNpc4ndFtpWTnLH7FFLIzbeIKTVWFqWOtx78 kMrljcpIiCHMWFS9PtLA2akDiyNMaelUZMW8GV4= X-Google-Smtp-Source: AK7set+7R1Wr1z5Sp3h1IUokP/iByz9YqafmmyADgLnR1SbmDsnsfLtsczeaGlQeWLa6YKpVjuo78g== X-Received: by 2002:a17:902:c10a:b0:19e:7b09:bd4d with SMTP id 10-20020a170902c10a00b0019e7b09bd4dmr447039pli.47.1677812309490; Thu, 02 Mar 2023 18:58:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 27/29] gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t Date: Thu, 2 Mar 2023 18:58:03 -0800 Message-Id: <20230303025805.625589-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: 1677812449106100001 Content-Type: text/plain; charset="utf-8" Pass %x as uint32_t and %lx as uint64_t; pass the address of %s as uint64_t and the length as uint32_t. Add casts in semihosting/syscalls.c from target_ulong to uint64_t; add casts from int to uint32_t for clarity. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub/syscalls.c | 12 ++++++------ semihosting/syscalls.c | 34 ++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index af42e244f9..b7d85c41c7 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -109,14 +109,14 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const= char *fmt, ...) *(p++) =3D 'F'; while (*fmt) { if (*fmt =3D=3D '%') { - target_ulong addr; uint64_t i64; + uint32_t i32; =20 fmt++; switch (*fmt++) { case 'x': - addr =3D va_arg(va, target_ulong); - p +=3D snprintf(p, p_end - p, TARGET_FMT_lx, addr); + i32 =3D va_arg(va, uint32_t); + p +=3D snprintf(p, p_end - p, "%" PRIx32, i32); break; case 'l': if (*(fmt++) !=3D 'x') { @@ -126,9 +126,9 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const c= har *fmt, ...) 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)); + i64 =3D va_arg(va, uint64_t); + i32 =3D va_arg(va, uint32_t); + p +=3D snprintf(p, p_end - p, "%" PRIx64 "/%x" PRIx32, i64= , i32); break; default: bad_format: diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index 42080ffdda..68899ebb1c 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -139,46 +139,48 @@ static void gdb_open(CPUState *cs, gdb_syscall_comple= te_cb complete, =20 gdb_open_complete =3D complete; gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x", - fname, len, (target_ulong)gdb_flags, (target_ulong)mode= ); + (uint64_t)fname, (uint32_t)len, + (uint32_t)gdb_flags, (uint32_t)mode); } =20 static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf) { - gdb_do_syscall(complete, "close,%x", (target_ulong)gf->hostfd); + gdb_do_syscall(complete, "close,%x", (uint32_t)gf->hostfd); } =20 static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { - gdb_do_syscall(complete, "read,%x,%x,%x", - (target_ulong)gf->hostfd, buf, len); + gdb_do_syscall(complete, "read,%x,%lx,%lx", + (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } =20 static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { - gdb_do_syscall(complete, "write,%x,%x,%x", - (target_ulong)gf->hostfd, buf, len); + gdb_do_syscall(complete, "write,%x,%lx,%lx", + (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } =20 static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, int64_t off, int gdb_whence) { gdb_do_syscall(complete, "lseek,%x,%lx,%x", - (target_ulong)gf->hostfd, off, (target_ulong)gdb_whence= ); + (uint32_t)gf->hostfd, off, (uint32_t)gdb_whence); } =20 static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf) { - gdb_do_syscall(complete, "isatty,%x", (target_ulong)gf->hostfd); + gdb_do_syscall(complete, "isatty,%x", (uint32_t)gf->hostfd); } =20 static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong addr) { - gdb_do_syscall(complete, "fstat,%x,%x", (target_ulong)gf->hostfd, addr= ); + gdb_do_syscall(complete, "fstat,%x,%lx", + (uint32_t)gf->hostfd, (uint64_t)addr); } =20 static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, @@ -191,7 +193,8 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete= _cb complete, return; } =20 - gdb_do_syscall(complete, "stat,%s,%x", fname, len, addr); + gdb_do_syscall(complete, "stat,%s,%lx", + (uint64_t)fname, (uint32_t)len, (uint64_t)addr); } =20 static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, @@ -203,7 +206,7 @@ static void gdb_remove(CPUState *cs, gdb_syscall_comple= te_cb complete, return; } =20 - gdb_do_syscall(complete, "unlink,%s", fname, len); + gdb_do_syscall(complete, "unlink,%s", (uint64_t)fname, (uint32_t)len); } =20 static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, @@ -223,7 +226,9 @@ static void gdb_rename(CPUState *cs, gdb_syscall_comple= te_cb complete, return; } =20 - gdb_do_syscall(complete, "rename,%s,%s", oname, olen, nname, nlen); + gdb_do_syscall(complete, "rename,%s,%s", + (uint64_t)oname, (uint32_t)olen, + (uint64_t)nname, (uint32_t)nlen); } =20 static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, @@ -235,13 +240,14 @@ static void gdb_system(CPUState *cs, gdb_syscall_comp= lete_cb complete, return; } =20 - gdb_do_syscall(complete, "system,%s", cmd, len); + gdb_do_syscall(complete, "system,%s", (uint64_t)cmd, (uint32_t)len); } =20 static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complet= e, target_ulong tv_addr, target_ulong tz_addr) { - gdb_do_syscall(complete, "gettimeofday,%x,%x", tv_addr, tz_addr); + gdb_do_syscall(complete, "gettimeofday,%lx,%lx", + (uint64_t)tv_addr, (uint64_t)tz_addr); } =20 /* --=20 2.34.1 From nobody Mon May 20 01:44:46 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=1677812392; cv=none; d=zohomail.com; s=zohoarc; b=Nzq6JBwBFCh0ZxaVNcRuLEGZ+SRie9CrV0+Aq9rh8B/Y05j8hQ6pI2O1OIBLYXYDNvzluIQOnPyk30O/FJ2bjFpJXvSyiJKOnDkaDp2zgFVfYuKP884fRcIIQoDEcwzPQWjAh+jBXySpUVSxqs3pcWdF0+8peZRumwJUj1KPIvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812392; h=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=uL8gPV4GfBPCsX5yefLxqBJp76wGELs04Du3rKf0/lI=; b=TObkF+norITgpQ25aBBhdiFEmKS9L3mlCNKN0esE6LHAEjPeJ0dnTN+26uw04QK4PoLpOmKU553Gt07GhiZwengE3jRs/P17D+9OyoxSCefYwZWUAvHTKeL1dO2BRoSFzaMhGgGlHNgroU909ShQ49SiN26PTCG64H/sC3GMo9Y= 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 1677812392569292.7531182508461; Thu, 2 Mar 2023 18:59:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcy-0007eB-Ji; Thu, 02 Mar 2023 21:58:36 -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 1pXvcv-0007cK-1C for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:33 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvct-0001uN-HG for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:32 -0500 Received: by mail-pj1-x102b.google.com with SMTP id y2so1154902pjg.3 for ; Thu, 02 Mar 2023 18:58:31 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812310; 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=uL8gPV4GfBPCsX5yefLxqBJp76wGELs04Du3rKf0/lI=; b=O7ntNcklmYopitZn731XJ7vJ6QAWmgejTKbRD5kN6cYSifij1anxrJUNzD2xx3Hmfa 3UmPRwhnaK0opiyWUwb5aUUftFrMCiAL3Yx2atzRE4sSLE2w6LFxnXHqBQHtd9FrXEtM D9ksXF1HOv3KOjSUNCj4UKECw5+mLX8nJbbB8jt5d/tmQWGm6h65MxsBpvbotYVR2ZVK yJqdxJk4whDGO1spbqk76pM7WPrBx+K5SP0ZY6QVCFo+b1YlSsg2LSEIRL8DQeSKe4Gn WOCERggmGMibmzx4zRHMcGlFqaKsSy7m3eF7dOUBvkE8jPGg/RbLzRSiOLkuS0H2eHOa H8mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812310; 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=uL8gPV4GfBPCsX5yefLxqBJp76wGELs04Du3rKf0/lI=; b=xqEjvCAfPNXPhDWRD8zipx4YlsHk6F4iI9J4eL/HfPPpjk+Fe+SLZZ1kNd17ceG4mi PiasPCXPB4kJRFQSIxy6i4gKUQQFsFGdJi2X7jcolzybkElUXdIsgRoXK2+uOiP6ci2f kjFrOoVdri/QS/ajVeX8mt2NitEax6QgaHn6kSasJqaSpxsoa01HNvUD33l5fx9jyRIx /RWBfv5cP5kMLhaVqDOl80fkW61ZhFWJGkZrc2JC5QfjYgftk5h7xL6RSDnKiNRggOkL J62dxL0iCp7DC0vB77N+8+YGI16qhADjEOmaBqyRNqI3r2rvE7gfGSsNGYQ77TmBKix8 YGNw== X-Gm-Message-State: AO0yUKWEmBhIwUpzNi94FDmgHUMZqQ1xlYAnzO22ewXRAAHeLXMbZGDe JccUa4zIPB596yoRHLDHUXyDPdFh9fnyc/eYlno= X-Google-Smtp-Source: AK7set+kKnQEErlL/AHk0MSwmZ8FFtZzCJwhUjLnAKmY9WF3f7MO5uTYZyvNWOVU0B1+pktFQJFCqA== X-Received: by 2002:a17:903:24f:b0:19e:7a2c:78a7 with SMTP id j15-20020a170903024f00b0019e7a2c78a7mr550293plh.57.1677812310276; Thu, 02 Mar 2023 18:58:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 28/29] gdbstub: Build syscall.c once Date: Thu, 2 Mar 2023 18:58:04 -0800 Message-Id: <20230303025805.625589-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 1677812394522100003 Content-Type: text/plain; charset="utf-8" There is no longer anything target specific. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- gdbstub/syscalls.c | 5 +---- gdbstub/meson.build | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index b7d85c41c7..4391d124e2 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -2,9 +2,7 @@ * 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). + * the various semihosting extensions. * * Copyright (c) 2003-2005 Fabrice Bellard * Copyright (c) 2023 Linaro Ltd @@ -13,7 +11,6 @@ */ =20 #include "qemu/osdep.h" -#include "cpu.h" #include "semihosting/semihost.h" #include "sysemu/runstate.h" #include "gdbstub/user.h" diff --git a/gdbstub/meson.build b/gdbstub/meson.build index d679c7ab86..bd5c5cd67d 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -31,8 +31,7 @@ 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')) +common_ss.add(files('syscalls.c')) =20 # The user-target is specialised by the guest specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-target.c')) --=20 2.34.1 From nobody Mon May 20 01:44:46 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=1677812334; cv=none; d=zohomail.com; s=zohoarc; b=TR+zk8MMp7T66ZVEst2gxFrEKI3lnEiLKk2bj3qsY+WaApYY58XiPJuo/snWFh9/LgqV0Om9x000vmv6ngpW6PhiRfKx0Kw5dXmYTorAJxXsIYSWxMWqd40VPBE91Old7o27kXJSl0oLtrGZu8R7JEv4JiGR6oASZTT/v21zTgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677812334; 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=4OngDMFsl9T6YL6fMvNNNnl0dkTUWspPmNYtn7l2lDM=; b=Jq4gRuHPU2uJrvFMkioMlSvJTgx0i2tz2PkD4RE3INA3L3XXBkuw19k9GaSrky4eXPtiTNnUiSXb3MrHYc8vwWnsBIYezQ//bREq/K7NhCqkXHv5XI+7La0UOV3vBMtPUPK3dNlZhpUN0K7PFm4EQTbLtXMoDx3UDbEZ9OQ2UrE= 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 1677812334203928.6666291254506; Thu, 2 Mar 2023 18:58:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXvcw-0007dh-TI; Thu, 02 Mar 2023 21:58: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 1pXvcv-0007cY-F8 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:33 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvct-0001pV-RB for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:33 -0500 Received: by mail-pj1-x102b.google.com with SMTP id x34so1210303pjj.0 for ; Thu, 02 Mar 2023 18:58:31 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812311; 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=4OngDMFsl9T6YL6fMvNNNnl0dkTUWspPmNYtn7l2lDM=; b=M4pHKN3Nlc4yFZavIpROm06Ha2GbYlXhoFLrUNMjY/E1ThP1YzbMs6oiLmuQhT7/J+ o1NwiwIq1IG9IISWMNMVsS0xESmFI25OoOiZwkFWQqhxOa89wQaRQZWzZtQKHGC1bX3R CQ+CcgK4pHg2BGJ7BZ/QzRq9JSgwJag7FZ1IhQXhShEWsPVya5obiNNNjG22BOnBNJ1O XVDaIGeKkFeeWw8PK9fORMrL/3/f6KVPtHmlpMb3GyTOeh/qWHESreeJZ5WN5/dNUMqE 0VsoKNNt2K2jkY2boj8RoJTqNfNvrFKwWlHGh8SZGSS1DJtikm3leYNCXKSBE/aXw5YI 3Ygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812311; 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=4OngDMFsl9T6YL6fMvNNNnl0dkTUWspPmNYtn7l2lDM=; b=7Gerj8lPPDDEAZQgdzTpp+7zFhR3ZnQ/Ra2s5XOC/ypBY9tHzAkWkNfbIqiWnQ52GX l2FtV4u9N9DQZ5E00FOcJf1sNYdEJlp1jQLt7xlkqqO1eNVlMWV3WaGI4/IUL8BhXub7 8b9j6UzmWRuD5i1AJUAHiMREmedi7LiuSTQMlqNKmGXiCrqRI5VNte/ULPFgfoXu6Qie GYKTJMleWMmjnD9epuW5ka7SIFSpSw8ud4BzCHtO586ShtdGl1Mev8sh3x4yAymVXnhh UFA9XYmzWRB9vNnvhXPodqwDahBDJAMdzyv5umsLvMv5g53NYpmkrYYvAZZQIDuajVK3 S3CQ== X-Gm-Message-State: AO0yUKW/90SUaD1PfNcFzNpRAxe7lqF0K3RzfFFrWAVyuJRuKqVVwdwB p8Rg47Stfqp+ygJrBnf0sbqacCaj1/HRYwandtc= X-Google-Smtp-Source: AK7set8Gzk1mhWGWfszvndUlwjCOjJZdktl/m5tFeq3yRKuSi6GdTiBoZp0yIDqiIQM85fV3HeMuTQ== X-Received: by 2002:a17:902:8688:b0:194:7a99:d5ce with SMTP id g8-20020a170902868800b001947a99d5cemr425332plo.12.1677812311056; Thu, 02 Mar 2023 18:58:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Mads Ynddal , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 29/29] gdbstub: move update guest debug to accel ops Date: Thu, 2 Mar 2023 18:58:05 -0800 Message-Id: <20230303025805.625589-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@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=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: 1677812336226100007 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 Message-Id: <20230302190846.2593720-27-alex.bennee@linaro.org> --- 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.34.1