public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types.
  2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
  2017-09-22 22:58 ` [PATCH v2 3/4] Add FreeBSD/arm architecture John Baldwin
@ 2017-09-22 22:58 ` John Baldwin
  2017-09-22 22:58 ` [PATCH v2 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: John Baldwin @ 2017-09-22 22:58 UTC (permalink / raw)
  To: gdb-patches, binutils

FreeBSD recently added two additional ELF auxiliary vectors.  FreeBSD's
AT_HWCAP uses a different number compared to AT_HWCAP on Linux as the
numerical value was already in use for a different vector on FreeBSD.

include/ChangeLog:

	* elf/common.h (AT_FREEBSD_EHDRFLAGS, AT_FREEBSD_HWCAP): Define.

gdb/ChangeLog:

	* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and
	AT_HWCAP.
---
 gdb/ChangeLog        | 5 +++++
 gdb/fbsd-tdep.c      | 2 ++
 include/ChangeLog    | 4 ++++
 include/elf/common.h | 2 ++
 4 files changed, 13 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index aa50dc9f5b..7788bfc1a9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-22  John Baldwin  <jhb@FreeBSD.org>
+
+	* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and
+	AT_HWCAP.
+
 2017-09-22  Tom Tromey  <tom@tromey.com>
 
 	* utils.c (class scoped_input_handler) <m_quit_handler>: Change
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 1908269632..85dad6be90 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -392,6 +392,8 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
       TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC);
       TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX);
       TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX);
+      TAG (EHDRFLAGS, _("ELF header e_flags"), AUXV_FORMAT_HEX);
+      TAG (HWCAP, _("Machine-dependent CPU capability hints"), AUXV_FORMAT_HEX);
     default:
       default_print_auxv_entry (gdbarch, file, type, val);
       return;
diff --git a/include/ChangeLog b/include/ChangeLog
index 0ece8de3f7..a563f3eb67 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2017-09-22  John Baldwin  <jhb@FreeBSD.org>
+
+	* elf/common.h (AT_FREEBSD_EHDRFLAGS, AT_FREEBSD_HWCAP): Define.
+
 2017-09-22  Alexandre Oliva <aoliva@redhat.com>
 
 	* dwarf2.def (DW_AT_GNU_locviews): New.
diff --git a/include/elf/common.h b/include/elf/common.h
index d08731cca1..f89ab32889 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -1144,6 +1144,8 @@
 #define AT_FREEBSD_PAGESIZESLEN 21      /* Number of pagesizes. */
 #define AT_FREEBSD_TIMEKEEP     22      /* Pointer to timehands. */
 #define AT_FREEBSD_STACKPROT    23      /* Initial stack protection. */
+#define AT_FREEBSD_EHDRFLAGS    24      /* e_flags field from ELF header. */
+#define AT_FREEBSD_HWCAP        25      /* CPU feature flags. */
 
 #define AT_SUN_UID      2000    /* Effective user ID.  */
 #define AT_SUN_RUID     2001    /* Real user ID.  */
-- 
2.13.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD.
  2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
  2017-09-22 22:58 ` [PATCH v2 3/4] Add FreeBSD/arm architecture John Baldwin
  2017-09-22 22:58 ` [PATCH v2 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
@ 2017-09-22 22:58 ` John Baldwin
  2017-09-22 23:07 ` [PATCH v2 4/4] Add native target for FreeBSD/arm John Baldwin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: John Baldwin @ 2017-09-22 22:58 UTC (permalink / raw)
  To: gdb-patches, binutils

bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_VFP.
---
 bfd/ChangeLog | 4 ++++
 bfd/elf.c     | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9b4cb08d14..3436fe7304 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2017-09-22  John Baldwin  <jhb@FreeBSD.org>
+
+	* elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_VFP.
+
 2017-09-22  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR binutils/22170
diff --git a/bfd/elf.c b/bfd/elf.c
index 9b61f06a84..a5f8dd4c2d 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10011,6 +10011,9 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
       return elfcore_make_note_pseudosection (abfd, ".note.freebsdcore.lwpinfo",
 					      note);
 
+    case NT_ARM_VFP:
+      return elfcore_grok_arm_vfp (abfd, note);
+
     default:
       return TRUE;
     }
-- 
2.13.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB
@ 2017-09-22 22:58 John Baldwin
  2017-09-22 22:58 ` [PATCH v2 3/4] Add FreeBSD/arm architecture John Baldwin
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: John Baldwin @ 2017-09-22 22:58 UTC (permalink / raw)
  To: gdb-patches, binutils

