From patchwork Thu Jul 11 18:03:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 33680 Received: (qmail 114658 invoked by alias); 11 Jul 2019 18:04:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 114649 invoked by uid 89); 11 Jul 2019 18:04:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR04-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr70073.outbound.protection.outlook.com (HELO EUR04-HE1-obe.outbound.protection.outlook.com) (40.107.7.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Jul 2019 18:04:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elzbclqBunG5zWyInfIK1OPpi5T9ENfr5+5pOZDUQ/YZgneFx8YswIr/CKMXCRoX4L6Fm4TY9EP3LlV8s+ME7+ZToeltKq9MwpLhW7cY9Tg8eysuKNBLTelts4K+JY4KRc7Y393m9dyJNw9LjgpqNOqrwiAmUzNQo4nb+KR4nF+YSCPDpZ9lExASgR8wG/KjT7wEsjXVDaAeOOtawHTto0IgCBdh7bL+setASJud9+qNV57HVE9BPnAIxfZTr/uaYR5gVPYhUPMB0AoSHHJjZ2YgJJozSLXID3op9GcBX726qTZWY2uzhhzVFfWATD4nuJmHr9C00mSgUVxc2lR4yg== 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-SenderADCheck; bh=yvqRU+G6f+9anQv8C+mdRLijqSnYhJn5DZo9b5R6y+M=; b=i++Y7dOMf84R43zgTkkJ8tcKllD8W2SYEACjKh9/3pAYMvsXXufMbGRWRFeQi4y7z7zVceyblaL6wRUzs7rXYpWbYWPCYEGlrejDMlLLAKABmVMQqbXmqO05iBHn5UwjHnHpzKV9O1SY3qRv5EhSoHleEdyup3RlVYFwzqgYKWKsrDT2/RdMSDyYILvYQpneXevLUL/i6W6N2vKgdMra2oG8rcc2ZcgeZ1LjVvoJdYwtmHmn9TBhD8Nh81IF/0wRIEygXGjHim0MmCb6ABwgREorxX92KJV4QI+keTUjOGbHM24JrCd81keDRElaMXgVwkx82NzdK0bhtdWkyWiIXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=temperror action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.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=yvqRU+G6f+9anQv8C+mdRLijqSnYhJn5DZo9b5R6y+M=; b=YBPbizvYk8z7nMNkyU5mPQ0RMNyhkmdl8ORFeGC8mbQF0rPySxV6q3KdxVCyu93u8NR4MnBM9foNnwEfctioKp+Y+HQ4J36BZPi0PDJ+Ah2NJt5ZuYHJ46T5E9iSQ4Wxx982f/Zhct3QmPDALyZS/VksWjkeQjv3/8hkyV7aV1g= Received: from DB6PR0802CA0028.eurprd08.prod.outlook.com (2603:10a6:4:a3::14) by AM5PR0801MB1842.eurprd08.prod.outlook.com (2603:10a6:203:3c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.10; Thu, 11 Jul 2019 18:03:56 +0000 Received: from VE1EUR03FT040.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::203) by DB6PR0802CA0028.outlook.office365.com (2603:10a6:4:a3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18 via Frontend Transport; Thu, 11 Jul 2019 18:03:55 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.org; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT040.mail.protection.outlook.com (10.152.18.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18 via Frontend Transport; Thu, 11 Jul 2019 18:03:55 +0000 Received: ("Tessian outbound 3dc70fbcc089:v24"); Thu, 11 Jul 2019 18:03:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d8090f37d8a84abc X-CR-MTA-TID: 64aa7808 Received: from 6ee072b585f8.1 (cr-mta-lb-1.cr-mta-net [104.47.6.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id DC6C082C-F47F-434C-A29C-B468FFA332B1.1; Thu, 11 Jul 2019 18:03:49 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02lp2059.outbound.protection.outlook.com [104.47.6.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6ee072b585f8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 11 Jul 2019 18:03:49 +0000 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=yvqRU+G6f+9anQv8C+mdRLijqSnYhJn5DZo9b5R6y+M=; b=YBPbizvYk8z7nMNkyU5mPQ0RMNyhkmdl8ORFeGC8mbQF0rPySxV6q3KdxVCyu93u8NR4MnBM9foNnwEfctioKp+Y+HQ4J36BZPi0PDJ+Ah2NJt5ZuYHJ46T5E9iSQ4Wxx982f/Zhct3QmPDALyZS/VksWjkeQjv3/8hkyV7aV1g= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2136.eurprd08.prod.outlook.com (10.172.225.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.19; Thu, 11 Jul 2019 18:03:47 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::259b:8edf:fb65:2760]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::259b:8edf:fb65:2760%8]) with mapi id 15.20.2052.020; Thu, 11 Jul 2019 18:03:47 +0000 From: Alan Hayward To: Simon Marchi CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH v2 1/5] Arm: Add read_description read funcs and use in GDB Date: Thu, 11 Jul 2019 18:03:47 +0000 Message-ID: <81151C3A-3B6D-4177-94B1-BD342F25ED4A@arm.com> References: <20190711134436.47896-1-alan.hayward@arm.com> <20190711134436.47896-2-alan.hayward@arm.com> In-Reply-To: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:DB6PR0802MB2136; X-MS-Exchange-PUrlCount: 1 x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:6430;OLM:6430; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(366004)(39860400002)(396003)(346002)(136003)(199004)(189003)(52314003)(6436002)(2906002)(91956017)(229853002)(66446008)(66946007)(66556008)(6486002)(305945005)(76116006)(478600001)(66476007)(64756008)(36756003)(30864003)(25786009)(14444005)(256004)(5024004)(486006)(476003)(14454004)(68736007)(4326008)(5660300002)(54906003)(33656002)(316002)(50226002)(102836004)(446003)(11346002)(2616005)(76176011)(6506007)(6116002)(53946003)(99286004)(86362001)(6512007)(57306001)(6246003)(66066001)(6306002)(8676002)(53546011)(71190400001)(71200400001)(53936002)(6916009)(7736002)(26005)(186003)(81156014)(81166006)(8936002)(3846002)(2004002)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2136; H:DB6PR0802MB2133.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: gJWqemqrRFDrOg8u6h/b3/erQDsgmRENVcLYj5iICEBhnVDTb7vSglQeGp3W/IBoorLv3t6DXYEcCs44mcuXDIHraaW5hOJJqa8XswpyLf24887w+ce/wmsv0idOda4KMvkIfS8H8DY2TEJjeoE/Mb7G7XhhrHNKpGwR+f6k1e0eSqMF/8yMRCqFEr/uWjf4H2XfWFdApmAOm4YNliHssO04SGjI9lyjbaMxT+FixfZgD7c0nA1qsjU4fYP5dcLvgiV+SUX/Fs1OIVhc3nXVQz1WagtgHsLlIpH+1l1kk5dtgxiFfvfuQDqIKdnOozm/esNnAoUJofRFJ9Dy7uIS6EmqMbOJ1sOwV+XD9q6A2ofTQAmwmxepQ57hHEYFezqxGpXULaqnkcS9HgNtTuJdxG7x0dTHo0nMYRtEUAGsU9c= Content-ID: MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; Return-Path: Alan.Hayward@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1b73a671-1412-40fa-082c-08d7062a1f2c X-IsSubscribed: yes > On 11 Jul 2019, at 14:57, Simon Marchi wrote: > > Oh, also please test rebuilding each patch against latest master, you will find the > places that need to be changed from "common" to "gdbsupport", such as here: > >> I had rebased, but looks like I had something left over causing the build to work. Fixed. > On 11 Jul 2019, at 15:19, Simon Marchi wrote: > > On 2019-07-11 9:46 a.m., Alan Hayward wrote: >> Switch the Arm target to get target descriptions via arm_read_description >> and aarch32_read_description, in the same style as other feature targets. >> Add an enum to specify the different types - this will also be of use to >> gdbserver in a later patch. >> >> Under the hood return the same existing pre-feature target descriptions. >> >> Note: This commit will break the AArch64 gdbserver build. > > Sorry for spamming you, one last thing :) > > I forgot to ask you, what is it in this patch that is breaking the AArch64 > gdbserver build in this? And what would it take for you not to break it? > > We generally try to keep things building at each commit, so I'd just like > a bit more justifications about why it's worth breaking it here, rather than > doing the necessary work to keep it building. > Annoyingly (for me) it’s just a single ifdef needed in arch/arm.c. I originally had patch 4 directly after patch 1, which would have then required adding the Arm files that get generated at build time into the aarch64 build. Anyway, fixed. Updated patch below: diff --git a/gdb/Makefile.in b/gdb/Makefile.in index b6680b9afd..62a59c90ea 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -665,7 +665,9 @@ ALL_64_TARGET_OBS = \ # All other target-dependent objects files (used with --enable-targets=all). ALL_TARGET_OBS = \ + aarch32-tdep.o \ arc-tdep.o \ + arch/aarch32.o \ arch/arm.o \ arch/arm-get-next-pcs.o \ arch/arm-linux.o \ @@ -1184,6 +1186,7 @@ SFILES = \ # right, it is probably easiest just to list .h files here directly. HFILES_NO_SRCDIR = \ + aarch32-tdep.h \ aarch64-ravenscar-thread.h \ aarch64-tdep.h \ ada-lang.h \ @@ -1429,6 +1432,7 @@ HFILES_NO_SRCDIR = \ xml-syscall.h \ xml-tdesc.h \ xtensa-tdep.h \ + arch/aarch32.h \ arch/aarch64.h \ arch/aarch64-insn.h \ arch/arm.h \ @@ -2133,6 +2137,7 @@ force_update: MAKEOVERRIDES = ALLDEPFILES = \ + aarch32-tdep.c \ aarch64-fbsd-nat.c \ aarch64-fbsd-tdep.c \ aarch64-linux-nat.c \ diff --git a/gdb/aarch32-tdep.c b/gdb/aarch32-tdep.c new file mode 100644 index 0000000000..12d464171c --- /dev/null +++ b/gdb/aarch32-tdep.c @@ -0,0 +1,33 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "gdbsupport/common-defs.h" +#include "gdbsupport/common-regcache.h" +#include "arch/aarch32.h" + +static struct target_desc *tdesc_aarch32; + +/* See aarch32-tdep.h. */ + +const target_desc * +aarch32_read_description () +{ + if (tdesc_aarch32 == nullptr) + tdesc_aarch32 = aarch32_create_target_description (); + + return tdesc_aarch32; +} diff --git a/gdb/aarch32-tdep.h b/gdb/aarch32-tdep.h new file mode 100644 index 0000000000..7fcea0adb9 --- /dev/null +++ b/gdb/aarch32-tdep.h @@ -0,0 +1,25 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef AARCH32_TDEP_H +#define AARCH32_TDEP_H + +/* Get the AArch32 target description. */ + +const target_desc *aarch32_read_description (); + +#endif /* aarch32-tdep.h. */ diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 7b60a9a0c3..2c1f4d9f98 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -30,6 +30,7 @@ #include "aarch64-tdep.h" #include "aarch64-linux-tdep.h" #include "aarch32-linux-nat.h" +#include "aarch32-tdep.h" #include "arch/arm.h" #include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" @@ -631,8 +632,6 @@ aarch64_linux_nat_target::post_attach (int pid) linux_nat_target::post_attach (pid); } -extern struct target_desc *tdesc_arm_with_neon; - /* Implement the "read_description" target_ops method. */ const struct target_desc * @@ -649,7 +648,7 @@ aarch64_linux_nat_target::read_description () ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec); if (ret == 0) - return tdesc_arm_with_neon; + return aarch32_read_description (); CORE_ADDR hwcap = linux_get_hwcap (this); diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c new file mode 100644 index 0000000000..14d6987d3f --- /dev/null +++ b/gdb/arch/aarch32.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "gdbsupport/common-defs.h" +#include "aarch32.h" + +extern struct target_desc *tdesc_arm_with_neon; + +/* See aarch32.h. */ + +target_desc * +aarch32_create_target_description () +{ + return tdesc_arm_with_neon; +} diff --git a/gdb/arch/aarch32.h b/gdb/arch/aarch32.h new file mode 100644 index 0000000000..d2c0047216 --- /dev/null +++ b/gdb/arch/aarch32.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef ARCH_AARCH32_H +#define ARCH_AARCH32_H + +#include "gdbsupport/tdesc.h" + +/* Create the AArch32 target description. */ + +target_desc *aarch32_create_target_description (); + +#endif /* aarch32.h. */ diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c index 860ce02858..7a0f36e4c4 100644 --- a/gdb/arch/arm.c +++ b/gdb/arch/arm.c @@ -21,6 +21,17 @@ #include "gdbsupport/common-regcache.h" #include "arm.h" +extern struct target_desc *tdesc_arm_with_vfpv2; +extern struct target_desc *tdesc_arm_with_vfpv3; +extern struct target_desc *tdesc_arm_with_iwmmxt; + +/* Temporary ifdef. Will be removed when target descriptions are switched. */ +#ifndef GDBSERVER +extern struct target_desc *tdesc_arm_with_m; +extern struct target_desc *tdesc_arm_with_m_vfp_d16; +extern struct target_desc *tdesc_arm_with_m_fpa_layout; +#endif + /* See arm.h. */ int @@ -372,3 +383,52 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst, return res & 0xffffffff; } + +/* See arch/arm.h. */ + +target_desc * +arm_create_target_description (arm_fp_type fp_type) +{ + switch (fp_type) + { + case ARM_FP_TYPE_NONE: + return nullptr; +/* Temporary ifdef. Will be removed when target descriptions are switched. */ +#ifndef GDBSERVER + case ARM_FP_TYPE_VFPV2: + return tdesc_arm_with_vfpv2; + + case ARM_FP_TYPE_VFPV3: + return tdesc_arm_with_vfpv3; + + case ARM_FP_TYPE_IWMMXT: + return tdesc_arm_with_iwmmxt; +#endif + default: + error (_("Invalid Arm FP type: %d"), fp_type); + } +} + +/* See arch/arm.h. */ + +target_desc * +arm_create_mprofile_target_description (arm_m_profile_type m_type) +{ + switch (m_type) + { +/* Temporary ifdef. Will be removed when target descriptions are switched. */ +#ifndef GDBSERVER + case ARM_M_TYPE_M_PROFILE: + return tdesc_arm_with_m; + + case ARM_M_TYPE_VFP_D16: + return tdesc_arm_with_m_fpa_layout; + + case ARM_M_TYPE_WITH_FPA: + return tdesc_arm_with_m_vfp_d16; +#endif + default: + error (_("Invalid Arm M type: %d"), m_type); + } +} + diff --git a/gdb/arch/arm.h b/gdb/arch/arm.h index dfbbd56d28..58511c7c6b 100644 --- a/gdb/arch/arm.h +++ b/gdb/arch/arm.h @@ -19,6 +19,8 @@ #ifndef ARCH_ARM_H #define ARCH_ARM_H +#include "gdbsupport/tdesc.h" + /* Register numbers of various important registers. */ enum gdb_regnum { @@ -66,6 +68,23 @@ enum arm_breakpoint_kinds ARM_BP_KIND_ARM = 4, }; +/* Supported Arm FP hardware types. */ +enum arm_fp_type { + ARM_FP_TYPE_NONE = 0, + ARM_FP_TYPE_VFPV2, + ARM_FP_TYPE_VFPV3, + ARM_FP_TYPE_IWMMXT, + ARM_FP_TYPE_INVALID +}; + +/* Supported M-profile Arm types. */ +enum arm_m_profile_type { + ARM_M_TYPE_M_PROFILE, + ARM_M_TYPE_VFP_D16, + ARM_M_TYPE_WITH_FPA, + ARM_M_TYPE_INVALID +}; + /* Instruction condition field values. */ #define INST_EQ 0x0 #define INST_NE 0x1 @@ -165,4 +184,12 @@ unsigned long shifted_reg_val (struct regcache *regcache, unsigned long pc_val, unsigned long status_reg); +/* Create an Arm target description with the given FP hardware type. */ + +target_desc *arm_create_target_description (arm_fp_type fp_type); + +/* Create an Arm M-profile target description with the given hardware type. */ + +target_desc *arm_create_mprofile_target_description (arm_m_profile_type m_type); + #endif /* ARCH_ARM_H */ diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index dea3abbdd3..6e1af9cda3 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -20,6 +20,8 @@ #include "defs.h" #include "elf/common.h" +#include "target-descriptions.h" +#include "aarch32-tdep.h" #include "arm-tdep.h" #include "arm-fbsd-tdep.h" #include "auxv.h" @@ -178,20 +180,20 @@ arm_fbsd_read_description_auxv (struct target_ops *target) CORE_ADDR arm_hwcap = 0; if (target_auxv_search (target, AT_FREEBSD_HWCAP, &arm_hwcap) != 1) - return NULL; + return nullptr; if (arm_hwcap & HWCAP_VFP) { if (arm_hwcap & HWCAP_NEON) - return tdesc_arm_with_neon; + return aarch32_read_description (); else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32)) == (HWCAP_VFPv3 | HWCAP_VFPD32)) - return tdesc_arm_with_vfpv3; + return arm_read_description (ARM_FP_TYPE_VFPV3); else - return tdesc_arm_with_vfpv2; + return arm_read_description (ARM_FP_TYPE_VFPV2); } - return NULL; + return nullptr; } /* Implement the "core_read_description" gdbarch method. */ diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index fe8a113a27..6a374bbc74 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -27,6 +27,7 @@ #include "observable.h" #include "gdbthread.h" +#include "aarch32-tdep.h" #include "arm-tdep.h" #include "arm-linux-tdep.h" #include "aarch32-linux-nat.h" @@ -551,7 +552,7 @@ arm_linux_nat_target::read_description () } if (arm_hwcap & HWCAP_IWMMXT) - return tdesc_arm_with_iwmmxt; + return arm_read_description (ARM_FP_TYPE_IWMMXT); if (arm_hwcap & HWCAP_VFP) { @@ -566,11 +567,11 @@ arm_linux_nat_target::read_description () /* NEON implies VFPv3-D32 or no-VFP unit. Say that we only support Neon with VFPv3-D32. */ if (arm_hwcap & HWCAP_NEON) - return tdesc_arm_with_neon; + return aarch32_read_description (); else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) - return tdesc_arm_with_vfpv3; - else - return tdesc_arm_with_vfpv2; + return arm_read_description (ARM_FP_TYPE_VFPV3); + + return arm_read_description (ARM_FP_TYPE_VFPV2); } return this->beneath ()->read_description (); diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index d846749e0b..aec20877d9 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -33,6 +33,7 @@ #include "auxv.h" #include "xml-syscall.h" +#include "aarch32-tdep.h" #include "arch/arm.h" #include "arch/arm-get-next-pcs.h" #include "arch/arm-linux.h" @@ -738,14 +739,14 @@ arm_linux_core_read_description (struct gdbarch *gdbarch, /* NEON implies VFPv3-D32 or no-VFP unit. Say that we only support Neon with VFPv3-D32. */ if (arm_hwcap & HWCAP_NEON) - return tdesc_arm_with_neon; + return aarch32_read_description (); else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) - return tdesc_arm_with_vfpv3; - else - return tdesc_arm_with_vfpv2; + return arm_read_description (ARM_FP_TYPE_VFPV3); + + return arm_read_description (ARM_FP_TYPE_VFPV2); } - return NULL; + return nullptr; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index c1ee39714f..1b19b72ca1 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -240,6 +240,10 @@ static const char **valid_disassembly_styles; /* Disassembly style to use. Default to "std" register names. */ static const char *disassembly_style; +/* All possible arm target descriptors. */ +static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID]; +static struct target_desc *tdesc_arm_mprofile_list[ARM_M_TYPE_INVALID]; + /* This is used to keep the bfd arch_info in sync with the disassembly style. */ static void set_disassembly_style_sfunc (const char *, int, @@ -8739,7 +8743,6 @@ arm_register_reggroup_p (struct gdbarch *gdbarch, int regnum, return default_register_reggroup_p (gdbarch, regnum, group); } -^L /* For backward-compatibility we allow two 'g' packet lengths with the remote protocol depending on whether FPA registers are supplied. M-profile targets do not have FPA registers, but some @@ -8753,21 +8756,26 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch) { if (gdbarch_tdep (gdbarch)->is_m) { + const target_desc *tdesc; + /* If we know from the executable this is an M-profile target, cater for remote targets whose register set layout is the same as the FPA layout. */ + tdesc = arm_read_mprofile_description (ARM_M_TYPE_WITH_FPA); register_remote_g_packet_guess (gdbarch, ARM_CORE_REGS_SIZE + ARM_FP_REGS_SIZE, - tdesc_arm_with_m_fpa_layout); + tdesc); /* The regular M-profile layout. */ + tdesc = arm_read_mprofile_description (ARM_M_TYPE_M_PROFILE); register_remote_g_packet_guess (gdbarch, ARM_CORE_REGS_SIZE, - tdesc_arm_with_m); + tdesc); /* M-profile plus M4F VFP. */ + tdesc = arm_read_mprofile_description (ARM_M_TYPE_VFP_D16); register_remote_g_packet_guess (gdbarch, ARM_CORE_REGS_SIZE + ARM_VFP2_REGS_SIZE, - tdesc_arm_with_m_vfp_d16); + tdesc); } /* Otherwise we don't have a useful guess. */ @@ -13310,3 +13318,35 @@ arm_process_record (struct gdbarch *gdbarch, struct regcache *regcache, return ret; } + +/* See arm-tdep.h. */ + +const target_desc * +arm_read_description (arm_fp_type fp_type) +{ + struct target_desc *tdesc = tdesc_arm_list[fp_type]; + + if (tdesc == nullptr) + { + tdesc = arm_create_target_description (fp_type); + tdesc_arm_list[fp_type] = tdesc; + } + + return tdesc; +} + +/* See arm-tdep.h. */ + +const target_desc * +arm_read_mprofile_description (arm_m_profile_type m_type) +{ + struct target_desc *tdesc = tdesc_arm_mprofile_list[m_type]; + + if (tdesc == nullptr) + { + tdesc = arm_create_mprofile_target_description (m_type); + tdesc_arm_mprofile_list[m_type] = tdesc; + } + + return tdesc; +} diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h index 36d2d381cf..6d1a91ca35 100644 --- a/gdb/arm-tdep.h +++ b/gdb/arm-tdep.h @@ -281,11 +281,11 @@ extern void void *cb_data, const struct regcache *regcache); -/* Target descriptions. */ -extern struct target_desc *tdesc_arm_with_m; -extern struct target_desc *tdesc_arm_with_iwmmxt; -extern struct target_desc *tdesc_arm_with_vfpv2; -extern struct target_desc *tdesc_arm_with_vfpv3; -extern struct target_desc *tdesc_arm_with_neon; +/* Get the correct Arm target description with given FP hardware type. */ +const target_desc *arm_read_description (arm_fp_type fp_type); + +/* Get the correct Arm M-Profile target description with given hardware + type. */ +const target_desc *arm_read_mprofile_description (arm_m_profile_type m_type); #endif /* arm-tdep.h */ diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 27f122ad04..7c0215e89a 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -48,8 +48,9 @@ amd64_tobjs="amd64-tdep.o arch/amd64.o ${x86_tobjs}" case "${targ}" in aarch64*-*-*) - cpu_obs="aarch64-tdep.o arch/aarch64-insn.o arch/aarch64.o \ - ravenscar-thread.o aarch64-ravenscar-thread.o";; + cpu_obs="aarch32-tdep.o aarch64-tdep.o arch/aarch32.o \ + arch/aarch64-insn.o arch/aarch64.o ravenscar-thread.o \ + aarch64-ravenscar-thread.o";; alpha*-*-*) # Target: Alpha @@ -62,7 +63,8 @@ arc*-*-*) ;; arm*-*-*) - cpu_obs="arch/arm.o arch/arm-get-next-pcs.o arm-tdep.o";; + cpu_obs="aarch32-tdep.o arch/aarch32.o arch/arm.o \ + arch/arm-get-next-pcs.o arm-tdep.o";; hppa*-*-*) # Target: HP PA-RISC