From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id tYBIHIGJ4mK08BsAWB0awg (envelope-from ) for ; Thu, 28 Jul 2022 09:05:05 -0400 Received: by simark.ca (Postfix, from userid 112) id 5CEF91EA03; Thu, 28 Jul 2022 09:05:05 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=TPVk2ZgV; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AB0001E5EA for ; Thu, 28 Jul 2022 09:05:01 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B21413856DE8 for ; Thu, 28 Jul 2022 13:05:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B21413856DE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1659013500; bh=XWVxLePM6yK0mrtN+etxi+9udWWPuQ1GZK5r97ZmH8s=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TPVk2ZgVgD4VYMf6NwrPOE+zvIh96MvCB+m5JccQdw3Sek/OC8kHME9x5QbndqmSe JDT41cBGqbsYWf9iP3rKj05Zc+AVu7paC9/Oq6q5r7IDe87zrSkhX00+xv9kIV4RDx qM/gAAIDlG5pceFI8q/m1Vmw2+BFMhMwXRSVYX14= Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2068.outbound.protection.outlook.com [40.107.20.68]) by sourceware.org (Postfix) with ESMTPS id 19C9E385800B for ; Thu, 28 Jul 2022 13:04:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19C9E385800B ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=fbdYeEbXstSuMXdFxoIKIRjcPiVl9CGj2k+nN12yQBocWMRErQHHuV+SlNAlexdc/QlvHaPfE7NGnjO6pBP7c/p58PJBlLu7l8+ZVd3soB3dvOd47pU1lZZFhc8pqCMP2aA62fkotfUJpqL9ghJmsUqiqrs2kiotalWZINI/RsoWJp4I8pp4TQQQh/aWAWFV5KOlCCm7Ul4vGVDP7/vCvtKeA/n0w1f0HG6QPk1CMMcSASuhFO4XP46Q2AUeJy2pupGLeMy6gtXTQQRCCaeFXSEfRRYxMb6+GlpyOIOyiH+wQweM7w9Yar6L71eLPFXuR/hgDjh5icWQdvlDvXQ1wg== 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=XWVxLePM6yK0mrtN+etxi+9udWWPuQ1GZK5r97ZmH8s=; b=ggJrfzoJxeGwLoMDBXXS9PoRI12cdoId/nZvAyeIv+OsF0Y5k6mpKvzFv3XsjW5YSrvXwGxbxl475+Ip1FOHyX+3SFP8ZLowhfotM1fwRHRBpA/ONqpUNVQzIRFl/k++mTsqS1JrlpyylqJrfLIcn6p+adVAVENjuGIsdsHYHvmYkMz0uASxzdWGkcqO0Xy0q2M0BJUGBGb1ocuAFQ5hHncz5ABjYhIill4ycAhdckCMmB597yMKdA1jyhQnUQHoSh13LPGym7KzT221cD21Ifg/i3QblA4/E3l/VICKitw6TIQkIf3ffSlINjI+cxKRCbCpezuM1/ywtWgdBQ0lJQ== 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]) Received: from FR0P281CA0115.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::14) by AS8PR08MB8135.eurprd08.prod.outlook.com (2603:10a6:20b:560::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Thu, 28 Jul 2022 13:04:36 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a8:cafe::c8) by FR0P281CA0115.outlook.office365.com (2603:10a6:d10:a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.5 via Frontend Transport; Thu, 28 Jul 2022 13:04:36 +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 VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12 via Frontend Transport; Thu, 28 Jul 2022 13:04:36 +0000 Received: ("Tessian outbound 63c09d5d38ac:v123"); Thu, 28 Jul 2022 13:04:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6cf36980e0a9bdda X-CR-MTA-TID: 64aa7808 Received: from 5a020e743e55.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AF7EBF27-453C-462C-876A-C8CAAF2E8436.1; Thu, 28 Jul 2022 13:03:43 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5a020e743e55.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 28 Jul 2022 13:03:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GP2OHNXNrzbKgsaK9x/hoDtBxu//yOS4R1/Jl7aR0nbaLACofv02cTmlahsteur3Z+qSOakMrfIj5fJiLodKPxaJupJVrEdDuOgNZrX/Nigsge+hsQ0AD55X6kjwIzBgv9vSwAH8I4AArvhVduw185TAqjobaMxQSFLk6nqcnuv0MhxYVnBCpjPXIEv9ttTHEQpHY+aXculGxRe310sfHYSQQALQTHxpWjkzioGEGcCfzBbGf6fxU8Y94B00jaPhbVQSahv+FYZg59vSYGGhVbGsswWsjp9/bQ9ozQb5/8DprNR5sJIB5ygtd5nPpY4JOURDtnLR1NGgCyp7aSkZtw== 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=XWVxLePM6yK0mrtN+etxi+9udWWPuQ1GZK5r97ZmH8s=; b=WeAlNyIQz5ua0KbGNQGoDdPoUkj15Z9n0/c7npeJ87oWlFHF/9NRBnuAEuli7k0vyUznDSf+0cLAKWImRpNd4KiiYquvOI2zY5Onf7XIR7OTyr4r4l3Syfoo5Ej/H+FdW+mv+L0TOsQVl/4sKLlegGlfqOksMdhQpxzKIgkmFiFeTpEwnqNcacP0MY0GTDnBZSc/ggqx8LkhbD4Tp2SVXWn/AvQBHHnsrLDUIHQWKRq5bAsvrxYcinC826GVHmyXU4K4fQXZHhjgMtR6efskM7ct+Lmm94z9wRyw0ahuKxy3gM1/BSG9++7oBMxb8KNpNVgE1zz8C+2hyCKUL/eRLg== 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 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AS2PR08MB8311.eurprd08.prod.outlook.com (2603:10a6:20b:556::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Thu, 28 Jul 2022 13:03:41 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::e866:af0e:2168:5ca7]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::e866:af0e:2168:5ca7%5]) with mapi id 15.20.5458.019; Thu, 28 Jul 2022 13:03:40 +0000 Message-ID: <3218f696-c2de-bcba-e73b-7409cf0a8b66@arm.com> Date: Thu, 28 Jul 2022 14:03:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 1/2] gdb/aarch64: Fix thread's gdbarch when SVE vector length changes Content-Language: en-US To: Thiago Jung Bauermann , gdb-patches@sourceware.org References: <20220728012306.157639-1-thiago.bauermann@linaro.org> <20220728012306.157639-2-thiago.bauermann@linaro.org> In-Reply-To: <20220728012306.157639-2-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0553.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:33b::7) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3297a0d1-2016-4315-18d0-08da7099b8f6 X-MS-TrafficTypeDiagnostic: AS2PR08MB8311:EE_|VE1EUR03FT008:EE_|AS8PR08MB8135: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: 3fHnAiYk/jrdt1zWTLi3d3YWtR6x+H5aay8j7HI6Uak3qZMFRNoFFokEHXe8W3idhcOR0VNBgP956foNwFUaKfHqcCuW/uIpxs605G8a1bP07e2DoM2o+DO7tZ7I5zgKuJVxcomsl5HcKCL2OSoTDYTFPwwZMlVa4u0hF6GSHRNnvKHvVvor+cAcgWtovyQDCy4AJY4+fibnimyL8thODzXWropnhLKgdadXeI/RZOm4gkJpOJFsy+eyhec4NXgdDhixhjQ9D2FbCLNCY9ovaLOT14wmdTCIez9fkj+CbssT3G3CHUtarTfv+WKnzFZQpBUoyeg3AWd9QZtl2jm55E8MgFDnrxhk03scY/DibUyZdAl4GnwsPrd4T8TkrYwjrisC+L+nimFzTWX+/J7cQrWMNPdHiWVAK+naiVL/pmiwph1C/nDtcBt0U8cDTA/DZ99zsagy6hrxk4m8vdCVxxExukGubqoPmx7vqw99YsLl26GfEpuJz2UohKzYAMnFXyFjp96BpU0fawnhn5P0J9UOZKyml1UOblsogS8+GKHdmm18AuRsvOZeyeY/x9cb47IWk3o3AMXuaIwK46i6iQh7qbtUfpZl/azffHFmw4pd2OkETyFmpzRH/B9QlVtS2VtwcQAlvMYSOv24+ttivGFi66H5Hm2yrGLej0bRkmNfgfK7LcUCMme9b/aID/i0C/GCjicFLqtw8V8z3oocjiCHjfdlrq2DjEyTWTwd3G+st0zaxIX5P/HYrsZa4clnJtfVvd0AwkSAiKWa99/hhhDDDe1zLA+l+IGiToL42otj5DsGV0iahzbr5NWsE4gekG4yDWyPxlyik1g5uOCu8w== 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:(13230016)(4636009)(346002)(39860400002)(376002)(366004)(396003)(136003)(6506007)(41300700001)(31696002)(6512007)(86362001)(26005)(53546011)(38100700002)(186003)(2616005)(83380400001)(8936002)(66946007)(5660300002)(31686004)(44832011)(8676002)(66556008)(66476007)(36756003)(6486002)(2906002)(316002)(478600001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8311 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5c8eaf01-e216-43a8-e74d-08da7099979f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bJuFeRXH+rfUNucRUsxmbs7sIOlK/rcmIxv+/8UWY/4k7JkLOyPHjjGLQUezp71ql9NsC5z1VOLnX+cy2LXT9pgaPF0foxID7nX342JOz3YupLfCFTf1CYhfia0l8/3zObBpIIcwobrztB8OmamMStThWMbwAuW36uM7HSMvpXqlMOLECICz7rD2griT07qN434TgR/bH5LiGdC4tN7iIj59dEwFFkGpB8lPGsBh4gwx92PXS4FtTxTSUV2ImteuwxjcQxkfBMd9AXwAt5JW8CILJaVb+GiOHvDVz+jvcBdqLYrWzY1yq0HxNY7nkfjIgncow8RxPQuiWiLAhUP8oU7780PR0J8LkAuMpyTDjEnjM3NW0XBF5BomE58UO73ZcvCTxxG0s0JG/laac9oED+KNpeT3kloemY+IlILJUz50fOQT2hf4nOgtVFYMcqeKRFUykY6xteKHH1TkbGQfWwS5cyuqCjGmryZqinQV4iG47BgieA7iU47ZRDhBEFQQTXKKlVSlYwh8kWh1pdec4VeTnqZ9TrTW8rG/2B+eK8PAB3voETqatD/sJ5TbRKC8qiWe7hArMJrBfpvxnHF4MnRbtCpIyHRbsKSFMX6RSkfzkqWQGmUNT/1XDfd8w0QP0b8vOl2m28NnRkOkH2+c1dMws0NRl3PgM7J87++ooMd5Z1Pozc5JvhWyn5W9ah4TfWHmYhb3WcgR22xWs8GmPIro86vwy8mdbCMRXWN1J+Ulhbx3eyonqZ2TpM7lTIl1IO7KOpaG0orJCrQ0XXa72TsCBeht7lkjVfCHU9ngIEPla2jE+oQmPOKm3BTwR/QZK4eaC9lCuunj4eE/LzzloA== 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:(13230016)(4636009)(39860400002)(376002)(136003)(396003)(346002)(46966006)(36840700001)(40470700004)(82310400005)(82740400003)(336012)(6486002)(47076005)(316002)(36756003)(81166007)(31696002)(86362001)(2616005)(41300700001)(478600001)(31686004)(186003)(6506007)(53546011)(26005)(6512007)(2906002)(5660300002)(8936002)(40460700003)(8676002)(70586007)(40480700001)(70206006)(356005)(83380400001)(44832011)(36860700001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2022 13:04:36.0217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3297a0d1-2016-4315-18d0-08da7099b8f6 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: VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8135 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, Thanks for the patch. On 7/28/22 02:23, Thiago Jung Bauermann via Gdb-patches wrote: > When the inferior program changes the SVE length, GDB can stop tracking > some registers as it obtains the new gdbarch that corresponds to the > updated length: > > Breakpoint 1, do_sve_ioctl_test () at sve-ioctls.c:44 > 44 res = prctl(PR_SVE_SET_VL, i, 0, 0, 0, 0); > (gdb) print i > $2 = 32 > (gdb) info registers > ⋮ > [ snip registers x0 to x30 ] > ⋮ > sp 0xffffffffeff0 0xffffffffeff0 > pc 0xaaaaaaaaa8ac 0xaaaaaaaaa8ac > cpsr 0x60000000 [ EL=0 BTYPE=0 C Z ] > fpsr 0x0 0 > fpcr 0x0 0 > vg 0x8 8 > tpidr 0xfffff7fcb320 0xfffff7fcb320 > (gdb) next > 45 if (res < 0) { > (gdb) info registers > ⋮ > [ snip registers x0 to x30 ] > ⋮ > sp 0xffffffffeff0 0xffffffffeff0 > pc 0xaaaaaaaaa8cc 0xaaaaaaaaa8cc > cpsr 0x200000 [ EL=0 BTYPE=0 SS ] > fpsr 0x0 0 > fpcr 0x0 0 > vg 0x4 4 > (gdb) > > Notice that register tpidr disappeared when vg (which holds the vector > length) changed from 8 to 4. The tpidr register is provided by the > org.gnu.gdb.aarch64.tls feature. > > This happens because the code that searches for a new gdbarch to match the > new vector length in aarch64_linux_nat_target::thread_architecture doesn't > take into account the features present in the target description associated > with the previous gdbarch. This patch makes it do that. > --- > gdb/aarch64-linux-nat.c | 11 ++++++++--- > gdb/aarch64-tdep.c | 25 +++++++++++++++++++++++++ > gdb/aarch64-tdep.h | 2 ++ > 3 files changed, 35 insertions(+), 3 deletions(-) > > diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c > index a457fcd48ad8..5963e246b43f 100644 > --- a/gdb/aarch64-linux-nat.c > +++ b/gdb/aarch64-linux-nat.c > @@ -900,11 +900,16 @@ aarch64_linux_nat_target::thread_architecture (ptid_t ptid) > > /* We reach here if the vector length for the thread is different from its > value at process start. Lookup gdbarch via info (potentially creating a > - new one), stashing the vector length inside id. Use -1 for when SVE > - unavailable, to distinguish from an unset value of 0. */ > + new one) by using a target description that corresponds to the new vq value > + and the current architecture features. */ > + > + const struct target_desc *tdesc = gdbarch_target_desc (inf->gdbarch); > + aarch64_features features = aarch64_features_from_target_desc (tdesc); > + features.vq = vq; > + > struct gdbarch_info info; > info.bfd_arch_info = bfd_lookup_arch (bfd_arch_aarch64, bfd_mach_aarch64); > - info.id = (int *) (vq == 0 ? -1 : vq); Even though we're removing this code, we're still actively using info.id in aarch64_gdbarch_init (). Will that work correctly? > + info.target_desc = aarch64_create_target_description (features); The current mechanism caches potentially multiple target description (to account for threads having different VL's). Instead of creating a fresh target description here, would it make more sense to figure out the features from this particular thread and then check if we have the right target description already? Maybe through aarch64_linux_nat_target::read_description ()? See the code in gdb/aarch64-tdep.c:aarch64_read_description (), which fetches a cached target description and creates a fresh one if it doesn't exist. > return gdbarch_find_by_info (info); > } > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index 8670197a8889..8b89b877f8f0 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -3352,6 +3352,31 @@ aarch64_read_description (const aarch64_features &features) > return tdesc; > } > > +/* Get the AArch64 features present in the given target description. */ > + > +aarch64_features > +aarch64_features_from_target_desc (const struct target_desc *tdesc) > +{ > + aarch64_features features; > + const struct tdesc_feature *feature; > + > + if (tdesc == nullptr) > + return features; > + > + feature = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sve"); > + if (feature != nullptr) > + features.vq = tdesc_register_bitsize (feature, "z0") / 128; > + > + features.pauth > + = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth") != nullptr); > + features.mte > + = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.mte") != nullptr); > + features.tls > + = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.tls") != nullptr); > + > + return features; > +} > + > /* Return the VQ used when creating the target description TDESC. */ > > static uint64_t > diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h > index 5bdd733dce32..d8513023c376 100644 > --- a/gdb/aarch64-tdep.h > +++ b/gdb/aarch64-tdep.h > @@ -121,6 +121,8 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base > }; > > const target_desc *aarch64_read_description (const aarch64_features &features); > +aarch64_features > +aarch64_features_from_target_desc (const struct target_desc *tdesc); > > extern int aarch64_process_record (struct gdbarch *gdbarch, > struct regcache *regcache, CORE_ADDR addr);