From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81726 invoked by alias); 15 Jun 2018 16:18:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 81608 invoked by uid 89); 15 Jun 2018 16:18:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:support X-HELO: EUR04-VI1-obe.outbound.protection.outlook.com Received: from mail-eopbgr80075.outbound.protection.outlook.com (HELO EUR04-VI1-obe.outbound.protection.outlook.com) (40.107.8.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Jun 2018 16:18:51 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; Received: from C02TF0U7HF1T.arm.com (217.140.96.140) by DB6PR0802MB2133.eurprd08.prod.outlook.com (2603:10a6:4:83::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.17; Fri, 15 Jun 2018 16:18:36 +0000 From: Alan Hayward To: gdb-patches@sourceware.org Cc: nd@arm.com, Alan Hayward Subject: [PATCH v3 3/3] Ptrace support for AArch64 SVE gdbsever Date: Fri, 15 Jun 2018 16:18:00 -0000 Message-Id: <20180615161824.95787-4-alan.hayward@arm.com> In-Reply-To: <20180615161824.95787-1-alan.hayward@arm.com> References: <20180615161824.95787-1-alan.hayward@arm.com> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: LO2P265CA0159.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::27) To DB6PR0802MB2133.eurprd08.prod.outlook.com (2603:10a6:4:83::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dbad0172-d348-4a44-3beb-08d5d2dba5f3 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: DB6PR0802MB2133: NoDisclaimer: True X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Forefront-PRVS: 0704670F76 Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2018 16:18:36.3363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dbad0172-d348-4a44-3beb-08d5d2dba5f3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2133 X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00403.txt.bz2 Add checks to detect SVE tdesc. Easiest way to do this is by checking the size of the vector registers. Use the common aarch64 ptrace copy functions for reading/writing registers. A wrapper is required due to the common functions using reg_buffer_common. 2018-06-15 Alan Hayward gdbserver/ * linux-aarch64-low.c (is_sve_tdesc): New function. (aarch64_sve_regs_copy_to_regcache): Likewise. (aarch64_sve_regs_copy_from_regcache): Likewise. (aarch64_regs_info): Add SVE checks. (initialize_low_arch): Initialize SVE. --- gdb/gdbserver/linux-aarch64-low.c | 63 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 9db9a7c1c3..1d34e319df 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -41,6 +41,7 @@ #include "arch/aarch64.h" #include "linux-aarch64-tdesc.h" #include "nat/aarch64-sve-linux-ptrace.h" +#include "tdesc.h" #ifdef HAVE_SYS_REG_H #include @@ -73,6 +74,16 @@ is_64bit_tdesc (void) return register_size (regcache->tdesc, 0) == 8; } +/* Return true if the regcache contains the number of SVE registers. */ + +static bool +is_sve_tdesc (void) +{ + struct regcache *regcache = get_thread_regcache (current_thread, 0); + + return regcache->tdesc->reg_defs.size () == AARCH64_SVE_NUM_REGS; +} + /* Implementation of linux_target_ops method "cannot_store_register". */ static int @@ -514,6 +525,22 @@ aarch64_arch_setup (void) aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); } +/* Wrapper for aarch64_sve_regs_copy_to_reg_buf. */ + +static void +aarch64_sve_regs_copy_to_regcache (struct regcache *regcache, const void *buf) +{ + return aarch64_sve_regs_copy_to_reg_buf (regcache, buf); +} + +/* Wrapper for aarch64_sve_regs_copy_from_reg_buf. */ + +static void +aarch64_sve_regs_copy_from_regcache (struct regcache *regcache, void *buf) +{ + return aarch64_sve_regs_copy_from_reg_buf (regcache, buf); +} + static struct regset_info aarch64_regsets[] = { { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, @@ -540,15 +567,44 @@ static struct regs_info regs_info_aarch64 = &aarch64_regsets_info, }; +static struct regset_info aarch64_sve_regsets[] = +{ + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PRSTATUS, + sizeof (struct user_pt_regs), GENERAL_REGS, + aarch64_fill_gregset, aarch64_store_gregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_SVE, + SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE), EXTENDED_REGS, + aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache + }, + NULL_REGSET +}; + +static struct regsets_info aarch64_sve_regsets_info = + { + aarch64_sve_regsets, /* regsets. */ + 0, /* num_regsets. */ + NULL, /* disabled_regsets. */ + }; + +static struct regs_info regs_info_aarch64_sve = + { + NULL, /* regset_bitmap. */ + NULL, /* usrregs. */ + &aarch64_sve_regsets_info, + }; + /* Implementation of linux_target_ops method "regs_info". */ static const struct regs_info * aarch64_regs_info (void) { - if (is_64bit_tdesc ()) - return ®s_info_aarch64; - else + if (!is_64bit_tdesc ()) return ®s_info_aarch32; + + if (is_sve_tdesc ()) + return ®s_info_aarch64_sve; + + return ®s_info_aarch64; } /* Implementation of linux_target_ops method "supports_tracepoints". */ @@ -3027,6 +3083,7 @@ initialize_low_arch (void) initialize_low_arch_aarch32 (); initialize_regsets_info (&aarch64_regsets_info); + initialize_regsets_info (&aarch64_sve_regsets_info); #if GDB_SELF_TEST initialize_low_tdesc (); -- 2.15.1 (Apple Git-101)