From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LWX2EjHLDmaPTCMAWB0awg (envelope-from ) for ; Thu, 04 Apr 2024 11:45:53 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=B46clkKR; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=B46clkKR; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 412071E0C0; Thu, 4 Apr 2024 11:45:53 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 083821E030 for ; Thu, 4 Apr 2024 11:45:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B81D3858C98 for ; Thu, 4 Apr 2024 15:45:50 +0000 (GMT) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2075.outbound.protection.outlook.com [40.107.247.75]) by sourceware.org (Postfix) with ESMTPS id D1CBB3858C98 for ; Thu, 4 Apr 2024 15:45:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1CBB3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D1CBB3858C98 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.247.75 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712245527; cv=pass; b=BGbIDPIqusXIZwdno1CrZWEQ4SvLhtZNQk/qBQPZcUe6BCjhmC7gAEBvx2rmqgtjoN5PMH5x6yVHUgTBXPvOMntWkljLay1gljQpxUwvsFWoq9/vdzrK7QxyHtZLICCLv2DDBS/QrvcX1623gRDYAnkVRi/AgLpoqTFvmSZmDQU= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712245527; c=relaxed/simple; bh=tSFETWii/Q/18cLi5cUOpflVxHuq8xRWj46oaGzFwCc=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=WZx94r517Qwfx3V0xMv571AKIzCyQMSiyEg5SjN/AtzBuwst+NmmzEOk6QPQisFE/vxsVMMAS0WEnSvchrOhct1GOm11s46DKGAupfT1snHg8SSvxQDqBbIwrNSeIf6D5mzp7Oz32m6ErMg1SjukI6AnAO8EE/hygwnMMY2S0io= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ep8u3DtMSxV5sJLyxykv1JU35McKzWhC3Anl1iCcQyKQfs8cn+skibCtFXxMTUH5x1r3185pgdX1jugTCh+8BRLBl5FzoZ0VWj4f8/mOUVaLdntm364ThM0Z7/ImNqNdU15zK7reLD19arRL+a2+azIzEQivgxmg6vZmM3ICywSYbRkyr28z5zP0Qsf4n+CdpYhnIVZZ81pRj7mE//Kqeq3soyek2drC3nZf5gJVf4rb1Op+f4ZDONxqbHCT1gQUIVsV0ujU9psxWd9XNLQzHWefDwjbWKxT5XGBlUfKCIA3p0+zhYA9rIzW5QrETJokc81xYjgvWPFYalvsCRXXPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o/zaNhywD/27TplC5E1oIhgkuUzmoik4lJaUu1AKP0Y=; b=TaTKVFXrTWogr40PNJNhkuzT7TP8Fzj+s+clZc14sAzQB8SS3BOgvUV4UC9BQsziHHIS8J9wko9z24hoCCYxpZzIYTC8udhxahy0hShM+0JH9GrdfMFFy/Jvm+8stbZMFx9ljiO0LXWIHpR/1AAQky/dQYuaYLMOESrc88gyL5meIQfHvQURCsTLH8AKkPV8fa4yYB+6HB2d+Vn5WTPZ7yqbI7QsrgHA1iLrZ4+9A+kk3LjkO5wG5oRMvfK9itH5SIheYGLq+yXkfGxG7vN1r+jLTzhs6VxOB6KBWWjYH2l8bebZzNOUAGoNs+ESBWMzO/3zJVswVuJHZpMJLKKWHw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o/zaNhywD/27TplC5E1oIhgkuUzmoik4lJaUu1AKP0Y=; b=B46clkKRxrLnZV8bynT57uPKXS6HrvOWnaDs7ZoS2ifWIIX6ldv0hZwUpTtgQwZLnPZtjTAF/F7VNiu2J88sxN50cYNpDnQ0IksY67KElPDHLC20LFo6DJmgOQ0HXJOmsYTjdTmB/XZTjXG5dUca4an8LCqEyfm4uZFmBpWtyCY= Received: from DB8PR04CA0015.eurprd04.prod.outlook.com (2603:10a6:10:110::25) by PAVPR08MB8965.eurprd08.prod.outlook.com (2603:10a6:102:328::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Thu, 4 Apr 2024 15:45:19 +0000 Received: from DB1PEPF000509E7.eurprd03.prod.outlook.com (2603:10a6:10:110:cafe::b3) by DB8PR04CA0015.outlook.office365.com (2603:10a6:10:110::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46 via Frontend Transport; Thu, 4 Apr 2024 15:45:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB1PEPF000509E7.mail.protection.outlook.com (10.167.242.57) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Thu, 4 Apr 2024 15:45:19 +0000 Received: ("Tessian outbound ff4e98f65004:v300"); Thu, 04 Apr 2024 15:45:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d2c164e304b548ba X-CR-MTA-TID: 64aa7808 Received: from fe8c56b6fb5e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B9A6C428-ACE9-4B15-9E7E-F192D26B56A3.1; Thu, 04 Apr 2024 15:45:12 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fe8c56b6fb5e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Apr 2024 15:45:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOW2m0ORCD65u46ORa76Phy9Rga7zi4HMEnalLNt19fi3KLiAT/a6RunkPGw6viJ9j8vQSd/SFmYR6Pgv8QejXudiyq4H+9YyBtdr4eEEl5Ljfg1yt+tOZ6OWecLcwHTqGL/vrDFhWCXJdR8oos48nnGMCASWhqM5oHEcnPLTkED08ONdlhjwqgru/RHg/F0CnossCAITMPa7Pg9A8e8U09x5UEzlI3G3gHGtUCfct5UnKY0wEWdOM705+EviB7rXW+mpVjU0IG1XmjtqdEwywYcKtlzhLQ+Sd2wYxuW37ND+pmZN0ZpGTdCwLURgcmTuM2CZd5NDdlp9ynx0JEqSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o/zaNhywD/27TplC5E1oIhgkuUzmoik4lJaUu1AKP0Y=; b=NLYhZYKPgYIwUZtbDviui8o9HKC1Z1d01Z3E19hkXjyxF2AbUMxQ+Gppy2ed4zgQ6KqCmSnKvwtmtDmeDmJe5pj8gsCGbuyUZdz6YbtUqHf+SwyuED0oVJCNSvJnMkC+dIJ39lqrQ7KPnHmR8ilLvD4Q7ZUZ2B32ocG0yWTBa2u/YUafYDqTtZ3N6/ZG8h3tC4C7OJEgtgcWFsgypKv4htGHL+YLrYgrJpEV8SwRuBBsFq4S24XNC7IyQmEsbP4Q56OfRj+TFaxxg2AwIC8vvnKVlVWwW+eiBaA3Ent18s9mjAJD6H+W7+mh05rhOKkszWGbtby8nlp6WrNGTi0uEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o/zaNhywD/27TplC5E1oIhgkuUzmoik4lJaUu1AKP0Y=; b=B46clkKRxrLnZV8bynT57uPKXS6HrvOWnaDs7ZoS2ifWIIX6ldv0hZwUpTtgQwZLnPZtjTAF/F7VNiu2J88sxN50cYNpDnQ0IksY67KElPDHLC20LFo6DJmgOQ0HXJOmsYTjdTmB/XZTjXG5dUca4an8LCqEyfm4uZFmBpWtyCY= Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by VI1PR08MB10197.eurprd08.prod.outlook.com (2603:10a6:800:1bc::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Thu, 4 Apr 2024 15:45:05 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::363f:3fc8:fc36:58ed]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::363f:3fc8:fc36:58ed%5]) with mapi id 15.20.7409.042; Thu, 4 Apr 2024 15:45:05 +0000 Message-ID: Date: Thu, 4 Apr 2024 16:45:03 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 5/7] gdb: Introduce is_address_tagged target hook Content-Language: en-US To: Gustavo Romero , gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org References: <20240404064819.2848899-1-gustavo.romero@linaro.org> <20240404064819.2848899-6-gustavo.romero@linaro.org> From: Luis Machado In-Reply-To: <20240404064819.2848899-6-gustavo.romero@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P123CA0053.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::17) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|VI1PR08MB10197:EE_|DB1PEPF000509E7:EE_|PAVPR08MB8965:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: qPwY2pMqdnwh0dknsmIImlVdycqLZ1SJGXMaJNRbV1J4RaUumpCF1xmP3i91HyW2EPjX2cKLZdOw1fhK7lA5Zq8Ttoz7Q7/txWhd/Xp0cdzNFFD9+2egqH7J5pjYG53ephmbUfNEez0G0Af1uX38I29UlcnyB6HD7Yg6rH5wLfN4SdrxzywKlj2vU1Mxw933SweiQuObnSFn+rYpB+z9HUiIWLq+glrADpS9+jPG3jTDST9fA+aRnkMzn+PebQok2vmzKpXzwIGxMZRIc+I3qoTcYWg4QO5959m4QkFjZW2ws0ymS9NykIWMTiut1kkrHMcUp3FGkXBNumzIamT2PCn+clbtxUeMXcTPP30b/JN6BIjI1Ff4LZb3xuU2wBZMCHyZjd93tTs6wS7A322Z4vkAkzEEBcYXUCvq7cH4M8p+98Iv6YUPIiDPGu9Etg8qfkC4wmEAZXVlQkerBOOWhcP5zJZOucttsSzqSuOD8UU8TEvShIUD13VbuLRRAPW3W5Y5sjQ8Zs6q3ko8J4KxJc/F5XquIg+mDfk88W0ChHKzilQNcA0e8kX85wImabNniC2fQiLnMl0U2qkQWG+MMJBdJ5s/vMpyuoGSHmPe2dk6IthHJ37isygQKGRyoMbkbaD1WZuojZOaRcYwKTGjeehc+KEe7oB6jgqcKx/m2qM= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(1800799015)(366007); DIR:OUT; SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10197 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509E7.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a74e831a-1810-4230-8fca-08dc54be3b1f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CBLOpxPBA5JAKnjShKTdrQlyOKige9dLMkI+jBLx8cP8hr1UvxCC/mntDb9XPVC+vAZyd16uYhc+nxdoS8tBDNTx+JgbLyD4xOj2pb49oAUe9GmmJY3JEDrx8kUAd89NZBJKNOYj1Q2wkiek/xT+y3+VOzhvFwNsEqP02VLQzTM30STUwoDm1e/jXJX3Jp1c8wq0tgUxqAB59X3QJ9rXM90qNe0+UEEsnTB0mzaoT568BMOKpucGJCIKdC41ZP4TS1Tq4Irp4d9UBSswvSKxbNRcFd5qZLED4Pwc//9eHQR93pnUbT1YS6ROoFPyPiAevfK6Y/RiHHD3vKFplZvQ1g69Vi4JnNA0Oq9jgKOTV0Nr9hLes9D2qVT9G5s2E8LYyJ/2I0GtljkgfK2GnTRiMqTXfa/N69v3yL3AvJFS5tQweRWSiyDBOGXLuDPJeKSGq0BfXnXnxMEIhddPqx7s9od+m8hIszFzrYIszboo3/xv0i8t3o6WxbJrFoS6aSqL3FpTVEIAInshRzhUUuF8PcbLIbPh00VJqpABcDd0oQrdHsiLmLe/ObVxpO2RzfFRPIsCHs7xKJBRoxDU2xpXMthGOGKuJj3KzXY+1DmG+De3NLBPE2BrdNnH2ptz8RFmz4cwWOFegct/NHo8iOD+G/hOrrW0Mx+Gfx19A+JmXlHZUZr7AKq1wVp60EkeYdeF5vXqnDBn9eMjigUIeMBOTPrqYINmdEXD/ivU84YvqypnyZeY6E5Q3b6voQtcz2qQ X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230031)(36860700004)(376005)(82310400014)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 15:45:19.2211 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a74e831a-1810-4230-8fca-08dc54be3b1f X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509E7.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB8965 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org On 4/4/24 07:48, Gustavo Romero wrote: > This commit introduces a new target hook, target_is_address_tagged, > which is used instead of the gdbarch_tagged_address_p gdbarch hook in > the upper layer (printcmd.c). > > This change allows the memory tagging address checking to be specialized > easily per target in the future. Since target_is_address_tagged > continues to use the gdbarch_tagged_address_p hook there is no change > in behavior for the targets using the new target hook (the remote.c, > aarch64-linux-nat.c, and corelow.c targets). The above block... > > This change enables easy specialization of memory tagging address > check per target in the future. As target_is_address_tagged continues > to utilize the gdbarch_tagged_address_p hook, there is no change in > behavior for all the targets that use the new target hook (i.e., the > remote.c, aarch64-linux-nat.c, and corelow.c targets). ... seems to be somewhat duplicated above in the commit message. Also, as general rule, we usually make updates clear at the top of the commit message. for instace: Updates in v3: - Something something. - Fixed breakage. And then those update blocks don't get pushed when the series is approved (sometimes some do push it). > > Just the gdbarch_tagged_address_p signature is changed for convenience, > since target_is_address_tagged takes the address to be checked as a > CORE_ADDR type. > > Signed-off-by: Gustavo Romero > --- > gdb/aarch64-linux-nat.c | 8 ++++++++ > gdb/aarch64-linux-tdep.c | 10 ++++------ > gdb/arch-utils.c | 2 +- > gdb/arch-utils.h | 2 +- > gdb/corelow.c | 8 ++++++++ > gdb/gdbarch-gen.h | 4 ++-- > gdb/gdbarch.c | 2 +- > gdb/gdbarch_components.py | 2 +- > gdb/printcmd.c | 31 +++++++++++++++++-------------- > gdb/remote.c | 10 ++++++++++ > gdb/target-delegates.c | 30 ++++++++++++++++++++++++++++++ > gdb/target.c | 6 ++++++ > gdb/target.h | 6 ++++++ > 13 files changed, 95 insertions(+), 26 deletions(-) > > diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c > index 3face34ce79..19c099832a5 100644 > --- a/gdb/aarch64-linux-nat.c > +++ b/gdb/aarch64-linux-nat.c > @@ -110,6 +110,8 @@ class aarch64_linux_nat_target final > /* Write allocation tags to memory via PTRACE. */ > bool store_memtags (CORE_ADDR address, size_t len, > const gdb::byte_vector &tags, int type) override; > + /* Check if an address is tagged. */ > + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; > }; > > static aarch64_linux_nat_target the_aarch64_linux_nat_target; > @@ -1071,6 +1073,12 @@ aarch64_linux_nat_target::store_memtags (CORE_ADDR address, size_t len, > return false; > } > > +bool > +aarch64_linux_nat_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) > +{ > + return gdbarch_tagged_address_p (gdbarch, address); I'd add a comment here on why we take a detour going to the linux-tdep layer to read the smaps file, because we don't have a better way to get that information. In the future, if this check is ever made available through PTRACE, one can come here and drop the smaps path. > +} > + > void _initialize_aarch64_linux_nat (); > void > _initialize_aarch64_linux_nat () > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index fc60e602748..2a47c3f0845 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -2451,17 +2451,15 @@ aarch64_mte_get_atag (CORE_ADDR address) > /* Implement the tagged_address_p gdbarch method. */ > > static bool > -aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, struct value *address) > +aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address) > { > - gdb_assert (address != nullptr); > - > - CORE_ADDR addr = value_as_address (address); > + gdb_assert (address); No need to assert for a non-zero address. We used to assert that we had a valid pointer, but since we're no longer dealing with a pointer, we don't have to worry about it. Plus, 0x0 is a valid address (at least for bare-metal. We could run into an assertion if the user explicitly tries to check for tags in a 0x0 address. See below: (gdb) memory-tag check 0x0 ../../../repos/binutils-gdb/gdb/aarch64-linux-tdep.c:2456: internal-error: aarch64_linux_tagged_address_p: Assertion `address' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. ----- Backtrace ----- 0xaaaac69ccf97 _Z22gdb_internal_backtracev 0xaaaac6e443e7 _ZL17internal_vproblemP16internal_problemPKciS2_St9__va_list 0xaaaac6e4464f _Z15internal_verrorPKciS0_St9__va_list 0xaaaac734a8b3 _Z18internal_error_locPKciS0_z 0xaaaac68dc407 _ZL30aarch64_linux_tagged_address_pP7gdbarchm 0xaaaac6c849ab _ZL24memory_tag_check_commandPKci 0xaaaac69fb8ab _Z8cmd_funcP16cmd_list_elementPKci 0xaaaac6de5ed3 _Z15execute_commandPKci 0xaaaac6adc203 _Z15command_handlerPKc 0xaaaac6add45f _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE 0xaaaac6adccd7 _ZL23gdb_rl_callback_handlerPc 0xaaaac6ea7eeb rl_callback_read_char 0xaaaac6adbc7b _ZL42gdb_rl_callback_read_char_wrapper_noexceptv 0xaaaac6adcb3b _ZL33gdb_rl_callback_read_char_wrapperPv 0xaaaac6e1ef5f _ZL19stdin_event_handleriPv 0xaaaac734b29f _ZL18gdb_wait_for_eventi.part.0 0xaaaac734bc7f _Z16gdb_do_one_eventi 0xaaaac6bdd977 _ZL21captured_command_loopv 0xaaaac6bdf6bb _Z8gdb_mainP18captured_main_args 0xaaaac68cee47 main > > /* Remove the top byte for the memory range check. */ > - addr = gdbarch_remove_non_address_bits (gdbarch, addr); > + address = gdbarch_remove_non_address_bits (gdbarch, address); > > /* Check if the page that contains ADDRESS is mapped with PROT_MTE. */ > - if (!linux_address_in_memtag_page (addr)) > + if (!linux_address_in_memtag_page (address)) > return false; > > /* We have a valid tag in the top byte of the 64-bit address. */ > diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c > index 456bfe971ff..cb149c36bc9 100644 > --- a/gdb/arch-utils.c > +++ b/gdb/arch-utils.c > @@ -102,7 +102,7 @@ default_memtag_to_string (struct gdbarch *gdbarch, struct value *tag) > /* See arch-utils.h */ > > bool > -default_tagged_address_p (struct gdbarch *gdbarch, struct value *address) > +default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address) > { > /* By default, assume the address is untagged. */ > return false; > diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h > index 2dcd8f6dc53..467be40c688 100644 > --- a/gdb/arch-utils.h > +++ b/gdb/arch-utils.h > @@ -141,7 +141,7 @@ extern std::string default_memtag_to_string (struct gdbarch *gdbarch, > struct value *tag); > > /* Default implementation of gdbarch_tagged_address_p. */ > -bool default_tagged_address_p (struct gdbarch *gdbarch, struct value *address); > +bool default_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address); > > /* Default implementation of gdbarch_memtag_matches_p. */ > extern bool default_memtag_matches_p (struct gdbarch *gdbarch, > diff --git a/gdb/corelow.c b/gdb/corelow.c > index f4e8273d962..b13d0124471 100644 > --- a/gdb/corelow.c > +++ b/gdb/corelow.c > @@ -109,6 +109,8 @@ class core_target final : public process_stratum_target > bool fetch_memtags (CORE_ADDR address, size_t len, > gdb::byte_vector &tags, int type) override; > > + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; > + Maybe add a comment to this function stating what we're looking for: /* If the architecture supports it, check if ADDRESS is within a memory range mapped with tags. For example, MTE tags for AArch64. */ Or some other variation of the above. The reason being that the corelow target is a bit special because it is generic, hence why we see an override for a x86 target hook in there as well. > x86_xsave_layout fetch_x86_xsave_layout () override; > > /* A few helpers. */ > @@ -1410,6 +1412,12 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len, > return false; > } > > +bool > +core_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) > +{ > + return gdbarch_tagged_address_p (gdbarch, address); > +} > + > /* Implementation of the "fetch_x86_xsave_layout" target_ops method. */ > > x86_xsave_layout > diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h > index ebcff80bb9e..63fab26987f 100644 > --- a/gdb/gdbarch-gen.h > +++ b/gdb/gdbarch-gen.h > @@ -707,8 +707,8 @@ extern void set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, gdbarch_memta > /* Return true if ADDRESS contains a tag and false otherwise. ADDRESS > must be either a pointer or a reference type. */ > > -typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, struct value *address); > -extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address); > +typedef bool (gdbarch_tagged_address_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR address); > +extern bool gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address); > extern void set_gdbarch_tagged_address_p (struct gdbarch *gdbarch, gdbarch_tagged_address_p_ftype *tagged_address_p); > > /* Return true if the tag from ADDRESS matches the memory tag for that > diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c > index 9319571deba..2d92f604c49 100644 > --- a/gdb/gdbarch.c > +++ b/gdb/gdbarch.c > @@ -3232,7 +3232,7 @@ set_gdbarch_memtag_to_string (struct gdbarch *gdbarch, > } > > bool > -gdbarch_tagged_address_p (struct gdbarch *gdbarch, struct value *address) > +gdbarch_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address) > { > gdb_assert (gdbarch != NULL); > gdb_assert (gdbarch->tagged_address_p != NULL); > diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py > index 7d913ade621..24e979431b6 100644 > --- a/gdb/gdbarch_components.py > +++ b/gdb/gdbarch_components.py > @@ -1267,7 +1267,7 @@ must be either a pointer or a reference type. > """, > type="bool", > name="tagged_address_p", > - params=[("struct value *", "address")], > + params=[("CORE_ADDR", "address")], > predefault="default_tagged_address_p", > invalid=False, > ) > diff --git a/gdb/printcmd.c b/gdb/printcmd.c > index 62fbcb98cfb..24eac7c8421 100644 > --- a/gdb/printcmd.c > +++ b/gdb/printcmd.c > @@ -1132,7 +1132,7 @@ do_examine (struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr) > = value_from_ulongest (builtin_type (gdbarch)->builtin_data_ptr, > tag_laddr); > > - if (gdbarch_tagged_address_p (gdbarch, v_addr)) > + if (target_is_address_tagged (gdbarch, value_as_address (v_addr))) > { > /* Fetch the allocation tag. */ > struct value *tag > @@ -1268,7 +1268,7 @@ print_value (value *val, const value_print_options &opts) > /* Returns true if memory tags should be validated. False otherwise. */ > > static bool > -should_validate_memtags (struct value *value) > +should_validate_memtags (gdbarch *gdbarch, struct value *value) > { > gdb_assert (value != nullptr && value->type () != nullptr); > > @@ -1289,7 +1289,7 @@ should_validate_memtags (struct value *value) > return false; > > /* We do. Check whether it includes any tags. */ > - return gdbarch_tagged_address_p (current_inferior ()->arch (), value); > + return target_is_address_tagged (gdbarch, value_as_address (value)); > } > > /* Helper for parsing arguments for print_command_1. */ > @@ -1346,7 +1346,7 @@ print_command_1 (const char *args, int voidprint) > { > gdbarch *arch = current_inferior ()->arch (); > > - if (should_validate_memtags (val) > + if (should_validate_memtags (arch, val) > && !gdbarch_memtag_matches_p (arch, val)) > { > /* Fetch the logical tag. */ > @@ -2946,9 +2946,10 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type) > flag, it is no use trying to access/manipulate its allocation tag. > > It is OK to manipulate the logical tag though. */ > + CORE_ADDR addr = value_as_address (val); > if (tag_type == memtag_type::allocation > - && !gdbarch_tagged_address_p (arch, val)) > - show_addr_not_tagged (value_as_address (val)); > + && !target_is_address_tagged (arch, addr)) > + show_addr_not_tagged (addr); > > value *tag_value = gdbarch_get_memtag (arch, val, tag_type); > std::string tag = gdbarch_memtag_to_string (arch, tag_value); > @@ -3104,8 +3105,9 @@ parse_set_allocation_tag_input (const char *args, struct value **val, > > /* If the address is not in a region memory mapped with a memory tagging > flag, it is no use trying to access/manipulate its allocation tag. */ > - if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val)) > - show_addr_not_tagged (value_as_address (*val)); > + CORE_ADDR addr = value_as_address (*val); > + if (!target_is_address_tagged (current_inferior ()->arch (), addr)) > + show_addr_not_tagged (addr); > } > > /* Implement the "memory-tag set-allocation-tag" command. > @@ -3129,8 +3131,9 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty) > > /* If the address is not in a region memory mapped with a memory tagging > flag, it is no use trying to manipulate its allocation tag. */ > - if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val)) > - show_addr_not_tagged (value_as_address(val)); > + CORE_ADDR addr = value_as_address (val); > + if (!target_is_address_tagged (current_inferior ()-> arch(), addr)) > + show_addr_not_tagged (addr); > > if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags, > memtag_type::allocation)) > @@ -3157,12 +3160,12 @@ memory_tag_check_command (const char *args, int from_tty) > struct value *val = process_print_command_args (args, &print_opts, true); > gdbarch *arch = current_inferior ()->arch (); > > + CORE_ADDR addr = value_as_address (val); > + > /* If the address is not in a region memory mapped with a memory tagging > flag, it is no use trying to access/manipulate its allocation tag. */ > - if (!gdbarch_tagged_address_p (arch, val)) > - show_addr_not_tagged (value_as_address (val)); > - > - CORE_ADDR addr = value_as_address (val); > + if (!target_is_address_tagged (current_inferior ()->arch (), addr)) > + show_addr_not_tagged (addr); I noticed the above checks happen at least 3 times in the code. Maybe a future cleanup possibility to split the check into a separate function. > > /* Check if the tag is valid. */ > if (!gdbarch_memtag_matches_p (arch, val)) > diff --git a/gdb/remote.c b/gdb/remote.c > index e278711df7b..9717db55e27 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -1084,6 +1084,8 @@ class remote_target : public process_stratum_target > bool store_memtags (CORE_ADDR address, size_t len, > const gdb::byte_vector &tags, int type) override; > > + bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) override; > + > public: /* Remote specific methods. */ > > void remote_download_command_source (int num, ULONGEST addr, > @@ -15573,6 +15575,14 @@ remote_target::store_memtags (CORE_ADDR address, size_t len, > return packet_check_result (rs->buf).status () == PACKET_OK; > } > > +/* Implement the "is_address_tagged" target_ops method. */ > + > +bool > +remote_target::is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) > +{ > + return gdbarch_tagged_address_p (gdbarch, address); > +} > + > /* Return true if remote target T is non-stop. */ > > bool > diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c > index 59ea70458ad..e322bbbe481 100644 > --- a/gdb/target-delegates.c > +++ b/gdb/target-delegates.c > @@ -197,6 +197,7 @@ struct dummy_target : public target_ops > bool supports_memory_tagging () override; > bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override; > bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override; > + bool is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override; > x86_xsave_layout fetch_x86_xsave_layout () override; > }; > > @@ -373,6 +374,7 @@ struct debug_target : public target_ops > bool supports_memory_tagging () override; > bool fetch_memtags (CORE_ADDR arg0, size_t arg1, gdb::byte_vector &arg2, int arg3) override; > bool store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector &arg2, int arg3) override; > + bool is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) override; > x86_xsave_layout fetch_x86_xsave_layout () override; > }; > > @@ -4562,6 +4564,34 @@ debug_target::store_memtags (CORE_ADDR arg0, size_t arg1, const gdb::byte_vector > return result; > } > > +bool > +target_ops::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) > +{ > + return this->beneath ()->is_address_tagged (arg0, arg1); > +} > + > +bool > +dummy_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) > +{ > + tcomplain (); > +} > + > +bool > +debug_target::is_address_tagged (gdbarch *arg0, CORE_ADDR arg1) > +{ > + gdb_printf (gdb_stdlog, "-> %s->is_address_tagged (...)\n", this->beneath ()->shortname ()); > + bool result > + = this->beneath ()->is_address_tagged (arg0, arg1); > + gdb_printf (gdb_stdlog, "<- %s->is_address_tagged (", this->beneath ()->shortname ()); > + target_debug_print_gdbarch_p (arg0); > + gdb_puts (", ", gdb_stdlog); > + target_debug_print_CORE_ADDR (arg1); > + gdb_puts (") = ", gdb_stdlog); > + target_debug_print_bool (result); > + gdb_puts ("\n", gdb_stdlog); > + return result; > +} > + > x86_xsave_layout > target_ops::fetch_x86_xsave_layout () > { > diff --git a/gdb/target.c b/gdb/target.c > index 107a84b3ca1..5c3c1a57dbd 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -796,6 +796,12 @@ target_store_memtags (CORE_ADDR address, size_t len, > return current_inferior ()->top_target ()->store_memtags (address, len, tags, type); > } > > +bool > +target_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) > +{ > + return current_inferior ()->top_target ()->is_address_tagged (gdbarch, address); > +} > + > x86_xsave_layout > target_fetch_x86_xsave_layout () > { > diff --git a/gdb/target.h b/gdb/target.h > index c9eaff16346..486a0a687b0 100644 > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -1334,6 +1334,10 @@ struct target_ops > const gdb::byte_vector &tags, int type) > TARGET_DEFAULT_NORETURN (tcomplain ()); > > + /* Returns true if ADDRESS is tagged, otherwise returns false. */ > + virtual bool is_address_tagged (gdbarch *gdbarch, CORE_ADDR address) > + TARGET_DEFAULT_NORETURN (tcomplain ()); > + Should the default for is_address_tagged by to return false, meaning the address is never tagged? > /* Return the x86 XSAVE extended state area layout. */ > virtual x86_xsave_layout fetch_x86_xsave_layout () > TARGET_DEFAULT_RETURN (x86_xsave_layout ()); > @@ -2317,6 +2321,8 @@ extern bool target_fetch_memtags (CORE_ADDR address, size_t len, > extern bool target_store_memtags (CORE_ADDR address, size_t len, > const gdb::byte_vector &tags, int type); > > +extern bool target_is_address_tagged (gdbarch *gdbarch, CORE_ADDR address); > + > extern x86_xsave_layout target_fetch_x86_xsave_layout (); > > /* Command logging facility. */