This series adds initial support for FreeBSD/arm to GDB.  It does not
include support for hardware watchpoints or breakpoints.

Relative to V1, patch 3 contains some additional changes to account
for HWCAP_* renumbering in FreeBSD to align with Linux as well as
handling HWCAP_NEON.

John Baldwin (4):
  Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector
    types.
  Handle the NT_ARM_VFP core dump note on FreeBSD.
  Add FreeBSD/arm architecture.
  Add native target for FreeBSD/arm.

 bfd/ChangeLog        |   4 +
 bfd/elf.c            |   3 +
 gdb/ChangeLog        |  22 +++++
 gdb/Makefile.in      |   3 +
 gdb/NEWS             |   2 +
 gdb/arm-fbsd-nat.c   | 151 ++++++++++++++++++++++++++++++
 gdb/arm-fbsd-tdep.c  | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/arm-fbsd-tdep.h  |  40 ++++++++
 gdb/configure.host   |   1 +
 gdb/configure.nat    |   5 +
 gdb/configure.tgt    |   5 +
 gdb/fbsd-tdep.c      |   2 +
 include/ChangeLog    |   4 +
 include/elf/common.h |   2 +
 14 files changed, 504 insertions(+)
 create mode 100644 gdb/arm-fbsd-nat.c
 create mode 100644 gdb/arm-fbsd-tdep.c
 create mode 100644 gdb/arm-fbsd-tdep.h

-- 
2.13.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 3/4] Add FreeBSD/arm architecture.
  2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
