Make dwarf2_get_dwz_file take a dwarf2_per_bfd
[deliverable/binutils-gdb.git] / gdb / arm-nbsd-nat.c
index 04fedd4be3af266523f2e7dacb14c876976d40a8..a8a67e6e85202c71bfeb905d356b3f28f23b6380 100644 (file)
 #include <machine/frame.h>
 
 #include "arm-tdep.h"
+#include "arm-nbsd-tdep.h"
 #include "aarch32-tdep.h"
 #include "inf-ptrace.h"
+#include "nbsd-nat.h"
 
-class arm_netbsd_nat_target final : public inf_ptrace_target
+class arm_netbsd_nat_target final : public nbsd_nat_target
 {
 public:
   /* Add our register access methods.  */
@@ -45,28 +47,6 @@ public:
 
 static arm_netbsd_nat_target the_arm_netbsd_nat_target;
 
-static void
-arm_supply_gregset (struct regcache *regcache, struct reg *gregset)
-{
-  int regno;
-  CORE_ADDR r_pc;
-
-  /* Integer registers.  */
-  for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++)
-    regcache->raw_supply (regno, (char *) &gregset->r[regno]);
-
-  regcache->raw_supply (ARM_SP_REGNUM, (char *) &gregset->r_sp);
-  regcache->raw_supply (ARM_LR_REGNUM, (char *) &gregset->r_lr);
-  /* This is ok: we're running native...  */
-  r_pc = gdbarch_addr_bits_remove (regcache->arch (), gregset->r_pc);
-  regcache->raw_supply (ARM_PC_REGNUM, (char *) &r_pc);
-
-  if (arm_apcs_32)
-    regcache->raw_supply (ARM_PS_REGNUM, (char *) &gregset->r_cpsr);
-  else
-    regcache->raw_supply (ARM_PS_REGNUM, (char *) &gregset->r_pc);
-}
-
 static void
 arm_supply_vfpregset (struct regcache *regcache, struct fpreg *fpregset)
 {
@@ -86,74 +66,28 @@ fetch_register (struct regcache *regcache, int regno)
 {
   struct reg inferior_registers;
   int ret;
+  int lwp = regcache->ptid ().lwp ();
 
   ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     {
       warning (_("unable to fetch general register"));
       return;
     }
-
-  switch (regno)
-    {
-    case ARM_SP_REGNUM:
-      regcache->raw_supply (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp);
-      break;
-
-    case ARM_LR_REGNUM:
-      regcache->raw_supply (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr);
-      break;
-
-    case ARM_PC_REGNUM:
-      /* This is ok: we're running native...  */
-      inferior_registers.r_pc = gdbarch_addr_bits_remove
-                                 (regcache->arch (),
-                                  inferior_registers.r_pc);
-      regcache->raw_supply (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc);
-      break;
-
-    case ARM_PS_REGNUM:
-      if (arm_apcs_32)
-       regcache->raw_supply (ARM_PS_REGNUM,
-                             (char *) &inferior_registers.r_cpsr);
-      else
-       regcache->raw_supply (ARM_PS_REGNUM,
-                             (char *) &inferior_registers.r_pc);
-      break;
-
-    default:
-      regcache->raw_supply (regno, (char *) &inferior_registers.r[regno]);
-      break;
-    }
-}
-
-static void
-fetch_regs (struct regcache *regcache)
-{
-  struct reg inferior_registers;
-  int ret;
-  int regno;
-
-  ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
-
-  if (ret < 0)
-    {
-      warning (_("unable to fetch general registers"));
-      return;
-    }
-
-  arm_supply_gregset (regcache, &inferior_registers);
+  arm_nbsd_supply_gregset (nullptr, regcache, regno, &inferior_registers,
+                          sizeof (inferior_registers));
 }
 
 static void
 fetch_fp_register (struct regcache *regcache, int regno)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
+
   int ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   struct vfpreg &vfp = inferior_fp_registers.fpr_vfp;
 
@@ -180,11 +114,12 @@ static void
 fetch_fp_regs (struct regcache *regcache)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
   int regno;
 
   ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   if (ret < 0)
     {
@@ -207,7 +142,7 @@ arm_netbsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
     }
   else
     {
-      fetch_regs (regcache);
+      fetch_register (regcache, -1);
       fetch_fp_regs (regcache);
     }
 }
