Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC/RFT] Use core regset iterators on Sparc Solaris
@ 2014-11-28 15:48 Ulrich Weigand
  2014-12-03  4:01 ` Joel Brobecker
  2014-12-03 13:23 ` Joel Brobecker
  0 siblings, 2 replies; 4+ messages in thread
From: Ulrich Weigand @ 2014-11-28 15:48 UTC (permalink / raw)
  To: gdb-patches; +Cc: davem

Hello,

Sparc/Solaris is another native target still does not use the new-style
iterate_over_regset_sections core file logic (allowing cross-debugging
of core files and core file generation).

Fortunately, it should be straightforward to enable to generic sparc logic
here by simply providing an appropriate register map.  In fact, the map
itself is already present, and can just be reused.  The only remaining
parameters needed are the total sizes of the register sections in core
files, which I've taken from public OpenSolaris sources.

The patch is untested so far since I don't have access to a Sparc/Solaris
system.  Testing by Solaris maintainers would be much appreciated.

Bye,
Ulrich

gdb/
	* config/sparc/sol2.mh (NATDEPFILES): Remove core-regset.o.
	* sparc-sol2-tdep.c: Include "regset.h".
	(sparc32_sol2_supply_core_gregset): New function.
	(sparc32_sol2_collect_core_gregset): Likewise.
	(sparc32_sol2_supply_core_fpregset): Likewise.
	(sparc32_sol2_collect_core_fpregset): Likewise.
	(sparc32_sol2_gregset, sparc32_sol2_fpregset): New variables.
	(sparc32_sol2_init_abi): Set tdep->gregset/sizeof_gregset and
	tdep->fpregset/sizeof_fpregset.
	* sparc64-sol2-tdep.c: Include "regset.h".
	(sparc64_sol2_supply_core_gregset): New function.
	(sparc64_sol2_collect_core_gregset): Likewise.
	(sparc64_sol2_supply_core_fpregset): Likewise.
	(sparc64_sol2_collect_core_fpregset): Likewise.
	(sparc64_sol2_gregset, sparc64_sol2_fpregset): New variables.
	(sparc64_sol2_init_abi): Set tdep->gregset/sizeof_gregset and
	tdep->fpregset/sizeof_fpregset.

Index: binutils-gdb/gdb/config/sparc/sol2.mh
===================================================================
--- binutils-gdb.orig/gdb/config/sparc/sol2.mh	2014-11-10 14:31:38.337160834 +0100
+++ binutils-gdb/gdb/config/sparc/sol2.mh	2014-11-28 15:18:43.966265980 +0100
@@ -1,6 +1,6 @@
 # Host: Solaris SPARC & UltraSPARC
 NAT_FILE= nm-sol2.h
 NATDEPFILES= sparc-sol2-nat.o \
-	core-regset.o fork-child.o \
+	fork-child.o \
 	procfs.o proc-api.o proc-events.o proc-flags.o proc-why.o
 HAVE_NATIVE_GCORE_HOST = 1
Index: binutils-gdb/gdb/sparc-sol2-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/sparc-sol2-tdep.c	2014-11-11 16:31:28.142902997 +0100
+++ binutils-gdb/gdb/sparc-sol2-tdep.c	2014-11-28 15:18:43.971266013 +0100
@@ -25,6 +25,7 @@
 #include "objfiles.h"
 #include "osabi.h"
 #include "regcache.h"
+#include "regset.h"
 #include "target.h"
 #include "trad-frame.h"
 
@@ -50,6 +51,52 @@ const struct sparc_fpregmap sparc32_sol2
   0 * 4,			/* %f0 */
   33 * 4,			/* %fsr */
 };