@ 2017-09-22 22:58 ` John Baldwin
  2017-09-22 22:58 ` [PATCH v2 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 9+ messages in thread
From: John Baldwin @ 2017-09-22 22:58 UTC (permalink / raw)
  To: gdb-patches, binutils

Support for collecting and supplying general purpose and floating
point registers is provided along with signal frame unwinding.  While
FreeBSD/arm kernels do populate NT_FPREGSET notes, they are always
zero-filled, so this implementation ignores them.  Recent FreeBSD/arm
kernels generate NT_ARM_VFP notes which are used to supply
floating-point registers.  As with Linux, the AT_HWCAP feature flags
are used to determine the correct target description.

gdb/ChangeLog:

	* Makefile.in (ALL_TARGET_OBS): Add arm-fbsd-tdep.o.
	(ALLDEPFILES): Add arm-fbsd-tdep.c.
	* NEWS: Mention new FreeBSD/arm target.
	* configure.tgt: Add arm*-*-freebsd*.
	* arm-fbsd-tdep.c: New file.
	* arm-fbsd-tdep.h: New file.
---
 gdb/ChangeLog       |   9 ++
 gdb/Makefile.in     |   2 +
 gdb/NEWS            |   1 +
 gdb/arm-fbsd-tdep.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/arm-fbsd-tdep.h |  40 ++++++++
 gdb/configure.tgt   |   5 +
 6 files changed, 317 insertions(+)
 create mode 100644 gdb/arm-fbsd-tdep.c
 create mode 100644 gdb/arm-fbsd-tdep.h

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7788bfc1a9..f09c24c81d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2017-09-22  John Baldwin  <jhb@FreeBSD.org>
 
+	* Makefile.in (ALL_TARGET_OBS): Add arm-fbsd-tdep.o.
+	(ALLDEPFILES): Add arm-fbsd-tdep.c.
+	* NEWS: Mention new FreeBSD/arm target.
+	* configure.tgt: Add arm*-*-freebsd*.
+	* arm-fbsd-tdep.c: New file.
+	* arm-fbsd-tdep.h: New file.
+
+2017-09-22  John Baldwin  <jhb@FreeBSD.org>
+
 	* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and
 	AT_HWCAP.
 
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 5740d43bb7..53514b0f49 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -792,6 +792,7 @@ ALL_TARGET_OBS = \
 	arc-tdep.o \
 	arm.o \
 	arm-bsd-tdep.o \
+	arm-fbsd-tdep.o \
 	arm-get-next-pcs.o \
 	arm-linux.o \
 	arm-linux-tdep.o \
@@ -2531,6 +2532,7 @@ ALLDEPFILES = \
 	arc-tdep.c \
 	arm.c \
 	arm-bsd-tdep.c \
+	arm-fbsd-tdep.c \
 	arm-get-next-pcs.c \
 	arm-linux.c \
 	arm-linux-nat.c \
diff --git a/gdb/NEWS b/gdb/NEWS
index 549f511b29..4e8ef17e0d 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -114,6 +114,7 @@ FreeBSD/aarch64			aarch64*-*-freebsd*
 * New targets
 
 FreeBSD/aarch64			aarch64*-*-freebsd*
+FreeBSD/arm			arm*-*-freebsd*
 
 *** Changes in GDB 8.0
 
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
new file mode 100644
index 0000000000..02697b3de8
--- /dev/null
+++ b/gdb/arm-fbsd-tdep.c
@@ -0,0 +1,260 @@
+/* Target-dependent code for FreeBSD/arm.
+
+   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 <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+
+#include "elf/common.h"
+#include "arm-tdep.h"
+#include "arm-fbsd-tdep.h"
+#include "auxv.h"
+#include "fbsd-tdep.h"
+#include "osabi.h"
+#include "solib-svr4.h"
+#include "target.h"
+#include "trad-frame.h"
+#include "tramp-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;
+	   mcontext_vfp_t sf_vfp;
+   };
+
+   ucontext_t is defined as:
+
+   struct __ucontext {
+	   sigset_t	uc_sigmask;
+	   mcontext_t	uc_mcontext;
+	   ...
+   };
+
+   mcontext_t is defined as:
+
+   struct {
+	   unsigned int __gregs[17];
+	   size_t       mc_vfp_size;
+	   void         *mc_vfp_ptr;
+	   ...
+   };
+
+   mcontext_vfp_t is defined as:
+
+   struct {
+	  uint64_t      mcv_reg[32];
+	  uint32_t      mcv_fpscr;
+   };
+
+   If the VFP state is valid, then mc_vfp_ptr will point to sf_vfp in
+   the sigframe, otherwise it is NULL.  There is no non-VFP floating
+   point register state saved in the signal frame.  */
+
+#define ARM_MCONTEXT_REG_SIZE		4
+#define ARM_MCONTEXT_VFP_REG_SIZE	8
+#define ARM_SIGFRAME_UCONTEXT_OFFSET	64
+#define ARM_UCONTEXT_MCONTEXT_OFFSET	16
+#define	ARM_MCONTEXT_VFP_PTR_OFFSET	72
+
+/* Implement the "init" method of struct tramp_frame.  */
+
+static void
+arm_fbsd_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, ARM_SP_REGNUM);
+  CORE_ADDR mcontext_addr =
+    sp
+    + ARM_SIGFRAME_UCONTEXT_OFFSET
+    + ARM_UCONTEXT_MCONTEXT_OFFSET;
+  CORE_ADDR mcontext_vfp_addr;
+  gdb_byte buf[4];
+  int i;
+
+  for (i = 0; i < 16; i++)
+    {
+      trad_frame_set_reg_addr (this_cache,
+			       ARM_A1_REGNUM + i,
+			       mcontext_addr + i * ARM_MCONTEXT_REG_SIZE);
+    }
+  trad_frame_set_reg_addr (this_cache, ARM_PS_REGNUM,
+			   mcontext_addr + 16 * ARM_MCONTEXT_REG_SIZE);
+
+  mcontext_vfp_addr = 0;
+  if (target_read_memory (mcontext_addr + ARM_MCONTEXT_VFP_PTR_OFFSET, buf,
+			  4) == 0)
+    mcontext_vfp_addr = extract_unsigned_integer (buf, 4, byte_order);
+  if (mcontext_vfp_addr != 0)
+    {
+      for (i = 0; i < 32; i++)
+	{
+	  trad_frame_set_reg_addr (this_cache, ARM_D0_REGNUM + i,
+				   mcontext_vfp_addr
+				   + i * ARM_MCONTEXT_VFP_REG_SIZE);
+	}
+      trad_frame_set_reg_addr (this_cache, ARM_FPSCR_REGNUM,
+			       mcontext_vfp_addr
+			       + 32 * ARM_MCONTEXT_VFP_REG_SIZE);
+    }
+
+  trad_frame_set_id (this_cache, frame_id_build (sp, func));
+}
+
+static const struct tramp_frame arm_fbsd_sigframe =
+{
+  SIGTRAMP_FRAME,
+  4,
+  {
+    {0xe1a0000d, -1},		/* mov  r0, sp  */
+    {0xe2800040, -1},		/* add  r0, r0, #SIGF_UC  */
+    {0xe59f700c, -1},		/* ldr  r7, [pc, #12]  */
+    {0xef0001a1, -1},		/* swi  SYS_sigreturn  */
+    {TRAMP_SENTINEL_INSN, -1}
+  },
+  arm_fbsd_sigframe_init
+};
+
+/* Register maps.  */
+
+static const struct regcache_map_entry arm_fbsd_gregmap[] =
+  {
+    { 13, ARM_A1_REGNUM, 4 }, /* r0 ... r12 */
+    { 1, ARM_SP_REGNUM, 4 },
+    { 1, ARM_LR_REGNUM, 4 },
+    { 1, ARM_PC_REGNUM, 4 },
+    { 1, ARM_PS_REGNUM, 4 },
+    { 0 }
+  };
+
+static const struct regcache_map_entry arm_fbsd_vfpregmap[] =
+  {
+    { 32, ARM_D0_REGNUM, 8 }, /* d0 ... d31 */
+    { 1, ARM_FPSCR_REGNUM, 4 },
+    { 0 }
+  };
+
+/* Register set definitions.  */
+
+const struct regset arm_fbsd_gregset =
+  {
+    arm_fbsd_gregmap,
+    regcache_supply_regset, regcache_collect_regset
+  };
+
+const struct regset arm_fbsd_vfpregset =
+  {
+    arm_fbsd_vfpregmap,
+    regcache_supply_regset, regcache_collect_regset
+  };
+
+/* Implement the "regset_from_core_section" gdbarch method.  */
+
+static void
+arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
+				       iterate_over_regset_sections_cb *cb,
+				       void *cb_data,
+				       const struct regcache *regcache)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  cb (".reg", ARM_FBSD_SIZEOF_GREGSET, &arm_fbsd_gregset, NULL, cb_data);
+
+  /* While FreeBSD/arm cores do contain a NT_FPREGSET / ".reg2"
+     register set, it is not populated with register values by the
+     kernel but just contains all zeroes.  */
+  if (tdep->vfp_register_count > 0)
+    cb (".reg-arm-vfp", ARM_FBSD_SIZEOF_VFPREGSET, &arm_fbsd_vfpregset,
+	"VFP floating-point", cb_data);
+}
+
+/* Lookup a target description from a target's AT_HWCAP auxiliary
+   vector.  */
+
+const struct target_desc *
+arm_fbsd_read_description_auxv (struct target_ops *target)
+{
+  CORE_ADDR arm_hwcap = 0;
+
+  if (target_auxv_search (target, AT_FREEBSD_HWCAP, &arm_hwcap) != 1)
+    return NULL;
+
+  if (arm_hwcap & HWCAP_VFP)
+    {
+      if (arm_hwcap & HWCAP_NEON)
+	return tdesc_arm_with_neon;
+      else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPD32))
+	  == (HWCAP_VFPv3 | HWCAP_VFPD32))
+	return tdesc_arm_with_vfpv3;
+      else
+	return tdesc_arm_with_vfpv2;
+    }
+
+  return NULL;
+}
+
+/* Implement the "core_read_description" gdbarch method.  */
+
+static const struct target_desc *
+arm_fbsd_core_read_description (struct gdbarch *gdbarch,
+				struct target_ops *target,
+				bfd *abfd)
+{
+  return arm_fbsd_read_description_auxv (target);
+}
+
+/* Implement the 'init_osabi' method of struct gdb_osabi_handler.  */
+
+static void
+arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  /* Generic FreeBSD support.  */
+  fbsd_init_abi (info, gdbarch);
+
+  if (tdep->fp_model == ARM_FLOAT_AUTO)
+    tdep->fp_model = ARM_FLOAT_SOFT_VFP;
+
+  tramp_frame_prepend_unwinder (gdbarch, &arm_fbsd_sigframe);
+
+  set_solib_svr4_fetch_link_map_offsets
+    (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+
+  tdep->jb_pc = 24;
+  tdep->jb_elt_size = 4;
+
+  set_gdbarch_iterate_over_regset_sections
+    (gdbarch, arm_fbsd_iterate_over_regset_sections);
+  set_gdbarch_core_read_description (gdbarch, arm_fbsd_core_read_description);
+
+  /* Single stepping.  */
+  set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+}
+
+void
+_initialize_arm_fbsd_tdep (void)
+{
+  gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_FREEBSD,
+			  arm_fbsd_init_abi);
+}
diff --git a/gdb/arm-fbsd-tdep.h b/gdb/arm-fbsd-tdep.h
new file mode 100644
index 0000000000..8717b804af
--- /dev/null
+++ b/gdb/arm-fbsd-tdep.h
@@ -0,0 +1,40 @@
+/* FreeBSD/arm target support, prototypes.
+
+   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 <http://www.gnu.org/licenses/>.  */
+
+#include "regset.h"
+
+/* The general-purpose regset consists of 13 R registers, plus SP, LR,
+   PC, and CPSR registers.  */
+#define ARM_FBSD_SIZEOF_GREGSET  (17 * 4)
+
+/* The VFP regset consists of 32 D registers plus FPSCR, and the whole
+   structure is padded to 64-bit alignment.  */
+#define	ARM_FBSD_SIZEOF_VFPREGSET	(33 * 8)
+
+extern const struct regset arm_fbsd_gregset;
+extern const struct regset arm_fbsd_vfpregset;
+
+/* Flags passed in AT_HWCAP. */
+#define	HWCAP_VFP		0x00000040
+#define	HWCAP_NEON		0x00001000
+#define	HWCAP_VFPv3		0x00002000
+#define	HWCAP_VFPD32		0x00080000
+
+extern const struct target_desc *
+arm_fbsd_read_description_auxv (struct target_ops *target);
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 7ac3ae0f42..4cffb743a3 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -110,6 +110,11 @@ arm*-*-linux*)
 			solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o"
 	build_gdbserver=yes
 	;;
