Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/gdb/dist/gdb more cleanups and homogenization



details:   https://anonhg.NetBSD.org/src/rev/883eb3a1a6e0
branches:  trunk
changeset: 841743:883eb3a1a6e0
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 30 01:19:36 2019 +0000

description:
more cleanups and homogenization

diffstat:

 external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c |   46 +++----
 external/gpl3/gdb/dist/gdb/alpha-bsd-nat.c    |   33 +++--
 external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c     |  152 ++++++++++++-------------
 external/gpl3/gdb/dist/gdb/hppa-nbsd-nat.c    |   26 ++--
 external/gpl3/gdb/dist/gdb/i386-bsd-nat.c     |   26 ++--
 external/gpl3/gdb/dist/gdb/m68k-bsd-nat.c     |    5 +
 external/gpl3/gdb/dist/gdb/mips-nbsd-nat.c    |   28 ++--
 external/gpl3/gdb/dist/gdb/ppc-nbsd-nat.c     |   60 ++--------
 external/gpl3/gdb/dist/gdb/sh-nbsd-nat.c      |   36 ++---
 external/gpl3/gdb/dist/gdb/sparc-nat.c        |   12 +-
 external/gpl3/gdb/dist/gdb/sparc-nbsd-nat.c   |   34 -----
 external/gpl3/gdb/dist/gdb/sparc64-nbsd-nat.c |    2 -
 external/gpl3/gdb/dist/gdb/vax-bsd-nat.c      |   24 ++-
 external/gpl3/gdb/dist/gdb/x86-bsd-nat.c      |    2 +-
 14 files changed, 215 insertions(+), 271 deletions(-)

diffs (truncated from 1259 to 300 lines):

diff -r 1900c5ff13f1 -r 883eb3a1a6e0 external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c     Wed May 29 22:12:16 2019 +0000
+++ b/external/gpl3/gdb/dist/gdb/aarch64-nbsd-nat.c     Thu May 30 01:19:36 2019 +0000
@@ -36,6 +36,14 @@
 
 /* Determine if PT_GETREGS fetches REGNUM.  */
 
+struct aarch64_nbsd_nat_target final : public nbsd_nat_target
+{
+  void fetch_registers (struct regcache *, int) override;
+  void store_registers (struct regcache *, int) override;
+};
+
+static aarch64_nbsd_nat_target the_aarch64_nbsd_nat_target;
+
 static bool
 getregs_supplies (struct gdbarch *gdbarch, int regnum)
 {
@@ -50,23 +58,19 @@
   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)
+void
+aarch64_nbsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
 {
-  ptid_t ptid = regcache_get_ptid (regcache);
-  pid_t pid = ptid_get_pid (ptid);
-  int tid = ptid_get_lwp (ptid);
+  ptid_t ptid = regcache->ptid ();
+  pid_t pid = ptid.pid ();
+  int lwp = ptid.lwp ();
 
   struct gdbarch *gdbarch = regcache->arch ();
   if (regnum == -1 || getregs_supplies (gdbarch, regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, tid) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, lwp) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       regcache_supply_regset (&aarch64_nbsd_gregset, regcache, regnum, &regs,
@@ -77,7 +81,7 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, tid) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
        perror_with_name (_("Couldn't get floating point status"));
 
       regcache_supply_regset (&aarch64_nbsd_fpregset, regcache, regnum, &fpregs,
@@ -88,20 +92,19 @@
 /* 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)
+void
+aarch64_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
 {
-  ptid_t ptid = regcache_get_ptid (regcache);
-  pid_t pid = ptid_get_pid (ptid);
-  int tid = ptid_get_lwp (ptid);
+  ptid_t ptid = regcache->ptid ();
+  pid_t pid = ptid.pid ();
+  int lwp = ptid.lwp ();
 
   struct gdbarch *gdbarch = regcache->arch ();
   if (regnum == -1 || getregs_supplies (gdbarch, regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, tid) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, lwp) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       regcache_collect_regset (&aarch64_nbsd_gregset, regcache,regnum, &regs,
@@ -173,12 +176,7 @@
 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);
+  add_inf_child_target (&the_aarch64_nbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (aarch64_nbsd_supply_pcb);
diff -r 1900c5ff13f1 -r 883eb3a1a6e0 external/gpl3/gdb/dist/gdb/alpha-bsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/alpha-bsd-nat.c        Wed May 29 22:12:16 2019 +0000
+++ b/external/gpl3/gdb/dist/gdb/alpha-bsd-nat.c        Thu May 30 01:19:36 2019 +0000
@@ -47,7 +47,12 @@
 
 #include "gregset.h"
 
+#ifdef __NetBSD__
+#include nbsd-nat.h"
+struct alpha_bsd_nat_target final : public nbsd_nat_target
+#else
 struct alpha_bsd_nat_target final : public inf_ptrace_target
+#endif
 {
   void fetch_registers (struct regcache *, int) override;
   void store_registers (struct regcache *, int) override;
@@ -98,12 +103,15 @@
 void
 alpha_bsd_nat_target::fetch_registers (struct regcache *regcache, int regno)
 {
+  ptid_t ptid = regcache->ptid ();
+  pid_t pid = ptid.pid ();
+  int lwp = ptid.lwp ();
+
   if (regno == -1 || getregs_supplies (regno))
     {
       struct reg gregs;
 
-      if (ptrace (PT_GETREGS, regcache->ptid ().pid (),
-                 (PTRACE_TYPE_ARG3) &gregs, inferior_ptid.lwp ()) == -1) 
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &gregs, lwp) == -1) 
        perror_with_name (_("Couldn't get registers"));
 
       alphabsd_supply_reg (regcache, (char *) &gregs, regno);
@@ -116,8 +124,7 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-                 (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
        perror_with_name (_("Couldn't get floating point status"));
 
       alphabsd_supply_fpreg (regcache, (char *) &fpregs, regno);
@@ -130,17 +137,20 @@
 void
 alpha_bsd_nat_target::store_registers (struct regcache *regcache, int regno)
 {
+  ptid_t ptid = regcache->ptid ();
+  pid_t pid = ptid.pid ();
+  int lwp = ptid.lwp ();
+
   if (regno == -1 || getregs_supplies (regno))
     {
       struct reg gregs;
-      if (ptrace (PT_GETREGS, regcache->ptid ().pid (),
-                  (PTRACE_TYPE_ARG3) &gregs, inferior_ptid.lwp ()) == -1)
+      if (ptrace (PT_GETREGS, pid,
+                  (PTRACE_TYPE_ARG3) &gregs, lwp) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       alphabsd_fill_reg (regcache, (char *) &gregs, regno);
 
-      if (ptrace (PT_SETREGS, regcache->ptid ().pid (),
-                  (PTRACE_TYPE_ARG3) &gregs, inferior_ptid.lwp ()) == -1) 
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &gregs, lwp) == -1) 
         perror_with_name (_("Couldn't write registers"));
 
       if (regno != -1)
@@ -152,14 +162,13 @@
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-                 (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1)
        perror_with_name (_("Couldn't get floating point status"));
 
       alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
 
-      if (ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-                 (PTRACE_TYPE_ARG3) &fpregs, inferior_ptid.lwp ()) == -1) 
+      if (ptrace (PT_SETFPREGS, pid,
+                 (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1) 
        perror_with_name (_("Couldn't write floating point status"));
     }
 }
diff -r 1900c5ff13f1 -r 883eb3a1a6e0 external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c
--- a/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Wed May 29 22:12:16 2019 +0000
+++ b/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Thu May 30 01:19:36 2019 +0000
@@ -50,7 +50,7 @@
 
 #include "gregset.h"
 
-class arm_netbsd_nat_target final : public inf_ptrace_target
+class arm_nbsd_nat_target final : public nbsd_nat_target
 {
 public:
   /* Add our register access methods.  */
@@ -58,7 +58,7 @@
   void store_registers (struct regcache *, int) override;
 };
 
-static arm_netbsd_nat_target the_arm_netbsd_nat_target;
+static arm_nbsd_nat_target the_arm_nbsd_nat_target;
 
 extern int arm_apcs_32;
 
@@ -136,20 +136,21 @@
   int regno;
 
   for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++)
-    regcache->raw_supply (regno,
-                         (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]);
+    regcache->raw_supply (regno, (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]);
 
   regcache->raw_supply (ARM_FPS_REGNUM, (char *) &fparegset->fpr_fpsr);
 }
 
 static void
-fetch_register (struct regcache *regcache, int regno)
+arm_nbsd_nat_fetch_register (struct regcache *regcache, int regno)
 {
-  struct reg inferior_registers;
+  struct reg regs;
+  ptid_t ptid = regcache->ptid ();
+  pid_t pid = ptid.pid ();
+  int lwp = ptid.lwp ();
   int ret;
 
-  ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, inferior_ptid.lwp ());
+  ret = ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, lwp);
 
   if (ret < 0)
     {
@@ -160,32 +161,28 @@
   switch (regno)
     {
     case ARM_SP_REGNUM:
-      regcache->raw_supply (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp);
+      regcache->raw_supply (ARM_SP_REGNUM, (char *) &regs.r_sp);
       break;
 
     case ARM_LR_REGNUM:
-      regcache->raw_supply (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr);
+      regcache->raw_supply (ARM_LR_REGNUM, (char *) &regs.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);
+      regs.r_pc = gdbarch_addr_bits_remove (regcache->arch (), regs.r_pc);
+      regcache->raw_supply (ARM_PC_REGNUM, (char *) &regs.r_pc);
       break;
 
     case ARM_PS_REGNUM:
       if (arm_apcs_32)
-       regcache->raw_supply (ARM_PS_REGNUM,
-                             (char *) &inferior_registers.r_cpsr);
+       regcache->raw_supply (ARM_PS_REGNUM, (char *) &regs.r_cpsr);
       else
-       regcache->raw_supply (ARM_PS_REGNUM,
-                             (char *) &inferior_registers.r_pc);
+       regcache->raw_supply (ARM_PS_REGNUM, (char *) &regs.r_pc);
       break;
 
     default:
-      regcache->raw_supply (regno, (char *) &inferior_registers.r[regno]);
+      regcache->raw_supply (regno, (char *) &regs.r[regno]);
       break;
     }
 }
@@ -193,12 +190,14 @@
 static void
 fetch_regs (struct regcache *regcache)
 {
-  struct reg inferior_registers;
+  ptid_t ptid = regcache->ptid ();
+  pid_t pid = ptid.pid ();
+  int lwp = ptid.lwp ();
+  struct reg regs;
   int ret;
   int regno;
 
-  ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, inferior_ptid.lwp ());
+  ret = ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, lwp);
 
   if (ret < 0)
     {
@@ -206,17 +205,17 @@
       return;
     }
 
-  arm_supply_gregset (regcache, &inferior_registers);
+  arm_supply_gregset (regcache, &regs);
 }
 



Home | Main Index | Thread Index | Old Index