+
+static void
+sparc32_sol2_supply_core_gregset (const struct regset *regset,
+				  struct regcache *regcache,
+				  int regnum, const void *gregs, size_t len)
+{
+  sparc32_supply_gregset (&sparc32_sol2_gregmap, regcache, regnum, gregs);
+}
+
+static void
+sparc32_sol2_collect_core_gregset (const struct regset *regset,
+				   const struct regcache *regcache,
+				   int regnum, void *gregs, size_t len)
+{
+  sparc32_collect_gregset (&sparc32_sol2_gregmap, regcache, regnum, gregs);
+}
+
+static void
+sparc32_sol2_supply_core_fpregset (const struct regset *regset,
+				   struct regcache *regcache,
+				   int regnum, const void *fpregs, size_t len)
+{
+  sparc32_supply_fpregset (&sparc32_sol2_fpregmap, regcache, regnum, fpregs);
+}
+
+static void
+sparc32_sol2_collect_core_fpregset (const struct regset *regset,
+				    const struct regcache *regcache,
+				    int regnum, void *fpregs, size_t len)
+{
+  sparc32_collect_fpregset (&sparc32_sol2_fpregmap, regcache, regnum, fpregs);
+}
+
+static const struct regset sparc32_sol2_gregset =
+  {
+    NULL,
+    sparc32_sol2_supply_core_gregset,
+    sparc32_sol2_collect_core_gregset
+  };
+
+static const struct regset sparc32_sol2_fpregset =
+  {
+    NULL,
+    sparc32_sol2_supply_core_fpregset,
+    sparc32_sol2_collect_core_fpregset
+  };
 \f
 
 /* The Solaris signal trampolines reside in libc.  For normal signals,
@@ -211,6 +258,12 @@ sparc32_sol2_init_abi (struct gdbarch_in
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
+  tdep->gregset = &sparc32_sol2_gregset;
+  tdep->sizeof_gregset = 152;
+
+  tdep->fpregset = &sparc32_sol2_fpregset;
+  tdep->sizeof_fpregset = 400;
+
   /* The Sun compilers (Sun ONE Studio, Forte Developer, Sun WorkShop, SunPRO)
      compiler puts out 0 instead of the address in N_SO stabs.  Starting with
      SunPRO 3.0, the compiler does this for N_FUN stabs too.  */
Index: binutils-gdb/gdb/sparc64-sol2-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/sparc64-sol2-tdep.c	2014-11-11 16:31:28.163903116 +0100
+++ binutils-gdb/gdb/sparc64-sol2-tdep.c	2014-11-28 15:18:43.975266040 +0100
@@ -25,6 +25,7 @@
 #include "objfiles.h"
 #include "osabi.h"
 #include "trad-frame.h"
+#include "regset.h"
 
 #include "sol2-tdep.h"
 #include "sparc64-tdep.h"
@@ -49,6 +50,52 @@ const struct sparc_fpregmap sparc64_sol2
   0 * 8,			/* %f0 */
   33 * 8,			/* %fsr */
 };
+
+static void
+sparc64_sol2_supply_core_gregset (const struct regset *regset,
+				  struct regcache *regcache,
+				  int regnum, const void *gregs, size_t len)
+{
+  sparc64_supply_gregset (&sparc64_sol2_gregmap, regcache, regnum, gregs);
+}
+
+static void
+sparc64_sol2_collect_core_gregset (const struct regset *regset,
+				   const struct regcache *regcache,
+				   int regnum, void *gregs, size_t len)
+{
+  sparc64_collect_gregset (&sparc64_sol2_gregmap, regcache, regnum, gregs);
+}
+
+static void
+sparc64_sol2_supply_core_fpregset (const struct regset *regset,
+				   struct regcache *regcache,
+				   int regnum, const void *fpregs, size_t len)
+{
+  sparc64_supply_fpregset (&sparc64_sol2_fpregmap, regcache, regnum, fpregs);
+}
+
+static void
+sparc64_sol2_collect_core_fpregset (const struct regset *regset,
+				    const struct regcache *regcache,
+				    int regnum, void *fpregs, size_t len)
+{
+  sparc64_collect_fpregset (&sparc64_sol2_fpregmap, regcache, regnum, fpregs);
+}
+
+static const struct regset sparc64_sol2_gregset =
+  {
+    NULL,
+    sparc64_sol2_supply_core_gregset,
+    sparc64_sol2_collect_core_gregset
+  };
+
+static const struct regset sparc64_sol2_fpregset =
+  {
+    NULL,
+    sparc64_sol2_supply_core_fpregset,
+    sparc64_sol2_collect_core_fpregset
+  };
 \f
 
 static struct sparc_frame_cache *
@@ -159,6 +206,12 @@ sparc64_sol2_init_abi (struct gdbarch_in
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
+  tdep->gregset = &sparc64_sol2_gregset;
+  tdep->sizeof_gregset = 304;
+
+  tdep->fpregset = &sparc64_sol2_fpregset;
+  tdep->sizeof_fpregset = 544;
+
   frame_unwind_append_unwinder (gdbarch, &sparc64_sol2_sigtramp_frame_unwind);
 
   sparc64_init_abi (info, gdbarch);
-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


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

end of thread, other threads:[~2014-12-03 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-28 15:48 [RFC/RFT] Use core regset iterators on Sparc Solaris Ulrich Weigand
2014-12-03  4:01 ` Joel Brobecker
2014-12-03 13:23 ` Joel Brobecker
2014-12-03 14:42   ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox