From d105cce5dd8d6a5218b044fc161ce89c6b245432 Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Fri, 19 Jul 2019 14:59:10 +0100 Subject: Arm: Add read_description read funcs and use in GDB 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. gdb/ChangeLog: * Makefile.in: Add new files. * aarch32-tdep.c: New file. * aarch32-tdep.h: New file. * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Call aarch32_read_description. * arch/aarch32.c: New file. * arch/aarch32.h: New file. * arch/arm.c (arm_create_target_description) (arm_create_mprofile_target_description): New function. * arch/arm.h (arm_fp_type, arm_m_profile_type): New enum. (arm_create_target_description) (arm_create_mprofile_target_description): New declaration. * arm-fbsd-tdep.c (arm_fbsd_read_description_auxv): Call read_description functions. * arm-linux-nat.c (arm_linux_nat_target::read_description): Likewise. * arm-linux-tdep.c (arm_linux_core_read_description): Likewise. * arm-tdep.c (tdesc_arm_list): New variable. (arm_register_g_packet_guesses): Call create description functions. (arm_read_description) (arm_read_mprofile_description): New function. * arm-tdep.h (arm_read_description) (arm_read_mprofile_description): Add declaration. * configure.tgt: Add new files. --- gdb/arch/aarch32.c | 29 ++++++++++++++++++++++++++ gdb/arch/aarch32.h | 27 ++++++++++++++++++++++++ gdb/arch/arm.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/arch/arm.h | 27 ++++++++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 gdb/arch/aarch32.c create mode 100644 gdb/arch/aarch32.h (limited to 'gdb/arch') diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c new file mode 100644 index 0000000..14d6987 --- /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 0000000..d2c0047 --- /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 860ce02..7a0f36e 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 dfbbd56..58511c7 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 */ -- cgit v1.1