From d6d7ce56231ca8c233e64b2ebcb910fe334d6ff8 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Fri, 24 Nov 2017 10:04:53 +0000 Subject: [PATCH] gdbserver: add aarch64_create_target_description gdbserver/ * configure.srv: Add new files. * linux-aarch64-ipa.c (get_ipa_tdesc): Call aarch64_linux_read_description. * linux-aarch64-low.c (aarch64_linux_read_description): Merge with aarch64_arch_setup. (aarch64_arch_setup): Call aarch64_linux_read_description. * linux-aarch64-tdesc.c: New file. * linux-aarch64-tdesc.h: New file. --- gdb/gdbserver/ChangeLog | 11 +++++++++ gdb/gdbserver/configure.srv | 12 +++++++--- gdb/gdbserver/linux-aarch64-ipa.c | 4 ++-- gdb/gdbserver/linux-aarch64-low.c | 21 +++++----------- gdb/gdbserver/linux-aarch64-tdesc.c | 37 +++++++++++++++++++++++++++++ gdb/gdbserver/linux-aarch64-tdesc.h | 20 ++++++++++++++++ 6 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 gdb/gdbserver/linux-aarch64-tdesc.c create mode 100644 gdb/gdbserver/linux-aarch64-tdesc.h diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 03d4ad7628f..90680555fdd 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2017-11-24 Alan Hayward + + * configure.srv: Add new files. + * linux-aarch64-ipa.c (get_ipa_tdesc): Call + aarch64_linux_read_description. + * linux-aarch64-low.c (aarch64_linux_read_description): + Merge with aarch64_arch_setup. + (aarch64_arch_setup): Call aarch64_linux_read_description. + * linux-aarch64-tdesc.c: New file. + * linux-aarch64-tdesc.h: New file. + 2017-11-24 Yao Qi * configure.srv: Set $srv_regobj for tic6x-linux. diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index f5fa5e6a461..14967ff5249 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -50,13 +50,17 @@ srv_linux_obj="linux-low.o linux-osdata.o linux-procfs.o linux-ptrace.o linux-wa case "${target}" in aarch64*-*-linux*) - srv_regobj="aarch64.o" - srv_regobj="${srv_regobj} arm-with-neon.o" + srv_regobj="arm-with-neon.o" + if $development; then + srv_regobj="${srv_regobj} aarch64.o" + fi srv_tgtobj="linux-aarch64-low.o aarch64-linux-hw-point.o" srv_tgtobj="$srv_tgtobj linux-aarch32-low.o" srv_tgtobj="${srv_tgtobj} arch/arm.o" srv_tgtobj="$srv_tgtobj aarch64-linux.o" srv_tgtobj="$srv_tgtobj arch/aarch64-insn.o" + srv_tgtobj="$srv_tgtobj arch/aarch64.o" + srv_tgtobj="$srv_tgtobj linux-aarch64-tdesc.o" srv_tgtobj="${srv_tgtobj} $srv_linux_obj" srv_xmlfiles="aarch64.xml" srv_xmlfiles="${srv_xmlfiles} aarch64-core.xml" @@ -65,7 +69,9 @@ case "${target}" in srv_xmlfiles="${srv_xmlfiles} arm/arm-with-neon.xml" srv_linux_regsets=yes srv_linux_thread_db=yes - ipa_obj="linux-aarch64-ipa.o aarch64-ipa.o" + ipa_obj="linux-aarch64-ipa.o" + 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" diff --git a/gdb/gdbserver/linux-aarch64-ipa.c b/gdb/gdbserver/linux-aarch64-ipa.c index ad1059029bb..28dc9776a1c 100644 --- a/gdb/gdbserver/linux-aarch64-ipa.c +++ b/gdb/gdbserver/linux-aarch64-ipa.c @@ -25,10 +25,10 @@ #ifdef HAVE_GETAUXVAL #include #endif +#include "linux-aarch64-tdesc.h" /* Defined in auto-generated file aarch64.c. */ void init_registers_aarch64 (void); -extern const struct target_desc *tdesc_aarch64; /* Each register saved by the jump pad is in a 16 byte cell. */ #define FT_CR_SIZE 16 @@ -155,7 +155,7 @@ get_raw_reg (const unsigned char *raw_regs, int regnum) const struct target_desc * get_ipa_tdesc (int idx) { - return tdesc_aarch64; + return aarch64_linux_read_description (); } /* Allocate buffer for the jump pads. The branch instruction has a reach diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index b00d5c502d2..dcce287974c 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -39,10 +39,10 @@ #include "gdb_proc_service.h" #include "arch/aarch64.h" +#include "linux-aarch64-tdesc.h" /* Defined in auto-generated files. */ void init_registers_aarch64 (void); -extern const struct target_desc *tdesc_aarch64; #ifdef HAVE_SYS_REG_H #include @@ -467,11 +467,10 @@ aarch64_linux_new_fork (struct process_info *parent, *child->priv->arch_private = *parent->priv->arch_private; } -/* Return the right target description according to the ELF file of - current thread. */ +/* Implementation of linux_target_ops method "arch_setup". */ -static const struct target_desc * -aarch64_linux_read_description (void) +static void +aarch64_arch_setup (void) { unsigned int machine; int is_elf64; @@ -482,17 +481,9 @@ aarch64_linux_read_description (void) is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine); if (is_elf64) - return tdesc_aarch64; + current_process ()->tdesc = aarch64_linux_read_description (); else - return tdesc_arm_with_neon; -} - -/* Implementation of linux_target_ops method "arch_setup". */ - -static void -aarch64_arch_setup (void) -{ - current_process ()->tdesc = aarch64_linux_read_description (); + current_process ()->tdesc = tdesc_arm_with_neon; aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread)); } diff --git a/gdb/gdbserver/linux-aarch64-tdesc.c b/gdb/gdbserver/linux-aarch64-tdesc.c new file mode 100644 index 00000000000..8518ef73389 --- /dev/null +++ b/gdb/gdbserver/linux-aarch64-tdesc.c @@ -0,0 +1,37 @@ +/* GNU/Linux/aarch64 specific target description, for the remote server + for GDB. + 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 "server.h" +#include "tdesc.h" +#include "arch/aarch64.h" +#include "linux-aarch32-low.h" + +/* Create the aarch64 target description. */ + +const target_desc * +aarch64_linux_read_description () +{ + static target_desc *aarch64_tdesc = NULL; + target_desc **tdesc = &aarch64_tdesc; + + if (*tdesc == NULL) + *tdesc = aarch64_create_target_description (); + + return *tdesc; +} diff --git a/gdb/gdbserver/linux-aarch64-tdesc.h b/gdb/gdbserver/linux-aarch64-tdesc.h new file mode 100644 index 00000000000..6d6731720c3 --- /dev/null +++ b/gdb/gdbserver/linux-aarch64-tdesc.h @@ -0,0 +1,20 @@ +/* Low level support for aarch64, shared between gdbserver and IPA. + + Copyright (C) 2016-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 . */ + +const target_desc * aarch64_linux_read_description (); -- 2.30.2