This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH] Add i386-specific register set functions


These new functions will be used to support core-files using the newly
introduced register sets.

Committed,

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i386-tdep.h (struct gdbarch_tdep): Add members gregset,
	gregset_reg_offset, gregset_num_regs, sizeof_gregset, fpregset,
	sizeof_fpregset.
	* i386-tdep.c: Include "regset.h".
	(i386_supply_gregset): New function.
	(i386_supply_fpregset): New function.
	(i386_gdbarch_init): Initialze register set-related members of
	TDEP.
	* x86-64-tdep.c (x86_64_supply_fpregset): New function.
	(x86_64_init_abi): Initialize TDEP->sizeof_fpregset.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.169
diff -u -p -r1.169 i386-tdep.c
--- i386-tdep.c 27 Sep 2003 21:57:56 -0000 1.169
+++ i386-tdep.c 5 Oct 2003 21:28:12 -0000
@@ -37,6 +37,7 @@
 #include "osabi.h"
 #include "regcache.h"
 #include "reggroups.h"
+#include "regset.h"
 #include "symfile.h"
 #include "symtab.h"
 #include "target.h"
@@ -1548,7 +1549,42 @@ i386_value_to_register (struct frame_inf
     }
 }
 
+/* Supply register REGNUM from the general-purpose register set REGSET
+   to register cache REGCACHE.  If REGNUM is -1, do this for all
+   registers in REGSET.  */
 
+static void
+i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
+		     int regnum, const void *gregs, size_t len)
+{
+  const struct gdbarch_tdep *tdep = regset->descr;
+  const char *regs = gregs;
+  int i;
+
+  gdb_assert (len == tdep->sizeof_gregset);
+
+  for (i = 0; i < tdep->gregset_num_regs; i++)
+    {
+      if ((regnum == i || regnum == -1)
+	  && tdep->gregset_reg_offset[i] != -1)
+	regcache_raw_supply (regcache, i, regs + tdep->gregset_reg_offset[i]);
+    }
+}
+
+/* Supply register REGNUM from the floating-point register set REGSET
+   to register cache REGCACHE.  If REGNUM is -1, do this for all
+   registers in REGSET.  */
+
+static void
+i386_supply_fpregset (const struct regset *regset, struct regcache *regcache,
+		      int regnum, const void *fpregs, size_t len)
+{
+  const struct gdbarch_tdep *tdep = regset->descr;
+
+  gdb_assert (len == tdep->sizeof_fpregset);
+  i387_supply_fsave (regcache, regnum, fpregs);
+}
+
 
 #ifdef STATIC_TRANSFORM_NAME
 /* SunPRO encodes the static variables.  This is not related to C++
@@ -1802,6 +1838,16 @@ i386_gdbarch_init (struct gdbarch_info i
   /* Allocate space for the new architecture.  */
   tdep = XMALLOC (struct gdbarch_tdep);
   gdbarch = gdbarch_alloc (&info, tdep);
+
+  /* General-purpose registers.  */
+  tdep->gregset = NULL;
+  tdep->gregset_reg_offset = NULL;
+  tdep->gregset_num_regs = I386_NUM_GREGS;
+  tdep->sizeof_gregset = 0;
+
+  /* Floating-point registers.  */
+  tdep->fpregset = NULL;
+  tdep->sizeof_fpregset = I387_SIZEOF_FSAVE;
 
   /* The default settings include the FPU registers, the MMX registers
      and the SSE registers.  This can be overidden for a specific ABI
Index: i386-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.h,v
retrieving revision 1.26
diff -u -p -r1.26 i386-tdep.h
--- i386-tdep.h 27 Sep 2003 21:57:56 -0000 1.26
+++ i386-tdep.h 5 Oct 2003 21:28:12 -0000
@@ -56,6 +56,16 @@ enum struct_return
 /* i386 architecture specific information.  */
 struct gdbarch_tdep
 {
+  /* General-purpose registers.  */
+  struct regset *gregset;
+  int *gregset_reg_offset;
+  int gregset_num_regs;
+  size_t sizeof_gregset;
+
+  /* Floating-point registers.  */
+  struct regset *fpregset;
+  size_t sizeof_fpregset;
+
   /* Register number for %st(0).  The register numbers for the other
      registers follow from this one.  Set this to -1 to indicate the
      absence of an FPU.  */
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.95
diff -u -p -r1.95 x86-64-tdep.c
--- x86-64-tdep.c 2 Oct 2003 20:28:30 -0000 1.95
+++ x86-64-tdep.c 5 Oct 2003 21:28:13 -0000
@@ -1203,11 +1203,30 @@ x86_64_frame_align (struct gdbarch *gdba
 {
   return sp & -(CORE_ADDR)16;
 }
+
+
+/* Supply register REGNUM from the floating-point register set REGSET
+   to register cache REGCACHE.  If REGNUM is -1, do this for all
+   registers in REGSET.  */
+
+static void
+x86_64_supply_fpregset (const struct regset *regset, struct regcache *regcache,
+			int regnum, const void *fpregs, size_t len)
+{
+  const struct gdbarch_tdep *tdep = regset->descr;
+
+  gdb_assert (len == tdep->sizeof_fpregset);
+  x86_64_supply_fxsave (regcache, regnum, fpregs);
+}
 
 void
 x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  /* AMD64 generally uses `fxsave' instead of `fsave' for saving its
+     floating-point registers.  */
+  tdep->sizeof_fpregset = I387_SIZEOF_FXSAVE;
 
   /* AMD64 has an FPU and 16 SSE registers.  */
   tdep->st0_regnum = X86_64_ST0_REGNUM;


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