Module Name: src
Committed By: christos
Date: Mon May 21 02:10:47 UTC 2018
Modified Files:
src/external/gpl3/gdb/dist/bfd: config.bfd
src/external/gpl3/gdb/dist/gdb: Makefile.in configure.host
configure.tgt
Added Files:
src/external/gpl3/gdb/dist/gdb: aarch64-nbsd-nat.c aarch64-nbsd-tdep.c
aarch64-nbsd-tdep.h
src/external/gpl3/gdb/dist/gdb/config/aarch64: nbsd.mh
Log Message:
add minimal glue to make gdb compile on aarch-64; now configure in gdb/dist
and gmake creates a gdb binary.
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/external/gpl3/gdb/dist/bfd/config.bfd
cvs rdiff -u -r1.1.1.7 -r1.2 src/external/gpl3/gdb/dist/gdb/Makefile.in
cvs rdiff -u -r0 -r1.1 src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c \
src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c \
src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.h
cvs rdiff -u -r1.9 -r1.10 src/external/gpl3/gdb/dist/gdb/configure.host
cvs rdiff -u -r1.18 -r1.19 src/external/gpl3/gdb/dist/gdb/configure.tgt
cvs rdiff -u -r0 -r1.1 src/external/gpl3/gdb/dist/gdb/config/aarch64/nbsd.mh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/gpl3/gdb/dist/bfd/config.bfd
diff -u src/external/gpl3/gdb/dist/bfd/config.bfd:1.17 src/external/gpl3/gdb/dist/bfd/config.bfd:1.18
--- src/external/gpl3/gdb/dist/bfd/config.bfd:1.17 Tue Nov 28 17:04:52 2017
+++ src/external/gpl3/gdb/dist/bfd/config.bfd Sun May 20 22:10:46 2018
@@ -260,6 +260,11 @@ case "${targ}" in
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"
Index: src/external/gpl3/gdb/dist/gdb/Makefile.in
diff -u src/external/gpl3/gdb/dist/gdb/Makefile.in:1.1.1.7 src/external/gpl3/gdb/dist/gdb/Makefile.in:1.2
--- src/external/gpl3/gdb/dist/gdb/Makefile.in:1.1.1.7 Tue Nov 28 13:18:04 2017
+++ src/external/gpl3/gdb/dist/gdb/Makefile.in Sun May 20 22:10:47 2018
@@ -2460,6 +2460,8 @@ MAKEOVERRIDES =
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 \
Index: src/external/gpl3/gdb/dist/gdb/configure.host
diff -u src/external/gpl3/gdb/dist/gdb/configure.host:1.9 src/external/gpl3/gdb/dist/gdb/configure.host:1.10
--- src/external/gpl3/gdb/dist/gdb/configure.host:1.9 Tue Nov 28 17:04:52 2017
+++ src/external/gpl3/gdb/dist/gdb/configure.host Sun May 20 22:10:47 2018
@@ -84,6 +84,7 @@ case "${host}" in
*-*-darwin*) gdb_host=darwin ;;
aarch64*-*-linux*) gdb_host=linux ;;
+aarch64*-*-netbsd*) gdb_host=nbsd ;;
alpha*-*-linux*) gdb_host=alpha-linux ;;
alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
Index: src/external/gpl3/gdb/dist/gdb/configure.tgt
diff -u src/external/gpl3/gdb/dist/gdb/configure.tgt:1.18 src/external/gpl3/gdb/dist/gdb/configure.tgt:1.19
--- src/external/gpl3/gdb/dist/gdb/configure.tgt:1.18 Mon Jan 8 13:56:20 2018
+++ src/external/gpl3/gdb/dist/gdb/configure.tgt Sun May 20 22:10:47 2018
@@ -56,8 +56,8 @@ aarch64*-*-linux*)
aarch64*-*-netbsd*)
# Target: AArch64 NetBSD
- #gdb_target_obs="aarch64-tdep.o aarch64-netbsd-tdep.o"
- gdb_target_obs="aarch64-tdep.o aarch64-insn.o solib-svr4.o"
+ gdb_target_obs="aarch64-tdep.o aarch64-nbsd-tdep.o \
+ aarch64-insn.o solib-svr4.o"
;;
alpha*-*-osf*)
Added files:
Index: src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c
diff -u /dev/null src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c:1.1
--- /dev/null Sun May 20 22:10:47 2018
+++ src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c Sun May 20 22:10:47 2018
@@ -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);
+}
Index: src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c
diff -u /dev/null src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c:1.1
--- /dev/null Sun May 20 22:10:47 2018
+++ src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.c Sun May 20 22:10:47 2018
@@ -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
+};
+
+/* Register maps. */
+
+static const struct regcache_map_entry aarch64_nbsd_gregmap[] =
+ {
+ { 30, AARCH64_X0_REGNUM, 8 }, /* x0 ... x29 */
+ { 1, AARCH64_LR_REGNUM, 8 },
+ { 1, AARCH64_SP_REGNUM, 8 },
+ { 1, AARCH64_PC_REGNUM, 8 },
+ { 1, AARCH64_CPSR_REGNUM, 4 },
+ { 0 }
+ };
+
+static const struct regcache_map_entry aarch64_nbsd_fpregmap[] =
+ {
+ { 32, AARCH64_V0_REGNUM, 16 }, /* v0 ... v31 */
+ { 1, AARCH64_FPSR_REGNUM, 4 },
+ { 1, AARCH64_FPCR_REGNUM, 4 },
+ { 0 }
+ };
+
+/* Register set definitions. */
+
+const struct regset aarch64_nbsd_gregset =
+ {
+ aarch64_nbsd_gregmap,
+ regcache_supply_regset, regcache_collect_regset
+ };
+
+const struct regset aarch64_nbsd_fpregset =
+ {
+ aarch64_nbsd_fpregmap,
+ regcache_supply_regset, regcache_collect_regset
+ };
+
+/* Implement the "regset_from_core_section" gdbarch method. */
+
+static void
+aarch64_nbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
+ iterate_over_regset_sections_cb *cb,
+ void *cb_data,
+ const struct regcache *regcache)
+{
+ cb (".reg", AARCH64_NBSD_SIZEOF_GREGSET, &aarch64_nbsd_gregset,
+ NULL, cb_data);
+ cb (".reg2", AARCH64_NBSD_SIZEOF_FPREGSET, &aarch64_nbsd_fpregset,
+ NULL, cb_data);
+}
+
+/* Implement the 'init_osabi' method of struct gdb_osabi_handler. */
+
+static void
+aarch64_nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ set_solib_svr4_fetch_link_map_offsets (gdbarch,
+ svr4_lp64_fetch_link_map_offsets);
+
+ tramp_frame_prepend_unwinder (gdbarch, &aarch64_nbsd_sigframe);
+
+ /* Enable longjmp. */
+ tdep->jb_pc = 13;
+
+ set_gdbarch_iterate_over_regset_sections
+ (gdbarch, aarch64_nbsd_iterate_over_regset_sections);
+}
+
+void
+_initialize_aarch64_nbsd_tdep (void)
+{
+ gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_FREEBSD,
+ aarch64_nbsd_init_abi);
+}
Index: src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.h
diff -u /dev/null src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.h:1.1
--- /dev/null Sun May 20 22:10:47 2018
+++ src/external/gpl3/gdb/dist/gdb/aarch64-nbsd-tdep.h Sun May 20 22:10:47 2018
@@ -0,0 +1,33 @@
+/* FreeBSD/aarch64 target support, prototypes.
+
+ 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 "regset.h"
+
+/* The general-purpose regset consists of 30 X registers, plus LR, SP,
+ ELR, and SPSR registers. SPSR is 32 bits but the structure is
+ passed to 64 bit alignment. */
+#define AARCH64_NBSD_SIZEOF_GREGSET (34 * X_REGISTER_SIZE)
+
+/* The fp regset consists of 32 V registers, plus FPSR and FPCR which
+ are 4 bytes wide each, and the whole structure is padded to 128 bit
+ alignment. */
+#define AARCH64_NBSD_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE)
+
+extern const struct regset aarch64_nbsd_gregset;
+extern const struct regset aarch64_nbsd_fpregset;
Index: src/external/gpl3/gdb/dist/gdb/config/aarch64/nbsd.mh
diff -u /dev/null src/external/gpl3/gdb/dist/gdb/config/aarch64/nbsd.mh:1.1
--- /dev/null Sun May 20 22:10:47 2018
+++ src/external/gpl3/gdb/dist/gdb/config/aarch64/nbsd.mh Sun May 20 22:10:47 2018
@@ -0,0 +1,5 @@
+# Host: NetBSD/amd64
+NATDEPFILES= fork-child.o inf-ptrace.o nbsd-nat.o aarch64-nbsd-nat.o \
+ bsd-kvm.o
+
+LOADLIBES= -lkvm