From patchwork Thu Jul 11 13:46:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 33674 Received: (qmail 19774 invoked by alias); 11 Jul 2019 13:46:45 -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 19693 invoked by uid 89); 11 Jul 2019 13:46:44 -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=auto-generated X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30077.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.77) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Jul 2019 13:46:40 +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=E2lwBIXLqFIpirlT1LuexNIH1LmSMErrUEjIsbWg/+s=; b=WjkijLJxDn5LJSNBHOWXknGoyS6OTq+GkrBayCoyeVIfbW4qmIHc7OeHIctfQpftQv9WfV7zXh5i0lvoYQHoqZ+biZQCSZz8o9qcBuvdhwGIbS5ac3NfkpKY3iNAyzdmSPZkWwVLDffQWesMiVRT8HNQv/NXb6QJ3TxGA3JBFyw= Received: from VI1PR08CA0204.eurprd08.prod.outlook.com (2603:10a6:800:d2::34) by DB6PR0802MB2600.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.16; Thu, 11 Jul 2019 13:46:36 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR08CA0204.outlook.office365.com (2603:10a6:800:d2::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2073.10 via Frontend Transport; Thu, 11 Jul 2019 13:46:35 +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 DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) 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 13:46:34 +0000 Received: ("Tessian outbound c2673421c4c6:v24"); Thu, 11 Jul 2019 13:46:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fe64de169de4d1d3 X-CR-MTA-TID: 64aa7808 Received: from 9503e1f65304.1 (cr-mta-lb-1.cr-mta-net [104.47.8.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 633049DA-B735-4B9F-B08C-102FA0A95CAC.1; Thu, 11 Jul 2019 13:46:29 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2057.outbound.protection.outlook.com [104.47.8.57]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9503e1f65304.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 11 Jul 2019 13:46:29 +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=E2lwBIXLqFIpirlT1LuexNIH1LmSMErrUEjIsbWg/+s=; b=WjkijLJxDn5LJSNBHOWXknGoyS6OTq+GkrBayCoyeVIfbW4qmIHc7OeHIctfQpftQv9WfV7zXh5i0lvoYQHoqZ+biZQCSZz8o9qcBuvdhwGIbS5ac3NfkpKY3iNAyzdmSPZkWwVLDffQWesMiVRT8HNQv/NXb6QJ3TxGA3JBFyw= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2232.eurprd08.prod.outlook.com (10.172.226.144) 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 13:46:27 +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 13:46:27 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH v2 4/5] Arm: Use read_description funcs in gdbserver Date: Thu, 11 Jul 2019 13:46:27 +0000 Message-ID: <20190711134436.47896-5-alan.hayward@arm.com> References: <20190711134436.47896-1-alan.hayward@arm.com> In-Reply-To: <20190711134436.47896-1-alan.hayward@arm.com> 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:DB6PR0802MB2232; X-MS-Exchange-PUrlCount: 1 x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:5797;OLM:5797; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(376002)(396003)(136003)(366004)(39860400002)(199004)(189003)(53936002)(99286004)(66476007)(66556008)(64756008)(2906002)(6306002)(66946007)(446003)(71200400001)(5640700003)(478600001)(2501003)(66446008)(44832011)(186003)(71190400001)(316002)(53946003)(1076003)(6436002)(6512007)(486006)(6916009)(2351001)(66066001)(6486002)(76176011)(476003)(102836004)(386003)(52116002)(6506007)(30864003)(8676002)(11346002)(68736007)(50226002)(26005)(86362001)(7736002)(81166006)(81156014)(2616005)(14454004)(6116002)(4326008)(305945005)(3846002)(36756003)(5660300002)(256004)(54906003)(8936002)(25786009)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2232; 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: PytSQCDSC2qrdH7flulv5JVjgSgjh82gUxM+rsKQiqxQi+cIUYgFXE+ItOh+tc6/3FYDGiXNLNQM7y5HhtZ/nW5GccrQ+LZcZnbfHkDU9D1Ank3IzZ1sqJPfB5LZkROUEEYw1OtJuuGBPNIR8gYz7cBeJ9P1k2IkNiJfCCsjbNR7+UwYRjiF2VEOsVOI9QQvFj8aHG8oE0ibJHqbirD8LEOWNUMWMOatGpWHdfj44u8p6wShVTIueB+aS9vYcT5aY1YlcF6IDaXAxqFrdTJUJzVtzx+oyRioE0zI067PCKqniUcuqk2QLvkrvBLPZEivGku01TfS0C3mxpng4WTr2/PVw0RM2xkN2MfE9Sr4InTNOaYVtSXBAKN9Sv6/xPYfZgkP056crW7xubGpgw8+D5QN7+02KcsuVldVWZ3CA6U= 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: DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 72b5fbce-def4-4f5f-306c-08d706062b88 X-IsSubscribed: yes Switch gdbserver over to using feature target descriptions. Add a function for determining the type of a given target description, and use where required. 2019-07-11 Alan Hayward * configure.srv: Add new files. Remove xml generated files. * linux-aarch32-low.c (initialize_low_arch_aarch32): Don't init registers. * linux-aarch32-low.h (tdesc_arm_with_neon): Remove. * linux-aarch32-tdesc.c: New file. * linux-aarch32-tdesc.h: New file. * linux-aarch64-low.c (aarch64_arch_setup): Call aarch32_linux_read_description. * linux-arm-low.c (init_registers_arm, tdesc_arm) (init_registers_arm_with_iwmmxt, tdesc_arm_with_iwmmxt) (init_registers_arm_with_vfpv2, tdesc_arm_with_vfpv2) (init_registers_arm_with_vfpv3, tdesc_arm_with_vfpv3): Remove. (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) (arm_store_vfpregset): Call arm_linux_get_tdesc_fp_type. (arm_read_description): Call arm_linux_read_description. (initialize_low_arch): Don't init registers. * linux-arm-tdesc.c: New file. * linux-arm-tdesc.h: New file. --- gdb/gdbserver/configure.srv | 14 +++--- gdb/gdbserver/linux-aarch32-low.c | 2 - gdb/gdbserver/linux-aarch32-low.h | 2 - gdb/gdbserver/linux-aarch32-tdesc.c | 46 +++++++++++++++++ gdb/gdbserver/linux-aarch32-tdesc.h | 29 +++++++++++ gdb/gdbserver/linux-aarch64-low.c | 3 +- gdb/gdbserver/linux-arm-low.c | 77 ++++++++++++++--------------- gdb/gdbserver/linux-arm-tdesc.c | 62 +++++++++++++++++++++++ gdb/gdbserver/linux-arm-tdesc.h | 29 +++++++++++ 9 files changed, 211 insertions(+), 53 deletions(-) create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.c create mode 100644 gdb/gdbserver/linux-aarch32-tdesc.h create mode 100644 gdb/gdbserver/linux-arm-tdesc.c create mode 100644 gdb/gdbserver/linux-arm-tdesc.h diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index c20177ef18..097dc4e9db 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -33,9 +33,10 @@ srv_linux_obj="linux-low.o linux-osdata.o linux-procfs.o linux-ptrace.o linux-wa # Input is taken from the "${target}" variable. case "${target}" in - aarch64*-*-linux*) srv_regobj="arm-with-neon.o" - srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o" + aarch64*-*-linux*) srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o" srv_tgtobj="$srv_tgtobj linux-aarch32-low.o" + srv_tgtobj="$srv_tgtobj linux-aarch32-tdesc.o" + srv_tgtobj="${srv_tgtobj} arch/aarch32.o" srv_tgtobj="${srv_tgtobj} arch/arm.o" srv_tgtobj="$srv_tgtobj aarch64-linux.o" srv_tgtobj="$srv_tgtobj arch/aarch64-insn.o" @@ -49,12 +50,11 @@ case "${target}" in ipa_obj="${ipa_obj} linux-aarch64-tdesc-ipa.o" ipa_obj="${ipa_obj} arch/aarch64-ipa.o" ;; - arm*-*-linux*) srv_regobj="reg-arm.o arm-with-iwmmxt.o" - srv_regobj="${srv_regobj} arm-with-vfpv2.o" - srv_regobj="${srv_regobj} arm-with-vfpv3.o" - srv_regobj="${srv_regobj} arm-with-neon.o" - srv_tgtobj="$srv_linux_obj linux-arm-low.o" + arm*-*-linux*) srv_tgtobj="$srv_linux_obj linux-arm-low.o" + srv_tgtobj="$srv_tgtobj linux-arm-tdesc.o" srv_tgtobj="$srv_tgtobj linux-aarch32-low.o" + srv_tgtobj="$srv_tgtobj linux-aarch32-tdesc.o" + srv_tgtobj="${srv_tgtobj} arch/aarch32.o" srv_tgtobj="${srv_tgtobj} arch/arm.o" srv_tgtobj="${srv_tgtobj} arch/arm-linux.o" srv_tgtobj="${srv_tgtobj} arch/arm-get-next-pcs.o" diff --git a/gdb/gdbserver/linux-aarch32-low.c b/gdb/gdbserver/linux-aarch32-low.c index a932373518..f1f2ae02a4 100644 --- a/gdb/gdbserver/linux-aarch32-low.c +++ b/gdb/gdbserver/linux-aarch32-low.c @@ -299,7 +299,5 @@ arm_breakpoint_kind_from_current_state (CORE_ADDR *pcptr) void initialize_low_arch_aarch32 (void) { - init_registers_arm_with_neon (); - initialize_regsets_info (&aarch32_regsets_info); } diff --git a/gdb/gdbserver/linux-aarch32-low.h b/gdb/gdbserver/linux-aarch32-low.h index 44e626c719..3078fca35e 100644 --- a/gdb/gdbserver/linux-aarch32-low.h +++ b/gdb/gdbserver/linux-aarch32-low.h @@ -36,6 +36,4 @@ void initialize_low_arch_aarch32 (void); void init_registers_arm_with_neon (void); int arm_is_thumb_mode (void); -extern const struct target_desc *tdesc_arm_with_neon; - #endif /* GDBSERVER_LINUX_AARCH32_LOW_H */ diff --git a/gdb/gdbserver/linux-aarch32-tdesc.c b/gdb/gdbserver/linux-aarch32-tdesc.c new file mode 100644 index 0000000000..3c26df1f96 --- /dev/null +++ b/gdb/gdbserver/linux-aarch32-tdesc.c @@ -0,0 +1,46 @@ +/* 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 "server.h" +#include "tdesc.h" +#include "arch/aarch32.h" +#include + +static struct target_desc *tdesc_aarch32; + +/* See linux-aarch32-tdesc.h. */ + +const target_desc * +aarch32_linux_read_description () +{ + if (tdesc_aarch32 == nullptr) + { + tdesc_aarch32 = aarch32_create_target_description (); + + static const char *expedite_regs[] = { "r11", "sp", "pc", 0 }; + init_target_desc (tdesc_aarch32, expedite_regs); + } + return tdesc_aarch32; +} + +/* See linux-aarch32-tdesc.h. */ + +bool +is_aarch32_linux_description (const target_desc *tdesc) +{ + return tdesc != nullptr && tdesc == tdesc_aarch32; +} diff --git a/gdb/gdbserver/linux-aarch32-tdesc.h b/gdb/gdbserver/linux-aarch32-tdesc.h new file mode 100644 index 0000000000..8887cbfdf4 --- /dev/null +++ b/gdb/gdbserver/linux-aarch32-tdesc.h @@ -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 . */ + +#ifndef GDBSERVER_LINUX_AARCH32_TDESC_H +#define GDBSERVER_LINUX_AARCH32_TDESC_H + +/* Return the AArch32 target description. */ + +const target_desc * aarch32_linux_read_description (); + +/* Return true if TDESC is the AArch32 target description. */ + +bool is_aarch32_linux_description (const target_desc *tdesc); + +#endif /* linux-aarch32-tdesc.h. */ diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 5aea5de372..ab2f40ea98 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -39,6 +39,7 @@ #include "gdb_proc_service.h" #include "arch/aarch64.h" +#include "linux-aarch32-tdesc.h" #include "linux-aarch64-tdesc.h" #include "nat/aarch64-sve-linux-ptrace.h" #include "tdesc.h" @@ -527,7 +528,7 @@ aarch64_arch_setup (void) current_process ()->tdesc = aarch64_linux_read_description (vq, pauth_p); } else - current_process ()->tdesc = tdesc_arm_with_neon; + current_process ()->tdesc = aarch32_linux_read_description (); aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); } diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index 7d6c9d9dd9..0e30af3562 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -22,6 +22,8 @@ #include "arch/arm-linux.h" #include "arch/arm-get-next-pcs.h" #include "linux-aarch32-low.h" +#include "linux-aarch32-tdesc.h" +#include "linux-arm-tdesc.h" #include /* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h. @@ -33,19 +35,6 @@ #include #include -/* Defined in auto-generated files. */ -void init_registers_arm (void); -extern const struct target_desc *tdesc_arm; - -void init_registers_arm_with_iwmmxt (void); -extern const struct target_desc *tdesc_arm_with_iwmmxt; - -void init_registers_arm_with_vfpv2 (void); -extern const struct target_desc *tdesc_arm_with_vfpv2; - -void init_registers_arm_with_vfpv3 (void); -extern const struct target_desc *tdesc_arm_with_vfpv3; - #ifndef PTRACE_GET_THREAD_AREA #define PTRACE_GET_THREAD_AREA 22 #endif @@ -175,7 +164,7 @@ arm_cannot_fetch_register (int regno) static void arm_fill_wmmxregset (struct regcache *regcache, void *buf) { - if (regcache->tdesc != tdesc_arm_with_iwmmxt) + if (arm_linux_get_tdesc_fp_type (regcache->tdesc) != ARM_FP_TYPE_IWMMXT) return; for (int i = 0; i < 16; i++) @@ -190,7 +179,7 @@ arm_fill_wmmxregset (struct regcache *regcache, void *buf) static void arm_store_wmmxregset (struct regcache *regcache, const void *buf) { - if (regcache->tdesc != tdesc_arm_with_iwmmxt) + if (arm_linux_get_tdesc_fp_type (regcache->tdesc) != ARM_FP_TYPE_IWMMXT) return; for (int i = 0; i < 16; i++) @@ -207,13 +196,19 @@ arm_fill_vfpregset (struct regcache *regcache, void *buf) { int num; - if (regcache->tdesc == tdesc_arm_with_neon - || regcache->tdesc == tdesc_arm_with_vfpv3) + if (is_aarch32_linux_description (regcache->tdesc)) num = 32; - else if (regcache->tdesc == tdesc_arm_with_vfpv2) - num = 16; else - return; + { + arm_fp_type fp_type = arm_linux_get_tdesc_fp_type (regcache->tdesc); + + if (fp_type == ARM_FP_TYPE_VFPV3) + num = 32; + else if (fp_type == ARM_FP_TYPE_VFPV2) + num = 16; + else + return; + } arm_fill_vfpregset_num (regcache, buf, num); } @@ -230,13 +225,19 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf) { int num; - if (regcache->tdesc == tdesc_arm_with_neon - || regcache->tdesc == tdesc_arm_with_vfpv3) + if (is_aarch32_linux_description (regcache->tdesc)) num = 32; - else if (regcache->tdesc == tdesc_arm_with_vfpv2) - num = 16; else - return; + { + arm_fp_type fp_type = arm_linux_get_tdesc_fp_type (regcache->tdesc); + + if (fp_type == ARM_FP_TYPE_VFPV3) + num = 32; + else if (fp_type == ARM_FP_TYPE_VFPV2) + num = 16; + else + return; + } arm_store_vfpregset_num (regcache, buf, num); } @@ -849,7 +850,7 @@ arm_read_description (void) unsigned long arm_hwcap = linux_get_hwcap (4); if (arm_hwcap & HWCAP_IWMMXT) - return tdesc_arm_with_iwmmxt; + return arm_linux_read_description (ARM_FP_TYPE_IWMMXT); if (arm_hwcap & HWCAP_VFP) { @@ -859,21 +860,21 @@ arm_read_description (void) errno = 0; char *buf = (char *) alloca (ARM_VFP3_REGS_SIZE); if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0 && errno == EIO) - return tdesc_arm; + return arm_linux_read_description (ARM_FP_TYPE_NONE); /* NEON implies either no VFP, or VFPv3-D32. We only support it with VFP. */ if (arm_hwcap & HWCAP_NEON) - return tdesc_arm_with_neon; + return aarch32_linux_read_description (); else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) - return tdesc_arm_with_vfpv3; + return arm_linux_read_description (ARM_FP_TYPE_VFPV3); else - return tdesc_arm_with_vfpv2; + return arm_linux_read_description (ARM_FP_TYPE_VFPV2); } /* The default configuration uses legacy FPA registers, probably simulated. */ - return tdesc_arm; + return arm_linux_read_description (ARM_FP_TYPE_NONE); } static void @@ -997,10 +998,11 @@ arm_regs_info (void) const struct target_desc *tdesc = current_process ()->tdesc; if (have_ptrace_getregset == 1 - && (tdesc == tdesc_arm_with_neon || tdesc == tdesc_arm_with_vfpv3)) + && (is_aarch32_linux_description (tdesc) + || arm_linux_get_tdesc_fp_type (tdesc) == ARM_FP_TYPE_VFPV3)) return ®s_info_aarch32; - else - return ®s_info_arm; + + return ®s_info_arm; } struct linux_target_ops the_low_target = { @@ -1045,13 +1047,6 @@ struct linux_target_ops the_low_target = { void initialize_low_arch (void) { - /* Initialize the Linux target descriptions. */ - init_registers_arm (); - init_registers_arm_with_iwmmxt (); - init_registers_arm_with_vfpv2 (); - init_registers_arm_with_vfpv3 (); - initialize_low_arch_aarch32 (); - initialize_regsets_info (&arm_regsets_info); } diff --git a/gdb/gdbserver/linux-arm-tdesc.c b/gdb/gdbserver/linux-arm-tdesc.c new file mode 100644 index 0000000000..cdc4dab87a --- /dev/null +++ b/gdb/gdbserver/linux-arm-tdesc.c @@ -0,0 +1,62 @@ +/* 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 "server.h" +#include "tdesc.h" +#include "arch/arm.h" +#include + +/* All possible Arm target descriptors. */ +static struct target_desc *tdesc_arm_list[ARM_FP_TYPE_INVALID]; + +/* See linux-arm-tdesc.h. */ + +const target_desc * +arm_linux_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); + + static const char *expedite_regs[] = { "r11", "sp", "pc", 0 }; + init_target_desc (tdesc, expedite_regs); + + tdesc_arm_list[fp_type] = tdesc; + } + + return tdesc; +} + +/* See linux-arm-tdesc.h. */ + +arm_fp_type +arm_linux_get_tdesc_fp_type (const target_desc *tdesc) +{ + gdb_assert (tdesc != nullptr); + + /* Many of the tdesc_arm_list entries may not have been initialised yet. This + is ok, because tdesc must be one of the initialised ones. */ + for (int i = ARM_FP_TYPE_NONE; i < ARM_FP_TYPE_INVALID; i++) + { + if (tdesc == tdesc_arm_list[i]) + return (arm_fp_type) i; + } + + return ARM_FP_TYPE_INVALID; +} diff --git a/gdb/gdbserver/linux-arm-tdesc.h b/gdb/gdbserver/linux-arm-tdesc.h new file mode 100644 index 0000000000..51efb9fb48 --- /dev/null +++ b/gdb/gdbserver/linux-arm-tdesc.h @@ -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 . */ + +#ifndef GDBSERVER_LINUX_ARM_TDESC_H +#define GDBSERVER_LINUX_ARM_TDESC_H + +/* Return the Arm target description with fp registers FP_TYPE. */ + +const target_desc * arm_linux_read_description (arm_fp_type fp_type); + +/* For a target description TDESC, return its fp type. */ + +arm_fp_type arm_linux_get_tdesc_fp_type (const target_desc *tdesc); + +#endif /* linux-arm-tdesc.h. */