public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD.
  2017-09-14 15:18 [PATCH 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
  2017-09-14 15:18 ` [PATCH 3/4] Add FreeBSD/arm architecture John Baldwin
  2017-09-14 15:18 ` [PATCH 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
@ 2017-09-14 15:18 ` John Baldwin
  2017-10-05 13:47   ` Nick Clifton
  2017-09-14 15:25 ` [PATCH 4/4] Add native target for FreeBSD/arm John Baldwin
  3 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2017-09-14 15:18 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 3d807b9f6c..a2a1972793 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,7 @@
+2017-09-14  John Baldwin  <jhb@FreeBSD.org>
+
+	* elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_VFP.
+
 2017-09-14  Nick Clifton  <nickc@redhat.com>
 
 	PR binutils/22113
diff --git a/bfd/elf.c b/bfd/elf.c
index 2aa2337724..1fb735d9a7 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] 11+ messages in thread

* [PATCH 3/4] Add FreeBSD/arm architecture.
  2017-09-14 15:18 [PATCH 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
@ 2017-09-14 15:18 ` John Baldwin
  2017-10-11 11:05   ` Pedro Alves
  2017-09-14 15:18 ` [PATCH 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2017-09-14 15:18 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 | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/arm-fbsd-tdep.h |  39 ++++++++
 gdb/configure.tgt   |   5 +
 6 files changed, 314 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 a32dceaea9..74928c0113 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 2017-09-14  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-14  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 2aa474e598..3468e34b6e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -790,6 +790,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 \
@@ -2529,6 +2530,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 2e6d48c016..f33b7ac49f 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -105,6 +105,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..23c3906b10
--- /dev/null
+++ b/gdb/arm-fbsd-tdep.c
@@ -0,0 +1,258 @@
+/* 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_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..7764a0fbe3
--- /dev/null
+++ b/gdb/arm-fbsd-tdep.h
@@ -0,0 +1,39 @@
+/* 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_VFPv3		0x00000200
+#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 9d9ef4b0f9..6a2003e0e8 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -109,6 +109,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] 11+ messages in thread

* [PATCH 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types.
  2017-09-14 15:18 [PATCH 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
  2017-09-14 15:18 ` [PATCH 3/4] Add FreeBSD/arm architecture John Baldwin
@ 2017-09-14 15:18 ` John Baldwin
  2017-10-05 13:47   ` Nick Clifton
  2017-09-14 15:18 ` [PATCH 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
  2017-09-14 15:25 ` [PATCH 4/4] Add native target for FreeBSD/arm John Baldwin
  3 siblings, 1 reply; 11+ messages in thread
From: John Baldwin @ 2017-09-14 15:18 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 f88cd6e1a4..a32dceaea9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-14  John Baldwin  <jhb@FreeBSD.org>
+
+	* fbsd-tdep.c (fbsd_print_auxv_entry): Handle AT_EHDRFLAGS and
+	AT_HWCAP.
+
 2017-09-14  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* dwarf2expr.h (dwarf_expr_context) <stack_empty_p>: 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 3b6cea9664..28d6a5cda3 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2016-09-14  John Baldwin  <jhb@FreeBSD.org>
+
+	* elf/common.h (AT_FREEBSD_EHDRFLAGS, AT_FREEBSD_HWCAP): Define.
+
 2017-09-06  Kamil Rytarowski  <n54@gmx.com>
 
 	* opcode/nds32.h: Rename __BIT() to N32_BIT().
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] 11+ messages in thread

* [PATCH 0/4] Initial support for FreeBSD/arm in GDB
@ 2017-09-14 15:18 John Baldwin
  2017-09-14 15:18 ` [PATCH 3/4] Add FreeBSD/arm architecture John Baldwin
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: John Baldwin @ 2017-09-14 15:18 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.

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  | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/arm-fbsd-tdep.h  |  39 ++++++++
 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, 501 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] 11+ messages in thread

* [PATCH 4/4] Add native target for FreeBSD/arm.
  2017-09-14 15:18 [PATCH 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
                   ` (2 preceding siblings ...)
  2017-09-14 15:18 ` [PATCH 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
@ 2017-09-14 15:25 ` John Baldwin
  2017-09-14 17:25   ` Eli Zaretskii
  2017-10-11 11:08   ` Pedro Alves
  3 siblings, 2 replies; 11+ messages in thread
From: John Baldwin @ 2017-09-14 15:25 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 74928c0113..f69bd06aec 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
 2017-09-14  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-14  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 3468e34b6e..52f1c5cd19 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2530,6 +2530,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 f33b7ac49f..c54a458530 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -101,6 +101,7 @@ show debug separate-debug-file
 * 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 a318b4a5a9..c08079b7ea 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] 11+ messages in thread

* Re: [PATCH 4/4] Add native target for FreeBSD/arm.
  2017-09-14 15:25 ` [PATCH 4/4] Add native target for FreeBSD/arm John Baldwin
@ 2017-09-14 17:25   ` Eli Zaretskii
  2017-10-11 11:08   ` Pedro Alves
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2017-09-14 17:25 UTC (permalink / raw)
  To: John Baldwin; +Cc: gdb-patches, binutils

> From: John Baldwin <jhb@FreeBSD.org>
> Date: Thu, 14 Sep 2017 08:18:31 -0700
> 
> 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.

OK for the NEWS part.

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

* Re: [PATCH 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types.
  2017-09-14 15:18 ` [PATCH 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
@ 2017-10-05 13:47   ` Nick Clifton
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Clifton @ 2017-10-05 13:47 UTC (permalink / raw)
  To: John Baldwin, gdb-patches, binutils

Hi John,

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

This change is approved.

Cheers
  Nick


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

* Re: [PATCH 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD.
  2017-09-14 15:18 ` [PATCH 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
@ 2017-10-05 13:47   ` Nick Clifton
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Clifton @ 2017-10-05 13:47 UTC (permalink / raw)
  To: John Baldwin, gdb-patches, binutils

Hi John,

> bfd/ChangeLog:
> 
> 	* elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_VFP.

Approved - please apply.

Cheers
  Nick


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

* Re: [PATCH 3/4] Add FreeBSD/arm architecture.
  2017-09-14 15:18 ` [PATCH 3/4] Add FreeBSD/arm architecture John Baldwin
@ 2017-10-11 11:05   ` Pedro Alves
  2017-10-11 17:07     ` John Baldwin
  0 siblings, 1 reply; 11+ messages in thread
From: Pedro Alves @ 2017-10-11 11:05 UTC (permalink / raw)
  To: John Baldwin, gdb-patches, binutils

On 09/14/2017 04:18 PM, John Baldwin wrote:
> 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.
> 

Hi John.  FWIW, this looks good to me.  I'm comfortable with
you self-approving this as FreeBSD maintainer after a
period, BTW.  A few minor nits below.

> diff --git a/gdb/NEWS b/gdb/NEWS
> index 2e6d48c016..f33b7ac49f 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -105,6 +105,7 @@ FreeBSD/aarch64			aarch64*-*-freebsd*
>  * New targets
>  
>  FreeBSD/aarch64			aarch64*-*-freebsd*
> +FreeBSD/arm			arm*-*-freebsd*

It'd be nice to update the hosts table at:
 https://sourceware.org/gdb/wiki/Systems

(I've added a notes column now, thinking that we'd start
saying something like "since GDB 8.1".  We could rename
the column too.)

> +#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

Space vs tab after #define in the last line above.


> +
> +/* 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;

= goes on next line.  Then per GNU standards (because that's
what Emacs likes), to line up the multiple lines, wrap in parens:

  CORE_ADDR mcontext_addr 
    = (sp
       + ARM_SIGFRAME_UCONTEXT_OFFSET
       + ARM_UCONTEXT_MCONTEXT_OFFSET);

Thought this would fit too, and is shorter:

  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++)

Suggest writing:

 for (int 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);

I mildly wonder whether this be:

  if (safe_read_memory_unsigned_integer (mcontext_addr + ARM_MCONTEXT_VFP_PTR_OFFSET, 4,
                                         byte_order, &mcontext_vfp_addr)
    {
      for (i = 0; i < 32; i++)
       ....

I'd convey intention and avoid the "= 0" initialization + "!= 0" check
(unless you need it anyway).

Thanks,
Pedro Alves

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

* Re: [PATCH 4/4] Add native target for FreeBSD/arm.
  2017-09-14 15:25 ` [PATCH 4/4] Add native target for FreeBSD/arm John Baldwin
  2017-09-14 17:25   ` Eli Zaretskii
@ 2017-10-11 11:08   ` Pedro Alves
  1 sibling, 0 replies; 11+ messages in thread
From: Pedro Alves @ 2017-10-11 11:08 UTC (permalink / raw)
  To: John Baldwin, gdb-patches, binutils

On 09/14/2017 04:18 PM, John Baldwin wrote:
> 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.

Looks fine to me.

Thanks,
Pedro Alves

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

* Re: [PATCH 3/4] Add FreeBSD/arm architecture.
  2017-10-11 11:05   ` Pedro Alves
@ 2017-10-11 17:07     ` John Baldwin
  0 siblings, 0 replies; 11+ 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:05:35 PM Pedro Alves wrote:
> On 09/14/2017 04:18 PM, John Baldwin wrote:
> > 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.
> > 
> 
> Hi John.  FWIW, this looks good to me.  I'm comfortable with
> you self-approving this as FreeBSD maintainer after a
> period, BTW.  A few minor nits below.
> 
> > diff --git a/gdb/NEWS b/gdb/NEWS
> > index 2e6d48c016..f33b7ac49f 100644
> > --- a/gdb/NEWS
> > +++ b/gdb/NEWS
> > @@ -105,6 +105,7 @@ FreeBSD/aarch64			aarch64*-*-freebsd*
> >  * New targets
> >  
> >  FreeBSD/aarch64			aarch64*-*-freebsd*
> > +FreeBSD/arm			arm*-*-freebsd*
> 
> It'd be nice to update the hosts table at:
>  https://sourceware.org/gdb/wiki/Systems
> 
> (I've added a notes column now, thinking that we'd start
> saying something like "since GDB 8.1".  We could rename
> the column too.)
> 
> > +#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
> 
> Space vs tab after #define in the last line above.

Fixed.

> > +
> > +/* 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;
> 
> = goes on next line.  Then per GNU standards (because that's
> what Emacs likes), to line up the multiple lines, wrap in parens:
> 
>   CORE_ADDR mcontext_addr 
>     = (sp
>        + ARM_SIGFRAME_UCONTEXT_OFFSET
>        + ARM_UCONTEXT_MCONTEXT_OFFSET);
> 
> Thought this would fit too, and is shorter:
> 
>   CORE_ADDR mcontext_addr = (sp
>                              + ARM_SIGFRAME_UCONTEXT_OFFSET
>                              + ARM_UCONTEXT_MCONTEXT_OFFSET);
 
Ok, the second looks better to me.

> > +  CORE_ADDR mcontext_vfp_addr;
> > +  gdb_byte buf[4];
> > +  int i;
> > +
> > +  for (i = 0; i < 16; i++)
> 
> Suggest writing:
> 
>  for (int i = 0; i < 16; i++)

Done.

> > +    {
> > +      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);
> 
> I mildly wonder whether this be:
> 
>   if (safe_read_memory_unsigned_integer (mcontext_addr + ARM_MCONTEXT_VFP_PTR_OFFSET, 4,
>                                          byte_order, &mcontext_vfp_addr)
>     {
>       for (i = 0; i < 32; i++)
>        ....
> 
> I'd convey intention and avoid the "= 0" initialization + "!= 0" check
> (unless you need it anyway).

I do need the != 0 check, but safe_read_memory_unsigned_integer does indeed
look nicer.

BTW, while working on the arm and aarch64 FreeBSD backends I've really liked
having the arrays of 'struct regcache_map_entry' objects.  I think I'd like
to add a similar type of 'map' array for work with trad_frame used for
signal frames as then one can just define a structure to describe the layout
and perhaps give a starting CORE_ADDR and the 'map' array as args to a
trad_frame function that would handle calling trad_frame_set_reg_addr().

-- 
John Baldwin

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14 15:18 [PATCH 0/4] Initial support for FreeBSD/arm in GDB John Baldwin
2017-09-14 15:18 ` [PATCH 3/4] Add FreeBSD/arm architecture John Baldwin
2017-10-11 11:05   ` Pedro Alves
2017-10-11 17:07     ` John Baldwin
2017-09-14 15:18 ` [PATCH 1/4] Handle FreeBSD-specific AT_EHDRFLAGS and AT_HWCAP auxiliary vector types John Baldwin
2017-10-05 13:47   ` Nick Clifton
2017-09-14 15:18 ` [PATCH 2/4] Handle the NT_ARM_VFP core dump note on FreeBSD John Baldwin
2017-10-05 13:47   ` Nick Clifton
2017-09-14 15:25 ` [PATCH 4/4] Add native target for FreeBSD/arm John Baldwin
2017-09-14 17:25   ` Eli Zaretskii
2017-10-11 11:08   ` Pedro Alves

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).