From patchwork Mon Nov 6 10:06:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 24103 Received: (qmail 36756 invoked by alias); 6 Nov 2017 10:06:34 -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 36735 invoked by uid 89); 6 Nov 2017 10:06:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL, BAYES_50, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Hauthentication-results:sender, Hx-exchange-antispam-report-cfa-test:6072148, Hx-exchange-antispam-report-cfa-test:3231021, Hx-exchange-antispam-report-cfa-test:201703061406153 X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0052.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Nov 2017 10:06:30 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0104.eurprd08.prod.outlook.com (10.160.211.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Mon, 6 Nov 2017 10:06:26 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::2891:52f2:59:8e54]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::2891:52f2:59:8e54%16]) with mapi id 15.20.0197.019; Mon, 6 Nov 2017 10:06:26 +0000 From: Alan Hayward To: Yao Qi CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH 1/4] Add aarch64_create_target_description Date: Mon, 6 Nov 2017 10:06:25 +0000 Message-ID: <06096E40-6CB8-4FD9-A87A-F33CA80B64BA@arm.com> References: <04DE907F-329F-4AB5-9EB1-4F83E05C992E@arm.com> <86tvygyhfc.fsf@gmail.com> In-Reply-To: <86tvygyhfc.fsf@gmail.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0104; 6:L6XwR/ZXDHXk9xxdOq4MKRkXA/LGnzDhHFb7mQgcl3eRqX4+1Vmo3Ewf6BqRva8Jy4yH6TDAb5Wizsc7DVZiGcKTnaBLHUT7nzCv0o37uuwRsq3lI8bwA4A8mqBDxN4mLr6fAdGFZWgsIuSjIFb4zfnle4lqgrwrqZmBIw+frAWDGqrhkOmCcLZ/MY2aTAzSkgKOxd0HbWfpBGE6Ssv2ucUbV3md5NGtGKF+yhhL8AeOEGafdiLRDNkuKDgFMpq9UkK1Zd+qqWaQBDg4+hdPi3smDvUlFbI7iWu0wdnumfFTyQBV3ZFfirOg3v8C+yFVCzGK7k0c4m7sdZlcUcYFq4sZAURALr1OuBLJIXFf0FM=; 5:Ia6RfQe/LB6mAzJBavLrBYLwvYD/zerfrDrwLsZYrclVPSU8J6qFewtmgyvJHYa1FQKK/cRg8fNAXHTsS0Kvh/lr373SD9oP7myiT2KuODet3sZ+uoXqT/OWRyR0kYbRQHCa9SHFX9gYOxa2PUM69DGkTYGAeyvsXWoHcZ2hZsk=; 24:8vJZ5ING8GLUCPH81SYvYKzYXtZWK+z2iD1xCPGVxtlpMbC139OIsUsmBdwpclJ7+4vVKFphc4gJ9knHQCaUbSHkXOVp0CHUU1R74yHM+9w=; 7:+tDpu4p6ZIjsIH5Qw3d9c4AWOPcCKNDAQGT+nbTSFwvNXC9ofxR6k85+aLZ1vXu1QgQXdQBcDe91zci0b9/H04J+6oJCxaj1WH+skpU3FeXpnF2QPa91tOdKf+FIq8GXnBEBZa21rv6s48mBQw8hExfW9VObtHC0xtZXJW+9Ike9LH/24TrV/Loz+azG4wZ7ksLOLfk/5kGoQuZjaJ7j2d9/YJiK9SaAtEmmszSGAGz8syMEe7VwAzwppMQxCJyo x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 456e54c1-b89e-4196-95b4-08d524fe0a97 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199); SRVR:AM3PR08MB0104; x-ms-traffictypediagnostic: AM3PR08MB0104: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(250305191791016)(180628864354917)(22074186197030)(17755550239193); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(100000703101)(100105400095)(3231021)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM3PR08MB0104; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM3PR08MB0104; x-forefront-prvs: 048396AFA0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(199003)(189002)(24454002)(4326008)(6512007)(83716003)(25786009)(189998001)(50986999)(76176999)(114624004)(14454004)(6916009)(2950100002)(229853002)(82746002)(39060400002)(54356999)(6246003)(101416001)(2900100001)(53546010)(68736007)(105586002)(99286004)(6306002)(1411001)(106356001)(5250100002)(53936002)(7736002)(33656002)(305945005)(54906003)(3660700001)(15760500003)(2906002)(478600001)(86362001)(575784001)(36756003)(72206003)(6436002)(66066001)(316002)(81166006)(5660300001)(8936002)(81156014)(8676002)(102836003)(6116002)(3846002)(3280700002)(97736004)(6506006)(6486002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0104; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <94F8A8E64E0ACC448CE231539AA4D490@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 456e54c1-b89e-4196-95b4-08d524fe0a97 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2017 10:06:25.7824 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0104 X-IsSubscribed: yes > On 30 Oct 2017, at 12:00, Yao Qi wrote: > > Alan Hayward writes: > >> +/* The Aarch64 target descriptor. */ > > s/descriptor/description/ > >> +static const struct target_desc *aarch64_tdesc = NULL; >> + > > Remove "struct". > > Can you move aarch64_tdesc to aarch64_read_description? I think it > only needs to be visible inside that function. > >> /* The standard register names, and all the valid aliases for them. */ >> static const struct >> { >> @@ -2827,6 +2830,19 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch, >> return 1; >> } >> >> +/* Get the correct target description. */ >> + >> +const target_desc * >> +aarch64_read_description () > > Otherwise, the patch is good to me. > > -- > Yao (齐尧) Fixed as suggested above. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index e21ea55197fb2735762d540fba54de8c8b71bdf0..029e554306704c5a543b5c24b72908a95f4f85d3 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -779,6 +779,7 @@ ALL_64_TARGET_OBS = \ amd64-sol2-tdep.o \ amd64-tdep.o \ amd64-windows-tdep.o \ + arch/aarch64.o \ arch/aarch64-insn.o \ arch/amd64.o \ ia64-linux-tdep.o \ @@ -1514,6 +1515,7 @@ HFILES_NO_SRCDIR = \ xml-syscall.h \ xml-tdesc.h \ xtensa-tdep.h \ + arch/aarch64.h \ arch/aarch64-insn.h \ arch/arm.h \ arch/i386.h \ diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 4feaec39d910485d66cdb87a3615eee8a0c112e4..e571d926b462b7988f06bb65036a53b3ac68dd4f 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -501,7 +501,7 @@ aarch64_linux_read_description (struct target_ops *ops) if (ret == 0) return tdesc_arm_with_neon; else - return tdesc_aarch64; + return aarch64_read_description (); } /* Convert a native/host siginfo object, into/from the siginfo in the diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index b6052bafd6d47e594b1452b565371f9bc1d84200..c2c2c309338a2ec814b615ac6c728bab7d5a4736 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -244,7 +244,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, if (target_auxv_search (target, AT_HWCAP, &aarch64_hwcap) != 1) return NULL; - return tdesc_aarch64; + return aarch64_read_description (); } /* Implementation of `gdbarch_stap_is_single_operand', as defined in diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 2597443560f9caf9f7ce0d95cf3325a423b91e02..d9cbd353f3feaea12fb4a07cf4944f305326fc8f 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -75,7 +75,7 @@ struct gdbarch_tdep int (*aarch64_syscall_record) (struct regcache *regcache, unsigned long svc_number); }; -extern struct target_desc *tdesc_aarch64; +const target_desc *aarch64_read_description (); extern int aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr); diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index a40dc69b92dbacc06907c6a56f715d47632201a2..c91b3435c151019dfe4087e756bd6665e12cd8b1 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2827,6 +2827,20 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch, return 1; } +/* Get the correct target description. */ + +const target_desc * +aarch64_read_description () +{ + static target_desc *aarch64_tdesc = NULL; + target_desc **tdesc = &aarch64_tdesc; + + if (*tdesc == NULL) + *tdesc = aarch64_create_target_description (); + + return *tdesc; +} + /* Initialize the current architecture based on INFO. If possible, re-use an architecture from ARCHES, which is a list of architectures already created during this debugging session. @@ -2850,7 +2864,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Ensure we always have a target descriptor. */ if (!tdesc_has_registers (tdesc)) - tdesc = tdesc_aarch64; + tdesc = aarch64_read_description (); gdb_assert (tdesc); diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index b52740529b182bd63744022e552c3cdb3bc16759..ebb78c4fa80b4b659f85797dc0a0d84e83de4bba 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -20,6 +20,10 @@ #ifndef ARCH_AARCH64_H #define ARCH_AARCH64_H +#include "tdesc.h" + +target_desc *aarch64_create_target_description (); + /* Register numbers of various important registers. */ enum aarch64_regnum { diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c new file mode 100644 index 0000000000000000000000000000000000000000..95d9906f10e660fda99d73a0d2a9d184fd3a7b52 --- /dev/null +++ b/gdb/arch/aarch64.c @@ -0,0 +1,30 @@ +/* Copyright (C) 2017 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 "aarch64.h" + +extern struct target_desc *tdesc_aarch64; + +/* Create the aarch64 target description. */ + +target_desc * +aarch64_create_target_description () +{ + return tdesc_aarch64; +} + diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 1fce0798e24e162d7c456d7b881b298334ff0fbc..daec0a7bcd31944679b87fb4c3775dedc15dfd21 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -114,7 +114,7 @@ aarch64*-*-freebsd*) aarch64*-*-linux*) # Target: AArch64 linux - gdb_target_obs="aarch64-linux-tdep.o \ + gdb_target_obs="aarch64-linux-tdep.o arch/aarch64.o\ arch/arm.o arch/arm-linux.o arch/arm-get-next-pcs.o \ arm-tdep.o arm-linux-tdep.o \ glibc-tdep.o linux-tdep.o solib-svr4.o \