diff options
author | Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> | 2018-05-22 11:09:05 -0300 |
---|---|---|
committer | Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com> | 2018-05-22 11:52:02 -0300 |
commit | bd64614eb737096f40b976fb505ddd42e7f1614c (patch) | |
tree | 51519baf597d6e6ac48c1f519f4e7a10e7f557dc /gdb/arch | |
parent | 241db429d5735ae8875e38991c82204b310c2ff5 (diff) | |
download | gdb-bd64614eb737096f40b976fb505ddd42e7f1614c.zip gdb-bd64614eb737096f40b976fb505ddd42e7f1614c.tar.gz gdb-bd64614eb737096f40b976fb505ddd42e7f1614c.tar.bz2 |
[PowerPC] Consolidate linux target description selection
Share target description declarations and selection among ppc linux
native targets, core files, gdbserver and IPA.
To avoid complicated define guards, gdbserver and IPA now have
declarations for all descriptions, including 64-bit generated
descriptions when compiled in 32-bit mode. These have always been
linked into the gdbserver and IPA binaries. Because they might be
uninitialized, the selection function checks that the selected
description is initialized.
gdb/ChangeLog:
2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
* arch/ppc-linux-common.c: New file.
* arch/ppc-linux-common.h: New file.
* arch/ppc-linux-tdesc.h: New file.
* configure.tgt (powerpc*-*-linux*): Add arch/ppc-linux-common.o.
* Makefile.in (ALL_TARGET_OBS): Add arch/ppc-linux-common.o.
(HFILES_NO_SRCDIR): Add arch/ppc-linux-common.h and
arch/ppc-linux-tdesc.h.
* ppc-linux-nat.c: Include arch/ppc-linux-common.h and
arch/ppc-linux-tdesc.h.
(ppc_linux_nat_target::read_description): Remove target
description matching code. Fill a ppc_linux_features struct and
call ppc_linux_match_description with it. Move comment about ISA
2.05 to ppc-linux-common.c.
* ppc-linux-tdep.c: Include arch/ppc-linux-common.h and
arch/ppc-linux-tdesc.h.
(ppc_linux_core_read_description): Remove target description
matching code. Fill a ppc_linux_features struct and call
ppc_linux_match_description with it.
* ppc-linux-tdep.h (tdesc_powerpc_32l, tdesc_powerpc_64l)
(tdesc_powerpc_altivec32l, tdesc_powerpc_altivec64l)
(tdesc_powerpc_cell32l, tdesc_powerpc_cell64l)
(tdesc_powerpc_vsx32l, tdesc_powerpc_vsx64l)
(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_64l)
(tdesc_powerpc_isa205_altivec32l, tdesc_powerpc_isa205_altivec64l)
(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_isa205_vsx64l)
(tdesc_powerpc_e500l): Remove.
gdb/gdbserver/ChangeLog:
2018-05-22 Pedro Franco de Carvalho <pedromfc@linux.vnet.ibm.com>
* configure.srv (srv_tgtobj): Add arch/ppc-linux-common.o.
* Makefile.in (SFILES): Add arch/ppc-linux-common.c.
* linux-ppc-tdesc.h: Rename to linux-ppc-tdesc-init.h.
* linux-ppc-tdesc-init.h (tdesc_powerpc_32l, tdesc_powerpc_64l)
(tdesc_powerpc_altivec32l, tdesc_powerpc_altivec64l)
(tdesc_powerpc_cell32l, tdesc_powerpc_cell64l)
(tdesc_powerpc_vsx32l, tdesc_powerpc_vsx64l)
(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_64l)
(tdesc_powerpc_isa205_altivec32l, tdesc_powerpc_isa205_altivec64l)
(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_isa205_vsx64l)
(tdesc_powerpc_e500l): Remove.
* linux-ppc-ipa.c: Include arch/ppc-linux-tdesc.h and
linux-ppc-tdesc-init.h. Don't include linux-ppc-tdesc.h.
* linux-ppc-low.c: Include arch/ppc-linux-common.h,
arch/ppc-linux-tdesc.h, and linux-ppc-tdesc-init.h. Don't include
linux-ppc-tdesc.h.
(ppc_arch_setup): Remove target description matching code. Fill a
ppc_linux_features struct and call ppc_linux_match_description
with it.
Diffstat (limited to 'gdb/arch')
-rw-r--r-- | gdb/arch/ppc-linux-common.c | 85 | ||||
-rw-r--r-- | gdb/arch/ppc-linux-common.h | 51 | ||||
-rw-r--r-- | gdb/arch/ppc-linux-tdesc.h | 42 |
3 files changed, 178 insertions, 0 deletions
diff --git a/gdb/arch/ppc-linux-common.c b/gdb/arch/ppc-linux-common.c new file mode 100644 index 0000000..87ccc42 --- /dev/null +++ b/gdb/arch/ppc-linux-common.c @@ -0,0 +1,85 @@ +/* Common target dependent code for GNU/Linux on PPC systems. + + Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. */ + +#include "common-defs.h" +#include "arch/ppc-linux-common.h" +#include "arch/ppc-linux-tdesc.h" + +/* Decimal Floating Point bit in AT_HWCAP. + + This file can be used by a host with another architecture, e.g. + when debugging core files, which might not provide this constant. */ + +#ifndef PPC_FEATURE_HAS_DFP +#define PPC_FEATURE_HAS_DFP 0x00000400 +#endif + +bool +ppc_linux_has_isa205 (unsigned long hwcap) +{ + /* Power ISA 2.05 (implemented by Power 6 and newer processors) + increases the FPSCR from 32 bits to 64 bits. Even though Power 7 + supports this ISA version, it doesn't have PPC_FEATURE_ARCH_2_05 + set, only PPC_FEATURE_ARCH_2_06. Since for now the only bits + used in the higher half of the register are for Decimal Floating + Point, we check if that feature is available to decide the size + of the FPSCR. */ + return ((hwcap & PPC_FEATURE_HAS_DFP) != 0); +} + +const struct target_desc * +ppc_linux_match_description (struct ppc_linux_features features) +{ + struct target_desc *tdesc = NULL; + + if (features.wordsize == 8) + { + if (features.cell) + tdesc = tdesc_powerpc_cell64l; + else if (features.vsx) + tdesc = features.isa205 + ? tdesc_powerpc_isa205_vsx64l : tdesc_powerpc_vsx64l; + else if (features.altivec) + tdesc = features.isa205 + ? tdesc_powerpc_isa205_altivec64l : tdesc_powerpc_altivec64l; + else + tdesc = features.isa205? + tdesc_powerpc_isa205_64l : tdesc_powerpc_64l; + } + else + { + gdb_assert (features.wordsize == 4); + + if (features.cell) + tdesc = tdesc_powerpc_cell32l; + else if (features.vsx) + tdesc = features.isa205 + ? tdesc_powerpc_isa205_vsx32l : tdesc_powerpc_vsx32l; + else if (features.altivec) + tdesc = features.isa205 + ? tdesc_powerpc_isa205_altivec32l : tdesc_powerpc_altivec32l; + else + tdesc = features.isa205 + ? tdesc_powerpc_isa205_32l : tdesc_powerpc_32l; + } + + gdb_assert (tdesc != NULL); + + return tdesc; +} diff --git a/gdb/arch/ppc-linux-common.h b/gdb/arch/ppc-linux-common.h new file mode 100644 index 0000000..b82adc4 --- /dev/null +++ b/gdb/arch/ppc-linux-common.h @@ -0,0 +1,51 @@ +/* Common target dependent code for GNU/Linux on PPC systems. + + Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. */ + +#ifndef ARCH_PPC_LINUX_COMMON_H +#define ARCH_PPC_LINUX_COMMON_H + +struct target_desc; + +/* Check if the hwcap auxv entry indicates that isa205 is supported. */ +bool ppc_linux_has_isa205 (unsigned long hwcap); + +/* Features used to determine the target description. */ +struct ppc_linux_features +{ + unsigned int wordsize; + bool altivec; + bool vsx; + bool isa205; + bool cell; +}; + +/* Base value for ppc_linux_features variables. */ +const struct ppc_linux_features ppc_linux_no_features = { + 0, + false, + false, + false, + false, +}; + +/* Return a target description that matches FEATURES. */ +const struct target_desc * ppc_linux_match_description +(struct ppc_linux_features features); + +#endif /* ARCH_PPC_LINUX_COMMON_H */ diff --git a/gdb/arch/ppc-linux-tdesc.h b/gdb/arch/ppc-linux-tdesc.h new file mode 100644 index 0000000..594c7c7 --- /dev/null +++ b/gdb/arch/ppc-linux-tdesc.h @@ -0,0 +1,42 @@ +/* Target description declarations shared between gdb, gdbserver and IPA. + + Copyright (C) 2018 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 <http://www.gnu.org/licenses/>. */ + +#ifndef ARCH_PPC_LINUX_TDESC_H +#define ARCH_PPC_LINUX_TDESC_H + +struct target_desc; + +extern struct target_desc *tdesc_powerpc_32l; +extern struct target_desc *tdesc_powerpc_altivec32l; +extern struct target_desc *tdesc_powerpc_cell32l; +extern struct target_desc *tdesc_powerpc_vsx32l; +extern struct target_desc *tdesc_powerpc_isa205_32l; +extern struct target_desc *tdesc_powerpc_isa205_altivec32l; +extern struct target_desc *tdesc_powerpc_isa205_vsx32l; +extern struct target_desc *tdesc_powerpc_e500l; + +extern struct target_desc *tdesc_powerpc_64l; +extern struct target_desc *tdesc_powerpc_altivec64l; +extern struct target_desc *tdesc_powerpc_cell64l; +extern struct target_desc *tdesc_powerpc_vsx64l; +extern struct target_desc *tdesc_powerpc_isa205_64l; +extern struct target_desc *tdesc_powerpc_isa205_altivec64l; +extern struct target_desc *tdesc_powerpc_isa205_vsx64l; + +#endif /* ARCH_PPC_LINUX_TDESC_H */ |