This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Cleanups to FreeBSD/mips native register operations.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d489d81d0934c4fda8c8aa68fbec1b1315cf8df0

commit d489d81d0934c4fda8c8aa68fbec1b1315cf8df0
Author: John Baldwin <jhb@FreeBSD.org>
Date:   Tue Apr 18 10:49:44 2017 -0700

    Cleanups to FreeBSD/mips native register operations.
    
    Compare against the "raw" PC register number instead of the cooked
    register number when determining if a register was handled by
    PT_GETREGS.  Previously the register fetch/store operations only tried
    PT_GETREGS to fetch any individual register.  The result was that
    fetching or storing an individual register not covered by PT_GETREGS
    (such as floating point registers) did not work.
    
    While here, remove an early exit to simplify the code flow from the
    PT_GETREGS / PT_SETREGS case, and add a getfpregs_supplies similar to
    getregs_supplies to describe the registers supplied by PT_GETFPREGS
    and PT_SETFPREGS.
    
    gdb/ChangeLog:
    
    	* mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison.
    	(getpfpregs_supplies): New function.
    	(mips_fbsd_fetch_inferior_registers): Remove early exit and use
    	getfpregs_supplies.
    	(mips_fbsd_store_inferior_registers): Likewise.

Diff:
---
 gdb/ChangeLog       |  8 ++++++++
 gdb/mips-fbsd-nat.c | 24 +++++++++++++-----------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 16f1f79..a271021 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-05-23  John Baldwin  <jhb@FreeBSD.org>
+
+	* mips-fbsd-nat.c (getregs_supplies): Fix upper bound comparison.
+	(getpfpregs_supplies): New function.
+	(mips_fbsd_fetch_inferior_registers): Remove early exit and use
+	getfpregs_supplies.
+	(mips_fbsd_store_inferior_registers): Likewise.
+
 2017-05-22  Pedro Alves <palves@redhat.com>
 
 	* MAINTAINERS (Host/Native): Add John Baldwin as FreeBSD
diff --git a/gdb/mips-fbsd-nat.c b/gdb/mips-fbsd-nat.c
index 078df52..53817d7 100644
--- a/gdb/mips-fbsd-nat.c
+++ b/gdb/mips-fbsd-nat.c
@@ -31,13 +31,22 @@
 #include "mips-fbsd-tdep.h"
 #include "inf-ptrace.h"
 
-/* Determine if PT_GETREGS fetches this register.  */
+/* Determine if PT_GETREGS fetches REGNUM.  */
 
 static bool
 getregs_supplies (struct gdbarch *gdbarch, int regnum)
 {
   return (regnum >= MIPS_ZERO_REGNUM
-	  && regnum <= gdbarch_pc_regnum (gdbarch));
+	  && regnum <= mips_regnum (gdbarch)->pc);
+}
+
+/* Determine if PT_GETFPREGS fetches REGNUM.  */
+
+static bool
+getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
+{
+  return (regnum >= mips_regnum (gdbarch)->fp0
+	  && regnum < mips_regnum (gdbarch)->fp_implementation_revision);
 }
 
 /* Fetch register REGNUM from the inferior.  If REGNUM is -1, do this
@@ -58,12 +67,9 @@ mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
 	perror_with_name (_("Couldn't get registers"));
 
       mips_fbsd_supply_gregs (regcache, regnum, &regs, sizeof (register_t));
-      if (regnum != -1)
-	return;
     }
 
-  if (regnum == -1
-      || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
+  if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
     {
       struct fpreg fpregs;
 
@@ -97,13 +103,9 @@ mips_fbsd_store_inferior_registers (struct target_ops *ops,
 
       if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
 	perror_with_name (_("Couldn't write registers"));
-
-      if (regnum != -1)
-	return;
     }
 
-  if (regnum == -1
-      || regnum >= gdbarch_fp0_regnum (get_regcache_arch (regcache)))
+  if (regnum == -1 || getfpregs_supplies (gdbarch, regnum))
     {
       struct fpreg fpregs;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]