@@ -218,10 +153,11 @@ store_register (const struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct reg inferior_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
 
   ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     {
@@ -279,7 +215,7 @@ store_register (const struct regcache *regcache, int regno)
     }
 
   ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
@@ -290,6 +226,7 @@ store_regs (const struct regcache *regcache)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct reg inferior_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
   int regno;
 
@@ -321,7 +258,7 @@ store_regs (const struct regcache *regcache)
     }
 
   ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to store general registers"));
@@ -331,8 +268,9 @@ static void
 store_fp_register (const struct regcache *regcache, int regno)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
   struct vfpreg &vfp = inferior_fp_registers.fpr_vfp;
 
   if (ret < 0)
@@ -354,7 +292,7 @@ store_fp_register (const struct regcache *regcache, int regno)
     warning (_("Invalid register number."));
 
   ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
@@ -364,6 +302,7 @@ static void
 store_fp_regs (const struct regcache *regcache)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
+  int lwp = regcache->ptid ().lwp ();
   if (tdep->vfp_register_count == 0)
     return;
 
@@ -376,7 +315,7 @@ store_fp_regs (const struct regcache *regcache)
                         (char *) &fpregs.fpr_vfp.vfp_fpscr);
 
   int ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-                   (PTRACE_TYPE_ARG3) &fpregs, 0);
+                   (PTRACE_TYPE_ARG3) &fpregs, lwp);
 
   if (ret < 0)
     warning (_("unable to store floating-point registers"));
@@ -416,56 +355,9 @@ arm_netbsd_nat_target::read_description ()
   return arm_read_description (ARM_FP_TYPE_VFPV3);
 }
 
-static void
-fetch_elfcore_registers (struct regcache *regcache,
-                        gdb_byte *core_reg_sect, unsigned core_reg_size,
-                        int which, CORE_ADDR ignore)
-{
-  struct reg gregset;
-  struct fpreg fparegset;
-
-  switch (which)
-    {
-    case 0:    /* Integer registers.  */
-      if (core_reg_size != sizeof (struct reg))
-       warning (_("wrong size of register set in core file"));
-      else
-       {
-         /* The memcpy may be unnecessary, but we can't really be sure
-            of the alignment of the data in the core file.  */
-         memcpy (&gregset, core_reg_sect, sizeof (gregset));
-         arm_supply_gregset (regcache, &gregset);
-       }
-      break;
-
-    case 2:
-      /* cbiesinger/2020-02-12 -- as far as I can tell, ARM/NetBSD does
-         not write any floating point registers into the core file (tested
-        with NetBSD 9.1_RC1).  When it does, this block will need to read them,
-        and the arm-netbsd gdbarch will need a core_read_description function
-        to return the right description for them.  */
-      break;
-
-    default:
-      /* Don't know what kind of register request this is; just ignore it.  */
-      break;
-    }
-}
-
-static struct core_fns arm_netbsd_elfcore_fns =
-{
-  bfd_target_elf_flavour,              /* core_flavour.  */
-  default_check_format,                        /* check_format.  */
-  default_core_sniffer,                        /* core_sniffer.  */
-  fetch_elfcore_registers,             /* core_read_registers.  */
-  NULL
-};
-
 void _initialize_arm_netbsd_nat ();
 void
 _initialize_arm_netbsd_nat ()
 {
   add_inf_child_target (&the_arm_netbsd_nat_target);
-
-  deprecated_add_core_fns (&arm_netbsd_elfcore_fns);
 }
This page took 0.027176 seconds and 4 git commands to generate.