From patchwork Wed Oct 25 08:28:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 23799 Received: (qmail 40499 invoked by alias); 25 Oct 2017 08:29:12 -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 40129 invoked by uid 89); 25 Oct 2017 08:28:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0053.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Oct 2017 08:28:51 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0103.eurprd08.prod.outlook.com (10.160.211.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.156.4; Wed, 25 Oct 2017 08:28:46 +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.0156.007; Wed, 25 Oct 2017 08:28:47 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH 1/4] Add aarch64_create_target_description Date: Wed, 25 Oct 2017 08:28:47 +0000 Message-ID: <04DE907F-329F-4AB5-9EB1-4F83E05C992E@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0103; 6:ynW+NqlidGgTqmUxRW21uAuN35PxXjouLkK399DsyBtsQb4nfs/kjLheGjWB2uSLApyIZUKa/iJoCj4at6sw00yj/HvFbgui0Jm1KLuO6llmkacAAJhsgzpnZYpEAvwBro0hr83el7DqpaL8djPeKijhO+dr6Fpn0Ct6EW0d37NaC/h9F645EO9ozULtfiJRM68+j0f6D4qWZ2HdG8zC6vGyV/JlUhW8Mp6gc9bBZKfdxuzq3NEdO4vLGWGidW7z+bLZHUV2Kk5bH37eZ4IvWTlLHcviXxeQC2ATXZqwJfB9tHhS2ZC1urPNVYMkZEnssu5L5awjP7MOyRfuVhYR7Q==; 5:EC/4kpR0g2GCpLWYfrfQH9Bkon5pxkosc38bHZnwFVc7hQ5+zW/4M3MCq0IIkGFhN/ZUhcd5y9X1pUNYVJsd8/6yL/jd0eHZO2fIK48Wrvg4FzcHnvoPeFa4RWSkx2yIc9amhkV4ognJjK3culuLHw==; 24:f8LxTJewLNJx0NN1Dd2rZYIk+zIVNESaR0kM8JLgqqHi6zdsSgRaJuLEi28krG6Eanh22upx1oblxWFuS1AmQ0pKls+vMfMDVbrWWzAE+pg=; 7:Cm16fxOAl5iOGRkDMqBANDdqIDVs+N2L44DVdhwwaYYMOf2Xr4aBzQ9C9QHmTmC88jfRlmJleZhgfmo3tzdu64Q0N5ZbTj0m1yIo2bx78WQFlfhU+tVYj+XGmFDs65GGa10E+2JxXwyfGh1cx2JnZuakFHIoM7kLmE/fkK912ATnAoZQWO+IAbMsTQNXCeuuFI3TD+xkuiYmHig0DJS/lsSpz7urODQlC9HXBCFqaVY= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: a6fbd3c2-bacc-44f7-c0ab-08d51b826987 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199); SRVR:AM3PR08MB0103; x-ms-traffictypediagnostic: AM3PR08MB0103: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(250305191791016)(180628864354917)(22074186197030); 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)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3231020)(3002001)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM3PR08MB0103; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM3PR08MB0103; x-forefront-prvs: 0471B73328 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(377424004)(199003)(189002)(305945005)(2900100001)(15760500003)(6306002)(99286003)(36756003)(6116002)(2906002)(54356999)(50986999)(6436002)(6486002)(3280700002)(2351001)(5250100002)(6916009)(106356001)(8936002)(8676002)(5640700003)(81166006)(105586002)(102836003)(6512007)(14454004)(53936002)(6506006)(66066001)(81156014)(2501003)(83716003)(4001150100001)(97736004)(33656002)(575784001)(4326008)(82746002)(3846002)(101416001)(72206003)(3660700001)(189998001)(68736007)(478600001)(25786009)(114624004)(7736002)(86362001)(5660300001)(316002)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0103; 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: <5F608E63478D9747B8CDCF9B61B1DB19@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6fbd3c2-bacc-44f7-c0ab-08d51b826987 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2017 08:28:47.1745 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0103 X-IsSubscribed: yes The first of a set of patches moving aarch64 over to use flexible target descriptors. For this patch, instead of accessing tdesc_aarch64 directly, obtain it from the function aarch64_read_description. For now, aarch64_create_target_description simply returns tdesc_aarch64. This will be changes in the final patch. This patch introduces no functionality changes. Tested on a --enable-targets=all build and aarch64 build with board files unix, native-gdbserver and unittest.exp. Alan. 2017-10-25 Alan Hayward * Makefile.in: Add new files. * aarch64-linux-nat.c (aarch64_linux_read_description): Call aarch64_read_description. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Call aarch64_read_description. * aarch64-tdep.c (aarch64_read_description): New function. (aarch64_gdbarch_init): Call aarch64_read_description. * aarch64-tdep.h (aarch64_read_description): New function. * arch/aarch64.c: New file. * configure.tgt: Add new files. 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..96d1391a193a43100e0fd4a262210ac7e90242dc 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -73,6 +73,9 @@ #define AARCH64_H0_REGNUM (AARCH64_S0_REGNUM + 32) #define AARCH64_B0_REGNUM (AARCH64_H0_REGNUM + 32) +/* The Aarch64 target descriptor. */ +static const struct target_desc *aarch64_tdesc = NULL; + /* 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 () +{ + struct target_desc **tdesc = (struct target_desc **) &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 +2866,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 \