Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3/gdb/dist add minimal glue to make...
details: https://anonhg.NetBSD.org/src/rev/43d85a62d110
branches: trunk
changeset: 319206:43d85a62d110
user: christos <christos%NetBSD.org@localhost>
date: Mon May 21 02:10:46 2018 +0000
description:
add minimal glue to make gdb compile on aarch-64; now configure in gdb/dist
and gmake creates a gdb binary.
diffstat:
external/gpl3/gdb/dist/bfd/config.bfd | 5 +
external/gpl3/gdb/dist/gdb/Makefile.in | 2 +
external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c | 136 ++++++++++++++
external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c | 202 ++++++++++++++++++++++
external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.h | 33 +++
external/gpl3/gdb/dist/gdb/config/aarch64/nbsd.mh | 5 +
external/gpl3/gdb/dist/gdb/configure.host | 1 +
external/gpl3/gdb/dist/gdb/configure.tgt | 4 +-
8 files changed, 386 insertions(+), 2 deletions(-)
diffs (truncated from 444 to 300 lines):
diff -r db066ef6e026 -r 43d85a62d110 external/gpl3/gdb/dist/bfd/config.bfd
--- a/external/gpl3/gdb/dist/bfd/config.bfd Sun May 20 23:47:16 2018 +0000
+++ b/external/gpl3/gdb/dist/bfd/config.bfd Mon May 21 02:10:46 2018 +0000
@@ -260,6 +260,11 @@
targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
want64=true
;;
+ aarch64-*-netbsd*)
+ targ_defvec=aarch64_elf64_le_vec
+ targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
+ want64=true
+ ;;
aarch64-*-fuchsia*)
targ_defvec=aarch64_elf64_le_vec
targ_selvecs="aarch64_elf64_be_vec arm_elf32_le_vec arm_elf32_be_vec"
diff -r db066ef6e026 -r 43d85a62d110 external/gpl3/gdb/dist/gdb/Makefile.in
--- a/external/gpl3/gdb/dist/gdb/Makefile.in Sun May 20 23:47:16 2018 +0000
+++ b/external/gpl3/gdb/dist/gdb/Makefile.in Mon May 21 02:10:46 2018 +0000
@@ -2460,6 +2460,8 @@
ALLDEPFILES = \
aarch64-linux-nat.c \
aarch64-linux-tdep.c \
+ aarch64-nbsd-nat.c \
+ aarch64-nbsd-tdep.c \
aarch64-newlib-tdep.c \
aarch64-tdep.c \
aix-thread.c \
diff -r db066ef6e026 -r 43d85a62d110 external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c Mon May 21 02:10:46 2018 +0000
@@ -0,0 +1,136 @@
+/* Native-dependent code for NetBSD/aarch64.
+
+ Copyright (C) 2017-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 "defs.h"
+#include "target.h"
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <machine/reg.h>
+
+#include "nbsd-nat.h"
+#include "aarch64-tdep.h"
+#include "aarch64-nbsd-tdep.h"
+#include "regcache.h"
+#include "gdbcore.h"
+#include "bsd-kvm.h"
+#include "inf-ptrace.h"
+
+/* Determine if PT_GETREGS fetches REGNUM. */
+
+static bool
+getregs_supplies (struct gdbarch *gdbarch, int regnum)
+{
+ return (regnum >= AARCH64_X0_REGNUM && regnum <= AARCH64_CPSR_REGNUM);
+}
+
+/* Determine if PT_GETFPREGS fetches REGNUM. */
+
+static bool
+getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
+{
+ return (regnum >= AARCH64_V0_REGNUM && regnum <= AARCH64_FPCR_REGNUM);
+}
+
+/* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
+ for all registers. */
+
+static void
+aarch64_nbsd_fetch_inferior_registers (struct target_ops *ops,
+ struct regcache *regcache, int regnum)
+{
+ ptid_t ptid = regcache_get_ptid (regcache);
+ pid_t pid = ptid_get_pid (ptid);
+ int tid = ptid_get_lwp (ptid);
+
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
+ {
+ struct reg regs;
+
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, tid) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ regcache_supply_regset (&aarch64_nbsd_gregset, regcache, regnum, ®s,
+ sizeof (regs));
+ }
+
+ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
+ {
+ struct fpreg fpregs;
+
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, tid) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ regcache_supply_regset (&aarch64_nbsd_fpregset, regcache, regnum, &fpregs,
+ sizeof (fpregs));
+ }
+}
+
+/* Store register REGNUM back into the inferior. If REGNUM is -1, do
+ this for all registers. */
+
+static void
+aarch64_nbsd_store_inferior_registers (struct target_ops *ops,
+ struct regcache *regcache, int regnum)
+{
+ ptid_t ptid = regcache_get_ptid (regcache);
+ pid_t pid = ptid_get_pid (ptid);
+ int tid = ptid_get_lwp (ptid);
+
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ if (regnum == -1 || getregs_supplies (gdbarch, regnum))
+ {
+ struct reg regs;
+
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, tid) == -1)
+ perror_with_name (_("Couldn't get registers"));
+
+ regcache_collect_regset (&aarch64_nbsd_gregset, regcache,regnum, ®s,
+ sizeof (regs));
+
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, tid) == -1)
+ perror_with_name (_("Couldn't write registers"));
+ }
+
+ if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
+ {
+ struct fpreg fpregs;
+
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, tid) == -1)
+ perror_with_name (_("Couldn't get floating point status"));
+
+ regcache_collect_regset (&aarch64_nbsd_fpregset, regcache,regnum, &fpregs,
+ sizeof (fpregs));
+
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, tid) == -1)
+ perror_with_name (_("Couldn't write floating point status"));
+ }
+}
+
+void
+_initialize_aarch64_nbsd_nat (void)
+{
+ struct target_ops *t;
+
+ t = inf_ptrace_target ();
+ t->to_fetch_registers = aarch64_nbsd_fetch_inferior_registers;
+ t->to_store_registers = aarch64_nbsd_store_inferior_registers;
+ nbsd_nat_add_target (t);
+}
diff -r db066ef6e026 -r 43d85a62d110 external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c Mon May 21 02:10:46 2018 +0000
@@ -0,0 +1,202 @@
+/* Target-dependent code for FreeBSD/aarch64.
+
+ Copyright (C) 2017-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 "defs.h"
+
+#include "gdbarch.h"
+#include "nbsd-tdep.h"
+#include "aarch64-tdep.h"
+#include "aarch64-nbsd-tdep.h"
+#include "osabi.h"
+#include "solib-svr4.h"
+#include "target.h"
+#include "tramp-frame.h"
+#include "trad-frame.h"
+
+/* In a signal frame, sp points to a 'struct sigframe' which is
+ defined as:
+
+ struct sigframe {
+ siginfo_t sf_si;
+ ucontext_t sf_uc;
+ };
+
+ ucontext_t is defined as:
+
+ struct __ucontext {
+ sigset_t uc_sigmask;
+ mcontext_t uc_mcontext;
+ ...
+ };
+
+ The mcontext_t contains the general purpose register set followed
+ by the floating point register set. The floating point register
+ set is only valid if the _MC_FP_VALID flag is set in mc_flags. */
+
+#define AARCH64_MCONTEXT_REG_SIZE 8
+#define AARCH64_MCONTEXT_FPREG_SIZE 16
+#define AARCH64_SIGFRAME_UCONTEXT_OFFSET 80
+#define AARCH64_UCONTEXT_MCONTEXT_OFFSET 16
+#define AARCH64_MCONTEXT_FPREGS_OFFSET 272
+#define AARCH64_MCONTEXT_FLAGS_OFFSET 800
+#define AARCH64_MCONTEXT_FLAG_FP_VALID 0x1
+
+/* Implement the "init" method of struct tramp_frame. */
+
+static void
+aarch64_nbsd_sigframe_init (const struct tramp_frame *self,
+ struct frame_info *this_frame,
+ struct trad_frame_cache *this_cache,
+ CORE_ADDR func)
+{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM);
+ CORE_ADDR mcontext_addr =
+ sp
+ + AARCH64_SIGFRAME_UCONTEXT_OFFSET
+ + AARCH64_UCONTEXT_MCONTEXT_OFFSET;
+ gdb_byte buf[4];
+ int i;
+
+ for (i = 0; i < 30; i++)
+ {
+ trad_frame_set_reg_addr (this_cache,
+ AARCH64_X0_REGNUM + i,
+ mcontext_addr + i * AARCH64_MCONTEXT_REG_SIZE);
+ }
+ trad_frame_set_reg_addr (this_cache, AARCH64_LR_REGNUM,
+ mcontext_addr + 30 * AARCH64_MCONTEXT_REG_SIZE);
+ trad_frame_set_reg_addr (this_cache, AARCH64_SP_REGNUM,
+ mcontext_addr + 31 * AARCH64_MCONTEXT_REG_SIZE);
+ trad_frame_set_reg_addr (this_cache, AARCH64_PC_REGNUM,
+ mcontext_addr + 32 * AARCH64_MCONTEXT_REG_SIZE);
+ trad_frame_set_reg_addr (this_cache, AARCH64_CPSR_REGNUM,
+ mcontext_addr + 33 * AARCH64_MCONTEXT_REG_SIZE);
+
+ if (target_read_memory (mcontext_addr + AARCH64_MCONTEXT_FLAGS_OFFSET, buf,
+ 4) == 0
+ && (extract_unsigned_integer (buf, 4, byte_order)
+ & AARCH64_MCONTEXT_FLAG_FP_VALID))
+ {
+ for (i = 0; i < 32; i++)
+ {
+ trad_frame_set_reg_addr (this_cache, AARCH64_V0_REGNUM + i,
+ mcontext_addr
+ + AARCH64_MCONTEXT_FPREGS_OFFSET
+ + i * AARCH64_MCONTEXT_FPREG_SIZE);
+ }
+ trad_frame_set_reg_addr (this_cache, AARCH64_FPSR_REGNUM,
+ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET
+ + 32 * AARCH64_MCONTEXT_FPREG_SIZE);
+ trad_frame_set_reg_addr (this_cache, AARCH64_FPCR_REGNUM,
+ mcontext_addr + AARCH64_MCONTEXT_FPREGS_OFFSET
+ + 32 * AARCH64_MCONTEXT_FPREG_SIZE + 4);
+ }
+
+ trad_frame_set_id (this_cache, frame_id_build (sp, func));
+}
+
+static const struct tramp_frame aarch64_nbsd_sigframe =
+{
+ SIGTRAMP_FRAME,
+ 4,
+ {
+ {0x910003e0, -1}, /* mov x0, sp */
+ {0x91014000, -1}, /* add x0, x0, #SF_UC */
+ {0xd2803428, -1}, /* mov x8, #SYS_sigreturn */
+ {0xd4000001, -1}, /* svc 0x0 */
+ {TRAMP_SENTINEL_INSN, -1}
+ },
+ aarch64_nbsd_sigframe_init
+};
+
Home |
Main Index |
Thread Index |
Old Index