+arm*-*-freebsd*)
+	# Target: FreeBSD/arm
+	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-fbsd-tdep.o \
+			fbsd-tdep.o solib-svr4.o"
+	;;
 arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
 	# Target: NetBSD/arm
 	gdb_target_obs="arm.o arm-get-next-pcs.o arm-tdep.o arm-nbsd-tdep.o \
-- 
2.13.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] Add native target for FreeBSD/arm.
  2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
                   ` (2 preceding siblings ...)
  2017-09-22 22:58 ` [PATCH v2 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
@ 2017-09-22 23:07 ` John Baldwin
  2017-09-24 23:49 ` [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB Alan Modra
  2017-09-29 17:46 ` John Baldwin
  5 siblings, 0 replies; 9+ messages in thread
From: John Baldwin @ 2017-09-22 23:07 UTC (permalink / raw)
  To: gdb-patches, binutils

gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add arm-fbsd-nat.c.
	* NEWS: Mention new FreeBSD/arm native configuration.
	* configure.host: Add arm*-*-freebsd*.
	* configure.nat: Likewise.
	* arm-fbsd-nat.c: New file.
---
 gdb/ChangeLog      |   8 +++
 gdb/Makefile.in    |   1 +
 gdb/NEWS           |   1 +
 gdb/arm-fbsd-nat.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/configure.host |   1 +
 gdb/configure.nat  |   5 ++
 6 files changed, 167 insertions(+)
 create mode 100644 gdb/arm-fbsd-nat.c

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f09c24c81d..0c7627c2ed 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2017-09-22  John Baldwin  <jhb@FreeBSD.org>
 
+	* Makefile.in (ALLDEPFILES): Add arm-fbsd-nat.c.
+	* NEWS: Mention new FreeBSD/arm native configuration.
+	* configure.host: Add arm*-*-freebsd*.
+	* configure.nat: Likewise.
+	* arm-fbsd-nat.c: New file.
+
+2017-09-22  John Baldwin  <jhb@FreeBSD.org>
+
 	* Makefile.in (ALL_TARGET_OBS): Add arm-fbsd-tdep.o.
 	(ALLDEPFILES): Add arm-fbsd-tdep.c.
 	* NEWS: Mention new FreeBSD/arm target.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 53514b0f49..bf416c6b66 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2532,6 +2532,7 @@ ALLDEPFILES = \
 	arc-tdep.c \
 	arm.c \
 	arm-bsd-tdep.c \
+	arm-fbsd-nat.c \
 	arm-fbsd-tdep.c \
 	arm-get-next-pcs.c \
 	arm-linux.c \
diff --git a/gdb/NEWS b/gdb/NEWS
index 4e8ef17e0d..4f30c1d861 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -110,6 +110,7 @@ starti
 * New native configurations
 
 FreeBSD/aarch64			aarch64*-*-freebsd*
+FreeBSD/arm			arm*-*-freebsd*
 
 * New targets
 
diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c
new file mode 100644
index 0000000000..b1c5c360f8
--- /dev/null
+++ b/gdb/arm-fbsd-nat.c
@@ -0,0 +1,151 @@
+/* Native-dependent code for FreeBSD/arm.
+
+   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 <http://www.gnu.org/licenses/>.  */
+
+#include "defs.h"
+#include "target.h"
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <machine/reg.h>
+
+#include "fbsd-nat.h"
+#include "arm-tdep.h"
+#include "arm-fbsd-tdep.h"
+#include "inf-ptrace.h"
+
+/* Determine if PT_GETREGS fetches REGNUM.  */
+
+static bool
+getregs_supplies (struct gdbarch *gdbarch, int regnum)
+{
+  return ((regnum >= ARM_A1_REGNUM && regnum <= ARM_PC_REGNUM)
+	  || regnum == ARM_PS_REGNUM);
+}
+
+#ifdef PT_GETVFPREGS
+/* Determine if PT_GETVFPREGS fetches REGNUM.  */
+
+static bool
+getvfpregs_supplies (struct gdbarch *gdbarch, int regnum)
+{
+  return ((regnum >= ARM_D0_REGNUM && regnum <= ARM_D31_REGNUM)
+	  || regnum == ARM_FPSCR_REGNUM);
+}
+#endif
+
+/* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
+   for all registers.  */
+
+static void
+arm_fbsd_fetch_inferior_registers (struct target_ops *ops,
+				    struct regcache *regcache, int regnum)
+{
+  pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
+
+  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) &regs, 0) == -1)
+	perror_with_name (_("Couldn't get registers"));
+
+      regcache->supply_regset (&arm_fbsd_gregset, regnum, &regs,
+			       sizeof (regs));
+    }
+
+#ifdef PT_GETVFPREGS
+  if (regnum == -1 || getvfpregs_supplies (gdbarch, regnum))
+    {
+      struct vfpreg vfpregs;
+
+      if (ptrace (PT_GETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1)
+	perror_with_name (_("Couldn't get floating point status"));
+
+      regcache->supply_regset (&arm_fbsd_vfpregset, regnum, &vfpregs,
+			       sizeof (vfpregs));
+    }
+#endif
+}
+
+/* Store register REGNUM back into the inferior.  If REGNUM is -1, do
+   this for all registers.  */
+
+static void
+arm_fbsd_store_inferior_registers (struct target_ops *ops,
+				    struct regcache *regcache, int regnum)
+{
+  pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
+
+  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) &regs, 0) == -1)
+	perror_with_name (_("Couldn't get registers"));
+
+      regcache->collect_regset (&arm_fbsd_gregset, regnum, &regs,
+			       sizeof (regs));
+
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+	perror_with_name (_("Couldn't write registers"));
+    }
+
+#ifdef PT_GETVFPREGS
+  if (regnum == -1 || getvfpregs_supplies (gdbarch, regnum))
+    {
+      struct vfpreg vfpregs;
+
+      if (ptrace (PT_GETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1)
+	perror_with_name (_("Couldn't get floating point status"));
+
+      regcache->collect_regset (&arm_fbsd_vfpregset, regnum, &vfpregs,
+				sizeof (vfpregs));
+
+      if (ptrace (PT_SETVFPREGS, pid, (PTRACE_TYPE_ARG3) &vfpregs, 0) == -1)
+	perror_with_name (_("Couldn't write floating point status"));
+    }
+#endif
+}
+
+/* Implement the to_read_description method.  */
+
+static const struct target_desc *
+arm_fbsd_read_description (struct target_ops *ops)
+{
+  const struct target_desc *desc;
+
+  desc = arm_fbsd_read_description_auxv (ops);
+  if (desc == NULL)
+    desc = ops->beneath->to_read_description (ops->beneath);
+  return desc;
+}
+
+void
+_initialize_arm_fbsd_nat (void)
+{
+  struct target_ops *t;
+
+  t = inf_ptrace_target ();
+  t->to_fetch_registers = arm_fbsd_fetch_inferior_registers;
+  t->to_store_registers = arm_fbsd_store_inferior_registers;
+  t->to_read_description = arm_fbsd_read_description;
+  fbsd_nat_add_target (t);
+}
diff --git a/gdb/configure.host b/gdb/configure.host
index 304675f137..ee53f25e9e 100644
--- a/gdb/configure.host
+++ b/gdb/configure.host
@@ -91,6 +91,7 @@ alpha*-*-netbsd* | alpha*-*-knetbsd*-gnu)
 			gdb_host=nbsd ;;
 alpha*-*-openbsd*)	gdb_host=nbsd ;;
 
+arm*-*-freebsd*)	gdb_host=fbsd ;;
 arm*-*-linux*)		gdb_host=linux ;;
 arm*-*-netbsdelf* | arm*-*-knetbsd*-gnu)
 			gdb_host=nbsdelf ;;
diff --git a/gdb/configure.nat b/gdb/configure.nat
index bf851f5ffc..4820936f5e 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -150,6 +150,11 @@ case ${gdb_host} in
 		NATDEPFILES="${NATDEPFILES} aarch64-fbsd-nat.o"
 		LOADLIBES=
 		;;
+	    arm)
+		# Host: FreeBSD/arm
+		NATDEPFILES="${NATDEPFILES} arm-fbsd-nat.o"
+		LOADLIBES=
+		;;
 	    i386)
 		# Host: FreeBSD/i386
 		NATDEPFILES="${NATDEPFILES} x86-nat.o x86-dregs.o \
-- 
2.13.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB
  2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
                   ` (3 preceding siblings ...)
  2017-09-22 23:07 ` [PATCH v2 4/4] Add native target for FreeBSD/arm John Baldwin
@ 2017-09-24 23:49 ` Alan Modra
  2017-09-29 17:46 ` John Baldwin
  5 siblings, 0 replies; 9+ messages in thread
From: Alan Modra @ 2017-09-24 23:49 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches, binutils

On Fri, Sep 22, 2017 at 03:57:09PM -0700, John Baldwin wrote:
> This series adds initial support for FreeBSD/arm to GDB.  It does not
> include support for hardware watchpoints or breakpoints.

Looks good to me, but you need a gdb maintainer to approve the patch
set.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB
  2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
                   ` (4 preceding siblings ...)
  2017-09-24 23:49 ` [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB Alan Modra
@ 2017-09-29 17:46 ` John Baldwin
  2017-10-11 11:14   ` Pedro Alves
  5 siblings, 1 reply; 9+ messages in thread
From: John Baldwin @ 2017-09-29 17:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: binutils

On Friday, September 22, 2017 03:57:09 PM John Baldwin wrote:
> This series adds initial support for FreeBSD/arm to GDB.  It does not
> include support for hardware watchpoints or breakpoints.
> 
> Relative to V1, patch 3 contains some additional changes to account
> for HWCAP_* renumbering in FreeBSD to align with Linux as well as
> handling HWCAP_NEON.
> 
> John Baldwin (4):
>   Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector
>     types.
>   Handle the NT_ARM_VFP core dump note on FreeBSD.
>   Add FreeBSD/arm architecture.
>   Add native target for FreeBSD/arm.
> 
>  bfd/ChangeLog        |   4 +
>  bfd/elf.c            |   3 +
>  gdb/ChangeLog        |  22 +++++
>  gdb/Makefile.in      |   3 +
>  gdb/NEWS             |   2 +
>  gdb/arm-fbsd-nat.c   | 151 ++++++++++++++++++++++++++++++
>  gdb/arm-fbsd-tdep.c  | 260 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  gdb/arm-fbsd-tdep.h  |  40 ++++++++
>  gdb/configure.host   |   1 +
>  gdb/configure.nat    |   5 +
>  gdb/configure.tgt    |   5 +
>  gdb/fbsd-tdep.c      |   2 +
>  include/ChangeLog    |   4 +
>  include/elf/common.h |   2 +
>  14 files changed, 504 insertions(+)
>  create mode 100644 gdb/arm-fbsd-nat.c
>  create mode 100644 gdb/arm-fbsd-tdep.c
>  create mode 100644 gdb/arm-fbsd-tdep.h

Ping?

Alan Modra has reviewed the binutils bits, and Eli signed off on the NEWS
change in V1.

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB
  2017-09-29 17:46 ` John Baldwin
@ 2017-10-11 11:14   ` Pedro Alves
  2017-10-11 17:07     ` John Baldwin
  0 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2017-10-11 11:14 UTC (permalink / raw)
  To: John Baldwin, gdb-patches; +Cc: binutils

On 09/29/2017 06:45 PM, John Baldwin wrote:

> Ping?
> 
> Alan Modra has reviewed the binutils bits, and Eli signed off on the NEWS
> change in V1.
> 

Sorry, missed that there was a v2.  In any case, same comment apply,
and the GDB changes look good to me.

I didn't mention explicitly, but just in case the configure.tgt
hunk still applies / builds as is: please be sure to update the
gdb/configure.tgt changes to follow the recent change that
split the cpu and os objects to separate switches.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB
  2017-10-11 11:14   ` Pedro Alves
@ 2017-10-11 17:07     ` John Baldwin
  0 siblings, 0 replies; 9+ messages in thread
From: John Baldwin @ 2017-10-11 17:07 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, binutils

On Wednesday, October 11, 2017 12:14:39 PM Pedro Alves wrote:
> On 09/29/2017 06:45 PM, John Baldwin wrote:
> 
> > Ping?
> > 
> > Alan Modra has reviewed the binutils bits, and Eli signed off on the NEWS
> > change in V1.
> > 
> 
> Sorry, missed that there was a v2.  In any case, same comment apply,
> and the GDB changes look good to me.
> 
> I didn't mention explicitly, but just in case the configure.tgt
> hunk still applies / builds as is: please be sure to update the
> gdb/configure.tgt changes to follow the recent change that
> split the cpu and os objects to separate switches.

Yes, I've already updated for that locally.  I'll work on pulling in the
other fixes as well.

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-10-11 17:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-22 22:58 [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
2017-09-22 22:58 ` [PATCH v2 3/4] Add FreeBSD/arm architecture John Baldwin
2017-09-22 22:58 ` [PATCH v2 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
2017-09-22 22:58 ` [PATCH v2 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
2017-09-22 23:07 ` [PATCH v2 4/4] Add native target for FreeBSD/arm John Baldwin
2017-09-24 23:49 ` [PATCH v2 0/4] Initial support for FreeBSD/arm in GDB Alan Modra
2017-09-29 17:46 ` John Baldwin
2017-10-11 11:14   ` Pedro Alves
2017-10-11 17:07     ` John Baldwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).