Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][SH] Implement core-file support for sh-linux
@ 2009-10-12 14:26 Andrew Stubbs
  2009-10-14  4:56 ` Joel Brobecker
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Stubbs @ 2009-10-12 14:26 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

This patch adds support for debugging core-files on SH Linux targets.

I've added code to read both the general-purpose registers, and the 
floating point registers from core files. This code is adapted from the 
SH NBSD files.

OK?

Andrew

[-- Attachment #2: corefiles.patch --]
[-- Type: text/x-diff, Size: 8616 bytes --]

2009-10-12  Andrew Stubbs  <ams@codesourcery.com>

	* configure.tgt (sh*-*-linux*): Add corelow.o to gdb_target_obs.
	* sh-linux-tdep.c: Include gdb_assert.h, gdb_string.h, regcache.h,
	regset.h and sh-tdep.h.
	(struct sh_linux_pt_regs, struct sh_linux_user_fpu_struct): New types.
	(sh_linux_supply_gregset, sh_linux_collect_gregset): New functions.
	(sh_linux_supply_fpregset, sh_linux_collect_fpregset): New functions.
	(sh_linux_gregset, sh_linux_fpregset): New variables.
	(sh_linux_regset_from_core_section): New function.
	(sh_linux_init_abi): Call set_gdbarch_regset_from_core_section.

---
 src/gdb-mainline/gdb/configure.tgt   |    3 
 src/gdb-mainline/gdb/sh-linux-tdep.c |  208 ++++++++++++++++++++++++++++++++++
 2 files changed, 210 insertions(+), 1 deletions(-)


diff --git a/src/gdb-mainline/gdb/configure.tgt b/src/gdb-mainline/gdb/configure.tgt
index 20b739e..0d3074a 100644
--- a/src/gdb-mainline/gdb/configure.tgt
+++ b/src/gdb-mainline/gdb/configure.tgt
@@ -407,7 +407,8 @@ score-*-*)
 sh*-*-linux*)
 	# Target: GNU/Linux Super-H
 	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-linux-tdep.o monitor.o \
-			dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o"
+			dsrec.o solib.o solib-svr4.o symfile-mem.o \
+			glibc-tdep.o corelow.o"
 	gdb_sim=../sim/sh/libsim.a
 	build_gdbserver=yes
 	;;
diff --git a/src/gdb-mainline/gdb/sh-linux-tdep.c b/src/gdb-mainline/gdb/sh-linux-tdep.c
index 46aad1d..27db8ff 100644
--- a/src/gdb-mainline/gdb/sh-linux-tdep.c
+++ b/src/gdb-mainline/gdb/sh-linux-tdep.c
@@ -20,10 +20,213 @@
 #include "defs.h"
 #include "osabi.h"
 
+#include "gdb_assert.h"
+#include "gdb_string.h"
+
 #include "solib-svr4.h"
 #include "symtab.h"
+#include "regcache.h"
+#include "regset.h"
 
 #include "glibc-tdep.h"
+#include "sh-tdep.h"
+
+/* Copied from asm/ptrace.h, and made 64-bit safe:
+   This struct defines the way the registers are stored on the
+   kernel stack during a system call or other kernel entry.  */
+struct sh_linux_pt_regs
+  {
+    uint32_t regs[16];
+    uint32_t pc;
+    uint32_t pr;
+    uint32_t sr;
+    uint32_t gbr;
+    uint32_t mach;
+    uint32_t macl;
+    int32_t tra;
+  };
+
+/* Copied from sys/user.h, and made 64-bit safe.  */
+struct sh_linux_user_fpu_struct
+  {
+    uint32_t fp_regs[16];
+    uint32_t xfp_regs[16];
+    uint32_t fpscr;
+    uint32_t fpul;
+  };
+
+/* Supply register REGNUM from the buffer specified by GREGS and LEN
+   in the general-purpose register set REGSET to register cache
+   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_linux_supply_gregset (const struct regset *regset,
+		       struct regcache *regcache,
+		       int regnum, const void *gregs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  const struct sh_linux_pt_regs *regs = gregs;
+  int i;
+
+  gdb_assert (len >= sizeof (struct sh_linux_pt_regs));
+
+  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
+    regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
+			 &regs->pc);
+
+  if (regnum == SR_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, SR_REGNUM, &regs->sr);
+
+  if (regnum == PR_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, PR_REGNUM, &regs->pr);
+
+  if (regnum == GBR_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, PR_REGNUM, &regs->gbr);
+
+  if (regnum == MACH_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, MACH_REGNUM, &regs->mach);
+
+  if (regnum == MACL_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, MACL_REGNUM, &regs->macl);
+
+  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
+    {
+      if (regnum == i || regnum == -1)
+	regcache_raw_supply (regcache, i, &regs->regs[i - R0_REGNUM]);
+    }
+}
+
+/* Collect register REGNUM in the general-purpose register set
+   REGSET. from register cache REGCACHE into the buffer specified by
+   GREGS and LEN.  If REGNUM is -1, do this for all registers in
+   REGSET.  */
+
+static void
+sh_linux_collect_gregset (const struct regset *regset,
+			const struct regcache *regcache,
+			int regnum, void *gregs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct sh_linux_pt_regs *regs = gregs;
+  int i;
+
+  gdb_assert (len >= sizeof (struct sh_linux_pt_regs));
+
+  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
+    regcache_raw_collect (regcache, gdbarch_pc_regnum (gdbarch),
+			  &regs->pc);
+
+  if (regnum == SR_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, SR_REGNUM, &regs->sr);
+
+  if (regnum == PR_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, PR_REGNUM, &regs->pr);
+
+  if (regnum == GBR_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, GBR_REGNUM, &regs->gbr);
+
+  if (regnum == MACH_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, MACH_REGNUM, &regs->mach);
+
+  if (regnum == MACL_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, MACL_REGNUM, &regs->macl);
+
+  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
+    {
+      if (regnum == i || regnum == -1)
+	regcache_raw_collect (regcache, i, &regs->regs[i - R0_REGNUM]);
+    }
+}
+
+/* Supply register REGNUM from the buffer specified by FPREGS and LEN
+   in the floating point register set REGSET to register cache
+   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_linux_supply_fpregset (const struct regset *regset,
+			  struct regcache *regcache,
+			  int regnum, const void *fpregs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  const struct sh_linux_user_fpu_struct *regs = fpregs;
+  int fp0_regnum = gdbarch_fp0_regnum (gdbarch);
+  int i;
+
+  gdb_assert (len >= sizeof (struct sh_linux_user_fpu_struct));
+
+  if (regnum == FPSCR_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, FPSCR_REGNUM, &regs->fpscr);
+
+  if (regnum == FPUL_REGNUM || regnum == -1)
+    regcache_raw_supply (regcache, FPUL_REGNUM, &regs->fpul);
+
+  if (fp0_regnum >= 0)
+    for (i = fp0_regnum; i <= (fp0_regnum + 15); i++)
+      if (regnum == i || regnum == -1)
+	regcache_raw_supply (regcache, i, &regs->fp_regs[i - fp0_regnum]);
+}
+
+/* Collect register REGNUM in the floating point register set
+   REGSET. from register cache REGCACHE into the buffer specified by
+   FPREGS and LEN.  If REGNUM is -1, do this for all registers in
+   REGSET.  */
+
+static void
+sh_linux_collect_fpregset (const struct regset *regset,
+			   const struct regcache *regcache,
+			   int regnum, void *fpregs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct sh_linux_user_fpu_struct *regs = fpregs;
+  int fp0_regnum = gdbarch_fp0_regnum (gdbarch);
+  int i;
+
+  gdb_assert (len >= sizeof (struct sh_linux_user_fpu_struct));
+
+  if (regnum == FPSCR_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, FPSCR_REGNUM, &regs->fpscr);
+
+  if (regnum == FPUL_REGNUM || regnum == -1)
+    regcache_raw_collect (regcache, FPUL_REGNUM, &regs->fpul);
+
+  if (fp0_regnum >= 0)
+    for (i = fp0_regnum; i <= (fp0_regnum + 15); i++)
+      if (regnum == i || regnum == -1)
+	regcache_raw_collect (regcache, i, &regs->fp_regs[i - fp0_regnum]);
+}
+
+/* SH register sets.  */
+
+static struct regset sh_linux_gregset =
+{
+  NULL,
+  sh_linux_supply_gregset,
+  sh_linux_collect_gregset
+};
+
+static struct regset sh_linux_fpregset =
+{
+  NULL,
+  sh_linux_supply_fpregset,
+  sh_linux_collect_fpregset
+};
+
+/* Return the appropriate register set for the core section identified
+   by SECT_NAME and SECT_SIZE.  */
+
+static const struct regset *
+sh_linux_regset_from_core_section (struct gdbarch *gdbarch,
+				   const char *sect_name, size_t sect_size)
+{
+  if (strcmp (sect_name, ".reg") == 0
+      && sect_size >= sizeof (struct sh_linux_pt_regs))
+    return &sh_linux_gregset;
+  else if (strcmp (sect_name, ".reg2") == 0
+	   && sect_size >= sizeof (struct sh_linux_user_fpu_struct))
+    return &sh_linux_fpregset;
+
+  return NULL;
+}
 
 static void
 sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -36,6 +239,11 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Core files are supported for 32-bit SH only, at present.  */
+  if (info.bfd_arch_info->mach != bfd_mach_sh5)
+    set_gdbarch_regset_from_core_section
+      (gdbarch, sh_linux_regset_from_core_section);
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */

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

* Re: [PATCH][SH] Implement core-file support for sh-linux
  2009-10-12 14:26 [PATCH][SH] Implement core-file support for sh-linux Andrew Stubbs
@ 2009-10-14  4:56 ` Joel Brobecker
  2009-10-15 13:27   ` Andrew Stubbs
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2009-10-14  4:56 UTC (permalink / raw)
  To: Andrew Stubbs; +Cc: gdb-patches

> 2009-10-12  Andrew Stubbs  <ams@codesourcery.com>
> 
> 	* configure.tgt (sh*-*-linux*): Add corelow.o to gdb_target_obs.
> 	* sh-linux-tdep.c: Include gdb_assert.h, gdb_string.h, regcache.h,
> 	regset.h and sh-tdep.h.
> 	(struct sh_linux_pt_regs, struct sh_linux_user_fpu_struct): New types.
> 	(sh_linux_supply_gregset, sh_linux_collect_gregset): New functions.
> 	(sh_linux_supply_fpregset, sh_linux_collect_fpregset): New functions.
> 	(sh_linux_gregset, sh_linux_fpregset): New variables.
> 	(sh_linux_regset_from_core_section): New function.
> 	(sh_linux_init_abi): Call set_gdbarch_regset_from_core_section.

It seems a shame that this code is almost a complete duplication of
the code in shnbsd.  I think we can avoid that simply by having an
array in the SH tdep structure that provides the offsets to the various
registers, indexed by register number.

Then the code from shnbsd can be moved to sh-tdep.c and the only
remaining bit is to initialize the array appropriately in shbnsd-tdep
and sh-linux-tdep.

-- 
Joel


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

* Re: [PATCH][SH] Implement core-file support for sh-linux
  2009-10-14  4:56 ` Joel Brobecker
@ 2009-10-15 13:27   ` Andrew Stubbs
  2009-10-15 16:20     ` Joel Brobecker
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Stubbs @ 2009-10-15 13:27 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 404 bytes --]

On 14/10/09 05:55, Joel Brobecker wrote:
> Then the code from shnbsd can be moved to sh-tdep.c and the only
> remaining bit is to initialize the array appropriately in shbnsd-tdep
> and sh-linux-tdep.

I believe this patch should do what you suggest.

I've tested the Linux support, but unfortunately I have now way to test 
the NBSD support. I have checked that it builds, but that is all.

OK?

Andrew

[-- Attachment #2: corefiles.patch --]
[-- Type: text/x-diff, Size: 13773 bytes --]

2009-10-15  Andrew Stubbs  <ams@codesourcery.com>

	* configure.tgt (sh*-*-linux*): Add corelow.o to gdb_target_obs.
	* sh-linux-tdep.c: Include gdb_string.h, regset.h and sh-tdep.h.
	(REGSx16): New macro.
	(gregs_table, fpregs_table): New variables.
	(sh_linux_regset_from_core_section): New function.
	(sh_linux_init_abi): Call set_gdbarch_regset_from_core_section.
	* sh-tdep.c: Include regset.h.
	(sh_corefile_supply_regset): New function.
	(sh_corefile_collect_regset): New function.
	(sh_corefile_gregset, sh_corefile_fpregset): New variables.
	(sh_init_corefile_regset): New function.
	* sh-tdep.h (PC_REGNUM): New enum value.
	(struct sh_corefile_regs): New type.
	(sh_init_corefile_regset): New prototype.
	* shnbsd-tdep.c: Remove include of regcache.h.
	(regmap): Use new definition using struct sh_corefile_regs.
	(shnbsd_supply_gregset, shnbsd_collect_gregset): Delete.
	(shnbsd_gregset): Delete.
	(current_regset): New variable.
	(shnbsd_regset_from_core_section): Use sh_init_corefile_regset.
	(shnbsd_supply_reg, shnbsd_fill_reg): Use new regset interface.

---
 src/gdb-mainline/gdb/configure.tgt   |    3 -
 src/gdb-mainline/gdb/sh-linux-tdep.c |   67 +++++++++++++++
 src/gdb-mainline/gdb/sh-tdep.c       |   79 ++++++++++++++++++
 src/gdb-mainline/gdb/sh-tdep.h       |   12 +++
 src/gdb-mainline/gdb/shnbsd-tdep.c   |  148 +++++++++-------------------------
 5 files changed, 199 insertions(+), 110 deletions(-)


diff --git a/src/gdb-mainline/gdb/configure.tgt b/src/gdb-mainline/gdb/configure.tgt
index 20b739e..0d3074a 100644
--- a/src/gdb-mainline/gdb/configure.tgt
+++ b/src/gdb-mainline/gdb/configure.tgt
@@ -407,7 +407,8 @@ score-*-*)
 sh*-*-linux*)
 	# Target: GNU/Linux Super-H
 	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-linux-tdep.o monitor.o \
-			dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o"
+			dsrec.o solib.o solib-svr4.o symfile-mem.o \
+			glibc-tdep.o corelow.o"
 	gdb_sim=../sim/sh/libsim.a
 	build_gdbserver=yes
 	;;
diff --git a/src/gdb-mainline/gdb/sh-linux-tdep.c b/src/gdb-mainline/gdb/sh-linux-tdep.c
index 46aad1d..cda968f 100644
--- a/src/gdb-mainline/gdb/sh-linux-tdep.c
+++ b/src/gdb-mainline/gdb/sh-linux-tdep.c
@@ -20,10 +20,72 @@
 #include "defs.h"
 #include "osabi.h"
 
+#include "gdb_string.h"
+
 #include "solib-svr4.h"
 #include "symtab.h"
+#include "regset.h"
 
 #include "glibc-tdep.h"
+#include "sh-tdep.h"
+
+#define REGSx16(base) \
+  {(base), 0, 4}, \
+  {(base) + 1, 4, 4}, \
+  {(base) + 2, 8, 4}, \
+  {(base) + 3, 12, 4}, \
+  {(base) + 4, 16, 4}, \
+  {(base) + 5, 20, 4}, \
+  {(base) + 6, 24, 4}, \
+  {(base) + 7, 28, 4}, \
+  {(base) + 8, 32, 4}, \
+  {(base) + 9, 36, 4}, \
+  {(base) + 10, 40, 4}, \
+  {(base) + 11, 44, 4}, \
+  {(base) + 12, 48, 4}, \
+  {(base) + 13, 52, 4}, \
+  {(base) + 14, 56, 4}, \
+  {(base) + 15, 60, 4}
+
+/* Describe the contents of the .reg section of the core file.  */
+
+static const struct sh_corefile_regs gregs_table[] =
+{
+  REGSx16 (R0_REGNUM),
+  {PC_REGNUM,   64, 4},
+  {PR_REGNUM,   68, 4},
+  {SR_REGNUM,   72, 4},
+  {GBR_REGNUM,  76, 4},
+  {MACH_REGNUM, 80, 4},
+  {MACL_REGNUM, 84, 4},
+  {-1 /* Terminator.  */, 0, 0}
+};
+
+/* Describe the contents of the .reg2 section of the core file.  */
+
+static const struct sh_corefile_regs fpregs_table[] =
+{
+  REGSx16 (FR0_REGNUM),
+  /* REGSx16 xfp_regs omitted.  */
+  {FPSCR_REGNUM, 128, 4},
+  {FPUL_REGNUM,  132, 4},
+  {-1 /* Terminator.  */, 0, 0}
+};
+
+/* Return the appropriate register set for the core section identified
+   by SECT_NAME and SECT_SIZE.  */
+
+static const struct regset *
+sh_linux_regset_from_core_section (struct gdbarch *core_gdbarch,
+				   const char *sect_name, size_t sect_size)
+{
+  if (strcmp (sect_name, ".reg") == 0)
+    return sh_init_corefile_regset (gregs_table, 0);
+  else if (strcmp (sect_name, ".reg2") == 0)
+    return sh_init_corefile_regset (fpregs_table, 1);
+
+  return NULL;
+}
 
 static void
 sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -36,6 +98,11 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Core files are supported for 32-bit SH only, at present.  */
+  if (info.bfd_arch_info->mach != bfd_mach_sh5)
+    set_gdbarch_regset_from_core_section
+      (gdbarch, sh_linux_regset_from_core_section);
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
diff --git a/src/gdb-mainline/gdb/sh-tdep.c b/src/gdb-mainline/gdb/sh-tdep.c
index 3e509bf..9f4a9dc 100644
--- a/src/gdb-mainline/gdb/sh-tdep.c
+++ b/src/gdb-mainline/gdb/sh-tdep.c
@@ -43,6 +43,7 @@
 #include "doublest.h"
 #include "osabi.h"
 #include "reggroups.h"
+#include "regset.h"
 
 #include "sh-tdep.h"
 
@@ -2738,6 +2739,84 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
     }
   return 0;
 }
+
+
+/* Supply register REGNUM from the buffer specified by REGS and LEN
+   in the register set REGSET to register cache REGCACHE.
+   REGTABLE specifies where each register can be found in REGS.
+   If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_corefile_supply_regset (const struct regset *regset,
+			   struct regcache *regcache,
+			   int regnum, const void *regs, size_t len)
+{
+  const struct sh_corefile_regs *regtable = regset->descr;
+  int i;
+
+  for (i = 0; regtable[i].regnum != -1; i++)
+    {
+      if ((regnum == -1 || regnum == regtable[i].regnum)
+	  && regtable[i].offset + regtable[i].size <= len)
+	regcache_raw_supply (regcache, regtable[i].regnum,
+			     (char *)regs + regtable[i].offset);
+    }
+}
+
+/* Collect register REGNUM in the register set REGSET from register cache
+   REGCACHE into the buffer specified by REGS and LEN.
+   REGTABLE specifies where each register can be found in REGS.
+   If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_corefile_collect_regset (const struct regset *regset,
+			    const struct regcache *regcache,
+			    int regnum, void *regs, size_t len)
+{
+  const struct sh_corefile_regs *regtable = regset->descr;
+  int i;
+
+  for (i = 0; regtable[i].regnum != -1; i++)
+    {
+      if ((regnum == -1 || regnum == regtable[i].regnum)
+	  && regtable[i].offset + regtable[i].size <= len)
+	regcache_raw_collect (regcache, regtable[i].regnum,
+			      (char *)regs + regtable[i].offset);
+    }
+}
+
+static struct regset sh_corefile_gregset =
+{
+  NULL,  /* Filled in later.  */
+  sh_corefile_supply_regset,
+  sh_corefile_collect_regset
+};
+
+static struct regset sh_corefile_fpregset =
+{
+  NULL,  /* Filled in later.  */
+  sh_corefile_supply_regset,
+  sh_corefile_collect_regset
+};
+
+
+/* Initialize reading registers from core files.
+   This is called from OS specific tdep files.  */
+
+struct regset *
+sh_init_corefile_regset (const struct sh_corefile_regs regs[], int fp)
+{
+  if (!fp)
+    {
+      sh_corefile_gregset.descr = regs;
+      return &sh_corefile_gregset;
+    }
+  else
+    {
+      sh_corefile_fpregset.descr = regs;
+      return &sh_corefile_fpregset;
+    }
+}
 \f
 
 static struct gdbarch *
diff --git a/src/gdb-mainline/gdb/sh-tdep.h b/src/gdb-mainline/gdb/sh-tdep.h
index dfa928e..ecec578 100644
--- a/src/gdb-mainline/gdb/sh-tdep.h
+++ b/src/gdb-mainline/gdb/sh-tdep.h
@@ -30,6 +30,7 @@ enum
     ARG0_REGNUM = 4,
     ARGLAST_REGNUM = 7,
     FP_REGNUM = 14,
+    PC_REGNUM = 16,
     PR_REGNUM = 17,
     GBR_REGNUM = 18,
     VBR_REGNUM = 19,
@@ -85,4 +86,15 @@ enum
 extern gdbarch_init_ftype sh64_gdbarch_init;
 extern void sh64_show_regs (struct frame_info *);
 
+/* This structure describes a register in a core-file.  */
+struct sh_corefile_regs
+  {
+    int regnum;
+    unsigned int offset;
+    unsigned int size;
+  };
+
+extern struct regset *sh_init_corefile_regset
+        (const struct sh_corefile_regs regs[], int fp);
+
 #endif /* SH_TDEP_H */
diff --git a/src/gdb-mainline/gdb/shnbsd-tdep.c b/src/gdb-mainline/gdb/shnbsd-tdep.c
index a0cddc5..5d1fc4c 100644
--- a/src/gdb-mainline/gdb/shnbsd-tdep.c
+++ b/src/gdb-mainline/gdb/shnbsd-tdep.c
@@ -22,7 +22,6 @@
 
 #include "defs.h"
 #include "gdbcore.h"
-#include "regcache.h"
 #include "regset.h"
 #include "value.h"
 #include "osabi.h"
@@ -34,116 +33,39 @@
 #include "shnbsd-tdep.h"
 #include "solib-svr4.h"
 
-/* Convert an r0-r15 register number into an offset into a ptrace
+/* Convert a register number into an offset into a ptrace
    register structure.  */
-static const int regmap[] =
+static const struct sh_corefile_regs regmap[] =
 {
-  (20 * 4),	/* r0 */
-  (19 * 4),	/* r1 */
-  (18 * 4),	/* r2 */ 
-  (17 * 4),	/* r3 */ 
-  (16 * 4),	/* r4 */
-  (15 * 4),	/* r5 */
-  (14 * 4),	/* r6 */
-  (13 * 4),	/* r7 */
-  (12 * 4),	/* r8 */ 
-  (11 * 4),	/* r9 */
-  (10 * 4),	/* r10 */
-  ( 9 * 4),	/* r11 */
-  ( 8 * 4),	/* r12 */
-  ( 7 * 4),	/* r13 */
-  ( 6 * 4),	/* r14 */
-  ( 5 * 4),	/* r15 */
+  {R0_REGNUM,      20 * 4, 4},
+  {R0_REGNUM + 1,  19 * 4, 4},
+  {R0_REGNUM + 2,  18 * 4, 4},
+  {R0_REGNUM + 3,  17 * 4, 4},
+  {R0_REGNUM + 4,  16 * 4, 4},
+  {R0_REGNUM + 5,  15 * 4, 4},
+  {R0_REGNUM + 6,  14 * 4, 4},
+  {R0_REGNUM + 7,  13 * 4, 4},
+  {R0_REGNUM + 8,  12 * 4, 4},
+  {R0_REGNUM + 9,  11 * 4, 4},
+  {R0_REGNUM + 10, 10 * 4, 4},
+  {R0_REGNUM + 11,  9 * 4, 4},
+  {R0_REGNUM + 12,  8 * 4, 4},
+  {R0_REGNUM + 13,  7 * 4, 4},
+  {R0_REGNUM + 14,  6 * 4, 4},
+  {R0_REGNUM + 15,  5 * 4, 4},
+  {PC_REGNUM,       0 * 4, 4},
+  {SR_REGNUM,       1 * 4, 4},
+  {PR_REGNUM,	    2 * 4, 4},
+  {MACH_REGNUM,	    3 * 4, 4},
+  {MACL_REGNUM,	    4 * 4, 4},
+  {-1 /* Terminator.  */, 0, 0}
 };
 
 /* Sizeof `struct reg' in <machine/reg.h>.  */
 #define SHNBSD_SIZEOF_GREGS	(21 * 4)
 
-/* Supply register REGNUM from the buffer specified by GREGS and LEN
-   in the general-purpose register set REGSET to register cache
-   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
-
-static void
-shnbsd_supply_gregset (const struct regset *regset,
-		       struct regcache *regcache,
-		       int regnum, const void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  const gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
-			 regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_supply (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* Collect register REGNUM in the general-purpose register set
-   REGSET. from register cache REGCACHE into the buffer specified by
-   GREGS and LEN.  If REGNUM is -1, do this for all registers in
-   REGSET.  */
-
-static void
-shnbsd_collect_gregset (const struct regset *regset,
-			const struct regcache *regcache,
-			int regnum, void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_collect (regcache, gdbarch_pc_regnum (gdbarch),
-			  regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_collect (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* SH register sets.  */
-
-static struct regset shnbsd_gregset =
-{
-  NULL,
-  shnbsd_supply_gregset,
-  shnbsd_collect_gregset
-};
+/* Local copy of the regset returned by sh_init_corefile_regset.  */
+static struct regset *current_regset = NULL;
 
 /* Return the appropriate register set for the core section identified
    by SECT_NAME and SECT_SIZE.  */
@@ -153,23 +75,31 @@ shnbsd_regset_from_core_section (struct gdbarch *gdbarch,
 				 const char *sect_name, size_t sect_size)
 {
   if (strcmp (sect_name, ".reg") == 0 && sect_size >= SHNBSD_SIZEOF_GREGS)
-    return &shnbsd_gregset;
+    {
+      current_regset = sh_init_corefile_regset (regmap, 0);
+      return current_regset;
+    }
 
+  current_regset = NULL;
   return NULL;
 }
 
 void
 shnbsd_supply_reg (struct regcache *regcache, const char *regs, int regnum)
 {
-  shnbsd_supply_gregset (&shnbsd_gregset, regcache, regnum,
-			 regs, SHNBSD_SIZEOF_GREGS);
+  gdb_assert (current_regset != NULL);
+
+  current_regset->supply_regset (current_regset, regcache, regnum,
+				 regs, SHNBSD_SIZEOF_GREGS);
 }
 
 void
 shnbsd_fill_reg (const struct regcache *regcache, char *regs, int regnum)
 {
-  shnbsd_collect_gregset (&shnbsd_gregset, regcache, regnum,
-			  regs, SHNBSD_SIZEOF_GREGS);
+  gdb_assert (current_regset != NULL);
+
+  current_regset->collect_regset (current_regset, regcache, regnum,
+				  regs, SHNBSD_SIZEOF_GREGS);
 }
 \f
 

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

* Re: [PATCH][SH] Implement core-file support for sh-linux
  2009-10-15 13:27   ` Andrew Stubbs
@ 2009-10-15 16:20     ` Joel Brobecker
  2009-10-19 17:27       ` Andrew Stubbs
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2009-10-15 16:20 UTC (permalink / raw)
  To: Andrew Stubbs; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]

>> Then the code from shnbsd can be moved to sh-tdep.c and the only
>> remaining bit is to initialize the array appropriately in shbnsd-tdep
>> and sh-linux-tdep.
>
> I believe this patch should do what you suggest.

You definitely got the idea, but the implementation does not work
in the case of multi-arch debugging.  This is because you are
introducing a global variable.  The solution is to rely on the
gdbarch_tdep structure.  Here is a patch that should provide you
with a quick sketch of how you can implement this:
  - I created a gdbarch_tdep structure for SH, since it didn't need one
    before; I populated it with a simple regmap being an array of
    integers, but it appears that this may not be sufficient, since
    registers might not be stored in the same order as GDB register
    numbers.  So your slightly more complex structure might be required
  - Move the core-file support from shnbsd-tdep to sh-tdep, did some
    renaming - hopefully I didn't miss much
  - Initialized support for core-file in sh-tdep knowing that the
    routine that checks core file section names will only return
    non-NULL if such support is available (detected by looking at
    the gdbarch_tdep structure).

Hopefully, once this is in place, the only thing you should have left
to do is to create the offset maps in sh-linux-tdep and set the tdep
maps during the sh/linux gdbarch initialization.

Does this make sense to you?

-- 
Joel

[-- Attachment #2: sh-core.diff --]
[-- Type: text/x-diff, Size: 9363 bytes --]

diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c
index 46aad1d..5eba796 100644
--- a/gdb/sh-linux-tdep.c
+++ b/gdb/sh-linux-tdep.c
@@ -28,6 +28,8 @@
 static void
 sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
   /* GNU/Linux uses SVR4-style shared libraries.  */
   set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
   set_solib_svr4_fetch_link_map_offsets
@@ -36,6 +38,12 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Core files are supported for 32-bit SH only, at present.  */
+  if (info.bfd_arch_info->mach != bfd_mach_sh5)
+    {
+      /* set tdep->core_regmap and tdep->core_fpregmap here.  */
+    }
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 3e509bf..5d8d5a3 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -2740,6 +2740,102 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 }
 \f
 
+/* Supply register REGNUM from the buffer specified by GREGS and LEN
+   in the general-purpose register set REGSET to register cache
+   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_supply_gregset (const struct regset *regset, struct regcache *regcache,
+		   int regnum, const void *gregs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  /* Use the tdep data to fill in the regset.  */
+}
+
+/* Collect register REGNUM in the general-purpose register set
+   REGSET. from register cache REGCACHE into the buffer specified by
+   GREGS and LEN.  If REGNUM is -1, do this for all registers in
+   REGSET.  */
+
+static void
+sh_collect_gregset (const struct regset *regset,
+		    const struct regcache *regcache,
+		    int regnum, void *gregs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Use the tdep data to fill in the regset.  */
+}
+
+/* SH register sets.  */
+
+static struct regset sh_gregset =
+{
+  NULL,
+  sh_supply_gregset,
+  sh_collect_gregset
+};
+
+/* Supply register REGNUM from the buffer specified by FPREGS and LEN
+   in the floating point register set REGSET to register cache
+   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_supply_fpregset (const struct regset *regset, struct regcache *regcache,
+		    int regnum, const void *fpregs, size_t len)
+{
+  /* Same as above.  */
+}
+
+/* Collect register REGNUM in the floating point register set
+   REGSET. from register cache REGCACHE into the buffer specified by
+   FPREGS and LEN.  If REGNUM is -1, do this for all registers in
+   REGSET.  */
+
+static void
+sh_collect_fpregset (const struct regset *regset,
+		     const struct regcache *regcache,
+		     int regnum, void *fpregs, size_t len)
+{
+  /* Same as above.  */
+}
+
+/* SH register sets.  */
+
+static struct regset sh_fpregset =
+{
+  NULL,
+  sh_supply_fpregset,
+  sh_collect_fpregset
+};
+
+/* Return the appropriate register set for the core section identified
+   by SECT_NAME and SECT_SIZE.  */
+
+static const struct regset *
+sh_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name,
+			     size_t sect_size)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (tdep->core_regmap == NULL)
+    return NULL;  /* core files not supported on this architecture.  */
+
+  if (strcmp (sect_name, ".reg") == 0 && sect_size >= SH_SIZEOF_GREGS)
+    return &sh_gregset;
+
+  if (tdep->core_fp_regmap
+      && strcmp (sect_name, ".reg2") == 0
+      && sect_size >= SH_SIZEOF_FP_GREGS)
+    return &sh_fpregset;
+
+  return NULL;
+}
+
 static struct gdbarch *
 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
@@ -2803,7 +2899,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided. */
-  gdbarch = gdbarch_alloc (&info, NULL);
+  tdep = XZALLOC (struct gdbarch_tdep);
+  gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
@@ -2847,6 +2944,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   dwarf2_frame_set_init_reg (gdbarch, sh_dwarf2_frame_init_reg);
 
+  set_gdbarch_regset_from_core_section (gdbarch, sh_regset_from_core_section);
+
   switch (info.bfd_arch_info->mach)
     {
     case bfd_mach_sh:
diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h
index dfa928e..37a8f8c 100644
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -82,6 +82,18 @@ enum
     FV_LAST_REGNUM = 79
   };
 
+struct gdbarch_tdep
+{
+  /* Non-NULL when debugging from a core file.  Provides the offset
+     where each general-purpose register is stored inside the associated
+     core file section.  */
+  int *core_regmap;
+  /* Non-NULL when debugging from a core file and when FP registers are
+     available.  Provides the offset where each FP register is stored
+     inside the associated core file section.  */
+  int *core_fp_regmap;
+};
+
 extern gdbarch_init_ftype sh64_gdbarch_init;
 extern void sh64_show_regs (struct frame_info *);
 
diff --git a/gdb/shnbsd-tdep.c b/gdb/shnbsd-tdep.c
index a0cddc5..633770d 100644
--- a/gdb/shnbsd-tdep.c
+++ b/gdb/shnbsd-tdep.c
@@ -59,105 +59,6 @@ static const int regmap[] =
 /* Sizeof `struct reg' in <machine/reg.h>.  */
 #define SHNBSD_SIZEOF_GREGS	(21 * 4)
 
-/* Supply register REGNUM from the buffer specified by GREGS and LEN
-   in the general-purpose register set REGSET to register cache
-   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
-
-static void
-shnbsd_supply_gregset (const struct regset *regset,
-		       struct regcache *regcache,
-		       int regnum, const void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  const gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
-			 regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_supply (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* Collect register REGNUM in the general-purpose register set
-   REGSET. from register cache REGCACHE into the buffer specified by
-   GREGS and LEN.  If REGNUM is -1, do this for all registers in
-   REGSET.  */
-
-static void
-shnbsd_collect_gregset (const struct regset *regset,
-			const struct regcache *regcache,
-			int regnum, void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_collect (regcache, gdbarch_pc_regnum (gdbarch),
-			  regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_collect (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* SH register sets.  */
-
-static struct regset shnbsd_gregset =
-{
-  NULL,
-  shnbsd_supply_gregset,
-  shnbsd_collect_gregset
-};
-
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
-
-static const struct regset *
-shnbsd_regset_from_core_section (struct gdbarch *gdbarch,
-				 const char *sect_name, size_t sect_size)
-{
-  if (strcmp (sect_name, ".reg") == 0 && sect_size >= SHNBSD_SIZEOF_GREGS)
-    return &shnbsd_gregset;
-
-  return NULL;
-}
-
 void
 shnbsd_supply_reg (struct regcache *regcache, const char *regs, int regnum)
 {
@@ -177,11 +78,12 @@ static void
 shnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
-  set_gdbarch_regset_from_core_section
-    (gdbarch, shnbsd_regset_from_core_section);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+
+  /* Set tdep->core_regmap here.  */
 }
 \f
 

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

* Re: [PATCH][SH] Implement core-file support for sh-linux
  2009-10-15 16:20     ` Joel Brobecker
@ 2009-10-19 17:27       ` Andrew Stubbs
  2009-10-19 19:33         ` Joel Brobecker
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Stubbs @ 2009-10-19 17:27 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

On 15/10/09 17:19, Joel Brobecker wrote:
> You definitely got the idea, but the implementation does not work
> in the case of multi-arch debugging.  This is because you are
> introducing a global variable.  The solution is to rely on the
> gdbarch_tdep structure.

OK, how about this patch?

I've reimplemented it using your ideas. I've tested that sh-linux GDB 
can read a core file, and I've tested that shnbsd.tdep.c can be built.

Andrew

[-- Attachment #2: corefiles.patch --]
[-- Type: text/x-diff, Size: 15187 bytes --]

2009-10-19  Andrew Stubbs  <ams@codesourcery.com>
	    Joel Brobecker  <brobecker@adacore.com>

	* configure.tgt (sh*-*-linux*): Add corelow.o to gdb_target_obs.
	* sh-linux-tdep.c: Include sh-tdep.h.
	(REGSx16): New macro.
	(gregs_table, fpregs_table): New variables.
	(sh_linux_init_abi): Set core_gregmap and fpregmap.
	* sh-tdep.c: Include regset.h.
	(sh_corefile_supply_regset): New function.
	(sh_corefile_collect_regset): New function.
	(sh_corefile_gregset, sh_corefile_fpregset): New variables.
	(sh_regset_from_core_section): New function.
	(sh_gdbarch_init): Set up tdep value.
	Call set_gdbarch_regset_from_core_section.
	* sh-tdep.h (PC_REGNUM): New enum value.
	(struct sh_corefile_regs): New type.
	(sh_corefile_gregset): Export variable.
	* shnbsd-tdep.c: Remove include of regcache.h and gdb_assert.h.
	(regmap): Use new definition using struct sh_corefile_regs.
	(shnbsd_supply_gregset, shnbsd_collect_gregset): Delete.
	(shnbsd_gregset): Delete.
	(shnbsd_regset_from_core_section): Delete.
	(shnbsd_supply_reg, shnbsd_fill_reg): Use new regset interface.
	(shnbsd_init_abi): Set core_gregmap.

---
 src/gdb-mainline/gdb/configure.tgt   |    3 -
 src/gdb-mainline/gdb/sh-linux-tdep.c |   52 +++++++++++
 src/gdb-mainline/gdb/sh-tdep.c       |   92 ++++++++++++++++++++
 src/gdb-mainline/gdb/sh-tdep.h       |   22 +++++
 src/gdb-mainline/gdb/shnbsd-tdep.c   |  155 +++++++---------------------------
 5 files changed, 197 insertions(+), 127 deletions(-)


diff --git a/src/gdb-mainline/gdb/configure.tgt b/src/gdb-mainline/gdb/configure.tgt
index 20b739e..0d3074a 100644
--- a/src/gdb-mainline/gdb/configure.tgt
+++ b/src/gdb-mainline/gdb/configure.tgt
@@ -407,7 +407,8 @@ score-*-*)
 sh*-*-linux*)
 	# Target: GNU/Linux Super-H
 	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-linux-tdep.o monitor.o \
-			dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o"
+			dsrec.o solib.o solib-svr4.o symfile-mem.o \
+			glibc-tdep.o corelow.o"
 	gdb_sim=../sim/sh/libsim.a
 	build_gdbserver=yes
 	;;
diff --git a/src/gdb-mainline/gdb/sh-linux-tdep.c b/src/gdb-mainline/gdb/sh-linux-tdep.c
index 46aad1d..1e62f27 100644
--- a/src/gdb-mainline/gdb/sh-linux-tdep.c
+++ b/src/gdb-mainline/gdb/sh-linux-tdep.c
@@ -24,6 +24,50 @@
 #include "symtab.h"
 
 #include "glibc-tdep.h"
+#include "sh-tdep.h"
+
+#define REGSx16(base) \
+  {(base),      0}, \
+  {(base) +  1, 4}, \
+  {(base) +  2, 8}, \
+  {(base) +  3, 12}, \
+  {(base) +  4, 16}, \
+  {(base) +  5, 20}, \
+  {(base) +  6, 24}, \
+  {(base) +  7, 28}, \
+  {(base) +  8, 32}, \
+  {(base) +  9, 36}, \
+  {(base) + 10, 40}, \
+  {(base) + 11, 44}, \
+  {(base) + 12, 48}, \
+  {(base) + 13, 52}, \
+  {(base) + 14, 56}, \
+  {(base) + 15, 60}
+
+/* Describe the contents of the .reg section of the core file.  */
+
+static const struct sh_corefile_regmap gregs_table[] =
+{
+  REGSx16 (R0_REGNUM),
+  {PC_REGNUM,   64},
+  {PR_REGNUM,   68},
+  {SR_REGNUM,   72},
+  {GBR_REGNUM,  76},
+  {MACH_REGNUM, 80},
+  {MACL_REGNUM, 84},
+  {-1 /* Terminator.  */, 0}
+};
+
+/* Describe the contents of the .reg2 section of the core file.  */
+
+static const struct sh_corefile_regmap fpregs_table[] =
+{
+  REGSx16 (FR0_REGNUM),
+  /* REGSx16 xfp_regs omitted.  */
+  {FPSCR_REGNUM, 128},
+  {FPUL_REGNUM,  132},
+  {-1 /* Terminator.  */, 0}
+};
 
 static void
 sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -36,6 +80,14 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Core files are supported for 32-bit SH only, at present.  */
+  if (info.bfd_arch_info->mach != bfd_mach_sh5)
+    {
+      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+      tdep->core_gregmap = (struct sh_corefile_regmap *)gregs_table;
+      tdep->core_fpregmap = (struct sh_corefile_regmap *)fpregs_table;
+    }
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
diff --git a/src/gdb-mainline/gdb/sh-tdep.c b/src/gdb-mainline/gdb/sh-tdep.c
index 3e509bf..b0a8d81 100644
--- a/src/gdb-mainline/gdb/sh-tdep.c
+++ b/src/gdb-mainline/gdb/sh-tdep.c
@@ -43,6 +43,7 @@
 #include "doublest.h"
 #include "osabi.h"
 #include "reggroups.h"
+#include "regset.h"
 
 #include "sh-tdep.h"
 
@@ -2738,12 +2739,98 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
     }
   return 0;
 }
+
+
+/* Supply register REGNUM from the buffer specified by REGS and LEN
+   in the register set REGSET to register cache REGCACHE.
+   REGTABLE specifies where each register can be found in REGS.
+   If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_corefile_supply_regset (const struct regset *regset,
+			   struct regcache *regcache,
+			   int regnum, const void *regs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  const struct sh_corefile_regmap *regmap = regset == &sh_corefile_gregset
+					    ? tdep->core_gregmap
+					    : tdep->core_fpregmap;
+  int i;
+
+  for (i = 0; regmap[i].regnum != -1; i++)
+    {
+      if ((regnum == -1 || regnum == regmap[i].regnum)
+	  && regmap[i].offset + 4 <= len)
+	regcache_raw_supply (regcache, regmap[i].regnum,
+			     (char *)regs + regmap[i].offset);
+    }
+}
+
+/* Collect register REGNUM in the register set REGSET from register cache
+   REGCACHE into the buffer specified by REGS and LEN.
+   REGTABLE specifies where each register can be found in REGS.
+   If REGNUM is -1, do this for all registers in REGSET.  */
+
+static void
+sh_corefile_collect_regset (const struct regset *regset,
+			    const struct regcache *regcache,
+			    int regnum, void *regs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  const struct sh_corefile_regmap *regmap = regset == &sh_corefile_gregset
+					    ? tdep->core_gregmap
+					    : tdep->core_fpregmap;
+  int i;
+
+  for (i = 0; regmap[i].regnum != -1; i++)
+    {
+      if ((regnum == -1 || regnum == regmap[i].regnum)
+	  && regmap[i].offset + 4 <= len)
+	regcache_raw_collect (regcache, regmap[i].regnum,
+			      (char *)regs + regmap[i].offset);
+    }
+}
+
+/* The following two regsets have the same contents, so it is tempting to
+   unify them, but they are distiguished by their address, so don't.  */
+
+struct regset sh_corefile_gregset =
+{
+  NULL,
+  sh_corefile_supply_regset,
+  sh_corefile_collect_regset
+};
+
+static struct regset sh_corefile_fpregset =
+{
+  NULL,
+  sh_corefile_supply_regset,
+  sh_corefile_collect_regset
+};
+
+static const struct regset *
+sh_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name,
+			     size_t sect_size)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (tdep->core_gregmap && strcmp (sect_name, ".reg") == 0)
+    return &sh_corefile_gregset;
+
+  if (tdep->core_fpregmap && strcmp (sect_name, ".reg2") == 0)
+    return &sh_corefile_fpregset;
+
+  return NULL;
+}
 \f
 
 static struct gdbarch *
 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
+  struct gdbarch_tdep *tdep;
 
   sh_show_regs = sh_generic_show_regs;
   switch (info.bfd_arch_info->mach)
@@ -2803,7 +2890,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided. */
-  gdbarch = gdbarch_alloc (&info, NULL);
+  tdep = XZALLOC (struct gdbarch_tdep);
+  gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
@@ -2847,6 +2935,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   dwarf2_frame_set_init_reg (gdbarch, sh_dwarf2_frame_init_reg);
 
+  set_gdbarch_regset_from_core_section (gdbarch, sh_regset_from_core_section);
+
   switch (info.bfd_arch_info->mach)
     {
     case bfd_mach_sh:
diff --git a/src/gdb-mainline/gdb/sh-tdep.h b/src/gdb-mainline/gdb/sh-tdep.h
index dfa928e..cd2f873 100644
--- a/src/gdb-mainline/gdb/sh-tdep.h
+++ b/src/gdb-mainline/gdb/sh-tdep.h
@@ -30,6 +30,7 @@ enum
     ARG0_REGNUM = 4,
     ARGLAST_REGNUM = 7,
     FP_REGNUM = 14,
+    PC_REGNUM = 16,
     PR_REGNUM = 17,
     GBR_REGNUM = 18,
     VBR_REGNUM = 19,
@@ -85,4 +86,25 @@ enum
 extern gdbarch_init_ftype sh64_gdbarch_init;
 extern void sh64_show_regs (struct frame_info *);
 
+/* This structure describes a register in a core-file.  */
+struct sh_corefile_regmap
+{
+  int regnum;
+  unsigned int offset;
+};
+
+struct gdbarch_tdep
+{
+  /* Non-NULL when debugging from a core file.  Provides the offset
+     where each general-purpose register is stored inside the associated
+     core file section.  */
+  struct sh_corefile_regmap *core_gregmap;
+  /* Non-NULL when debugging from a core file and when FP registers are
+     available.  Provides the offset where each FP register is stored
+     inside the associated core file section.  */
+  struct sh_corefile_regmap *core_fpregmap;
+};
+
+extern struct regset sh_corefile_gregset;
+
 #endif /* SH_TDEP_H */
diff --git a/src/gdb-mainline/gdb/shnbsd-tdep.c b/src/gdb-mainline/gdb/shnbsd-tdep.c
index a0cddc5..6630717 100644
--- a/src/gdb-mainline/gdb/shnbsd-tdep.c
+++ b/src/gdb-mainline/gdb/shnbsd-tdep.c
@@ -22,154 +22,59 @@
 
 #include "defs.h"
 #include "gdbcore.h"
-#include "regcache.h"
 #include "regset.h"
 #include "value.h"
 #include "osabi.h"
 
-#include "gdb_assert.h"
 #include "gdb_string.h"
 
 #include "sh-tdep.h"
 #include "shnbsd-tdep.h"
 #include "solib-svr4.h"
 
-/* Convert an r0-r15 register number into an offset into a ptrace
+/* Convert a register number into an offset into a ptrace
    register structure.  */
-static const int regmap[] =
+static const struct sh_corefile_regmap regmap[] =
 {
-  (20 * 4),	/* r0 */
-  (19 * 4),	/* r1 */
-  (18 * 4),	/* r2 */ 
-  (17 * 4),	/* r3 */ 
-  (16 * 4),	/* r4 */
-  (15 * 4),	/* r5 */
-  (14 * 4),	/* r6 */
-  (13 * 4),	/* r7 */
-  (12 * 4),	/* r8 */ 
-  (11 * 4),	/* r9 */
-  (10 * 4),	/* r10 */
-  ( 9 * 4),	/* r11 */
-  ( 8 * 4),	/* r12 */
-  ( 7 * 4),	/* r13 */
-  ( 6 * 4),	/* r14 */
-  ( 5 * 4),	/* r15 */
+  {R0_REGNUM,      20 * 4},
+  {R0_REGNUM + 1,  19 * 4},
+  {R0_REGNUM + 2,  18 * 4},
+  {R0_REGNUM + 3,  17 * 4},
+  {R0_REGNUM + 4,  16 * 4},
+  {R0_REGNUM + 5,  15 * 4},
+  {R0_REGNUM + 6,  14 * 4},
+  {R0_REGNUM + 7,  13 * 4},
+  {R0_REGNUM + 8,  12 * 4},
+  {R0_REGNUM + 9,  11 * 4},
+  {R0_REGNUM + 10, 10 * 4},
+  {R0_REGNUM + 11,  9 * 4},
+  {R0_REGNUM + 12,  8 * 4},
+  {R0_REGNUM + 13,  7 * 4},
+  {R0_REGNUM + 14,  6 * 4},
+  {R0_REGNUM + 15,  5 * 4},
+  {PC_REGNUM,       0 * 4},
+  {SR_REGNUM,       1 * 4},
+  {PR_REGNUM,	    2 * 4},
+  {MACH_REGNUM,	    3 * 4},
+  {MACL_REGNUM,	    4 * 4},
+  {-1 /* Terminator.  */, 0}
 };
 
 /* Sizeof `struct reg' in <machine/reg.h>.  */
 #define SHNBSD_SIZEOF_GREGS	(21 * 4)
 
-/* Supply register REGNUM from the buffer specified by GREGS and LEN
-   in the general-purpose register set REGSET to register cache
-   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
-
-static void
-shnbsd_supply_gregset (const struct regset *regset,
-		       struct regcache *regcache,
-		       int regnum, const void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  const gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
-			 regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_supply (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* Collect register REGNUM in the general-purpose register set
-   REGSET. from register cache REGCACHE into the buffer specified by
-   GREGS and LEN.  If REGNUM is -1, do this for all registers in
-   REGSET.  */
-
-static void
-shnbsd_collect_gregset (const struct regset *regset,
-			const struct regcache *regcache,
-			int regnum, void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_collect (regcache, gdbarch_pc_regnum (gdbarch),
-			  regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_collect (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* SH register sets.  */
-
-static struct regset shnbsd_gregset =
-{
-  NULL,
-  shnbsd_supply_gregset,
-  shnbsd_collect_gregset
-};
-
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
-
-static const struct regset *
-shnbsd_regset_from_core_section (struct gdbarch *gdbarch,
-				 const char *sect_name, size_t sect_size)
-{
-  if (strcmp (sect_name, ".reg") == 0 && sect_size >= SHNBSD_SIZEOF_GREGS)
-    return &shnbsd_gregset;
-
-  return NULL;
-}
-
 void
 shnbsd_supply_reg (struct regcache *regcache, const char *regs, int regnum)
 {
-  shnbsd_supply_gregset (&shnbsd_gregset, regcache, regnum,
-			 regs, SHNBSD_SIZEOF_GREGS);
+  sh_corefile_gregset.supply_regset (&sh_corefile_gregset, regcache, regnum,
+				     regs, SHNBSD_SIZEOF_GREGS);
 }
 
 void
 shnbsd_fill_reg (const struct regcache *regcache, char *regs, int regnum)
 {
-  shnbsd_collect_gregset (&shnbsd_gregset, regcache, regnum,
-			  regs, SHNBSD_SIZEOF_GREGS);
+  sh_corefile_gregset.collect_regset (&sh_corefile_gregset, regcache, regnum,
+				      regs, SHNBSD_SIZEOF_GREGS);
 }
 \f
 
@@ -177,8 +82,8 @@ static void
 shnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
-  set_gdbarch_regset_from_core_section
-    (gdbarch, shnbsd_regset_from_core_section);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
 
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);

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

* Re: [PATCH][SH] Implement core-file support for sh-linux
  2009-10-19 17:27       ` Andrew Stubbs
@ 2009-10-19 19:33         ` Joel Brobecker
  2009-10-21 14:18           ` Andrew Stubbs
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2009-10-19 19:33 UTC (permalink / raw)
  To: Andrew Stubbs; +Cc: gdb-patches

On Mon, Oct 19, 2009 at 06:26:51PM +0100, Andrew Stubbs wrote:
> 2009-10-19  Andrew Stubbs  <ams@codesourcery.com>
> 	    Joel Brobecker  <brobecker@adacore.com>
> 
> 	* configure.tgt (sh*-*-linux*): Add corelow.o to gdb_target_obs.
> 	* sh-linux-tdep.c: Include sh-tdep.h.
> 	(REGSx16): New macro.
> 	(gregs_table, fpregs_table): New variables.
> 	(sh_linux_init_abi): Set core_gregmap and fpregmap.
> 	* sh-tdep.c: Include regset.h.
> 	(sh_corefile_supply_regset): New function.
> 	(sh_corefile_collect_regset): New function.
> 	(sh_corefile_gregset, sh_corefile_fpregset): New variables.
> 	(sh_regset_from_core_section): New function.
> 	(sh_gdbarch_init): Set up tdep value.
> 	Call set_gdbarch_regset_from_core_section.
> 	* sh-tdep.h (PC_REGNUM): New enum value.
> 	(struct sh_corefile_regs): New type.
> 	(sh_corefile_gregset): Export variable.
> 	* shnbsd-tdep.c: Remove include of regcache.h and gdb_assert.h.
> 	(regmap): Use new definition using struct sh_corefile_regs.
> 	(shnbsd_supply_gregset, shnbsd_collect_gregset): Delete.
> 	(shnbsd_gregset): Delete.
> 	(shnbsd_regset_from_core_section): Delete.
> 	(shnbsd_supply_reg, shnbsd_fill_reg): Use new regset interface.
> 	(shnbsd_init_abi): Set core_gregmap.

Thanks!

I just a few minor comments. This is pre-approved after the comments
have been addressed.

> +  /* Core files are supported for 32-bit SH only, at present.  */
> +  if (info.bfd_arch_info->mach != bfd_mach_sh5)
> +    {
> +      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> +      tdep->core_gregmap = (struct sh_corefile_regmap *)gregs_table;

Can you add en empty line between the declarations and the first
statement?  This is something that some of the maintainers insist on,
so let's try to be as consistent as we can.

> +  const struct sh_corefile_regmap *regmap = regset == &sh_corefile_gregset
> +					    ? tdep->core_gregmap
> +					    : tdep->core_fpregmap;

Just another formatting nit: the Gnu Coding Standards actually explicitly
help in that case and ask that we use parens around your expression.
This helps gnu indent as well as emacs format your code properly, but
I just think it makes it more readable.

const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
                                           ? tdep->core_gregmap
                                           : tdep->core_fpregmap);

Likewise in sh_corefile_collect_regset.

>  shnbsd_supply_reg (struct regcache *regcache, const char *regs, int regnum)
>  {
> -  shnbsd_supply_gregset (&shnbsd_gregset, regcache, regnum,
> -			 regs, SHNBSD_SIZEOF_GREGS);
> +  sh_corefile_gregset.supply_regset (&sh_corefile_gregset, regcache, regnum,
> +				     regs, SHNBSD_SIZEOF_GREGS);
>  }

Personally, I would prefer it if you declared the two functions
sh_corefile_supply_regset and sh_corefile_collect_regset as non-static
and using them directly, rather than accessing a global constant to call
a function.  This made me believe, at first, that you were accessing
a global variable that was set while the target was determined, and thus
would not be multiarch-friendly.  I see now that this is not the case,
so the code looks correct to me now. I would just delete the code
and replace the calls form shnbsd-nat.c to the calls to the new
sh_corefile_supply/collect_regset functions.

But this is not a strong requirement.  If you prefer it the current
way, I will not complain.

-- 
Joel


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

* Re: [PATCH][SH] Implement core-file support for sh-linux
  2009-10-19 19:33         ` Joel Brobecker
@ 2009-10-21 14:18           ` Andrew Stubbs
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Stubbs @ 2009-10-21 14:18 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 943 bytes --]

On 19/10/09 20:33, Joel Brobecker wrote:
> I just a few minor comments. This is pre-approved after the comments
> have been addressed.

OK, I've attached what I committed.

> Personally, I would prefer it if you declared the two functions
> sh_corefile_supply_regset and sh_corefile_collect_regset as non-static
> and using them directly, rather than accessing a global constant to call
> a function.  This made me believe, at first, that you were accessing
> a global variable that was set while the target was determined, and thus
> would not be multiarch-friendly.  I see now that this is not the case,
> so the code looks correct to me now. I would just delete the code
> and replace the calls form shnbsd-nat.c to the calls to the new
> sh_corefile_supply/collect_regset functions.

I have done this. This resulted in shnbsd-tdep.h having no contents, so 
I've deleted it.

Otherwise, the only changes are the ones you requested.

Andrew

[-- Attachment #2: corefiles.patch --]
[-- Type: text/x-diff, Size: 19655 bytes --]

2009-10-21  Andrew Stubbs  <ams@codesourcery.com>
	    Joel Brobecker  <brobecker@adacore.com>

	* Makefile.in (HFILES_NO_SRCDIR): Remove shnbsd-tdep.h
	* configure.tgt (sh*-*-linux*): Add corelow.o to gdb_target_obs.
	* sh-linux-tdep.c: Include sh-tdep.h.
	(REGSx16): New macro.
	(gregs_table, fpregs_table): New variables.
	(sh_linux_init_abi): Set core_gregmap and fpregmap.
	* sh-tdep.c: Include regset.h.
	(sh_corefile_supply_regset): New function.
	(sh_corefile_collect_regset): New function.
	(sh_corefile_gregset, sh_corefile_fpregset): New variables.
	(sh_regset_from_core_section): New function.
	(sh_gdbarch_init): Set up tdep value.
	Call set_gdbarch_regset_from_core_section.
	* sh-tdep.h (PC_REGNUM): New enum value.
	(struct sh_corefile_regs): New type.
	(sh_corefile_gregset): Export variable.
	(sh_corefile_supply_regset): New prototype.
	(sh_corefile_collect_regset): New prototype.
	* shnbsd-tdep.c: Remove include of regcache.h, gdb_assert.h and
	shnbsd-tdep.h.
	(regmap): Use new definition using struct sh_corefile_regs.
	(shnbsd_supply_gregset, shnbsd_collect_gregset): Delete.
	(shnbsd_gregset): Delete.
	(shnbsd_regset_from_core_section): Delete.
	(shnbsd_supply_reg, shnbsd_fill_reg): Use new regset interface.
	(shnbsd_init_abi): Set core_gregmap.
	(shnbsd_supply_reg): Delete.
	(shnbsd_fill_reg): Delete.
	(SHNBSD_SIZEOF_GREGS): Move ...
	* shnbsd-nat.c (SHNBSD_SIZEOF_GREGS): ... to here.
	Remove include of shnbsd-tdep.h.
	(shnbsd_fetch_inferior_registers): Replace shnbsd_supply_reg call
	with sh_corefile_supply_regset.
	(shnbsd_store_inferior_registers): Replace shnbsd_fill_reg call with
	sh_corefile_collect_regset.
	* shnbsd-tdep.h: Delete file.

---
 src/gdb-mainline/gdb/Makefile.in     |    2 
 src/gdb-mainline/gdb/configure.tgt   |    3 -
 src/gdb-mainline/gdb/sh-linux-tdep.c |   53 +++++++++++
 src/gdb-mainline/gdb/sh-tdep.c       |   92 +++++++++++++++++++
 src/gdb-mainline/gdb/sh-tdep.h       |   28 ++++++
 src/gdb-mainline/gdb/shnbsd-nat.c    |   12 ++
 src/gdb-mainline/gdb/shnbsd-tdep.c   |  166 ++++++----------------------------
 src/gdb-mainline/gdb/shnbsd-tdep.h   |   26 -----
 8 files changed, 211 insertions(+), 171 deletions(-)
 delete mode 100644 src/gdb-mainline/gdb/shnbsd-tdep.h


diff --git a/src/gdb-mainline/gdb/Makefile.in b/src/gdb-mainline/gdb/Makefile.in
index 0172782..e5e8cfe 100644
--- a/src/gdb-mainline/gdb/Makefile.in
+++ b/src/gdb-mainline/gdb/Makefile.in
@@ -723,7 +723,7 @@ f-lang.h dwarf2loc.h value.h sparc-tdep.h defs.h target-descriptions.h \
 objfiles.h vec.h disasm.h mips-tdep.h ser-base.h \
 gdb_curses.h bfd-target.h memattr.h inferior.h ax.h dummy-frame.h \
 inflow.h fbsd-nat.h libunwind-frame.h completer.h inf-ttrace.h \
-solib-target.h shnbsd-tdep.h gdb_vfork.h alpha-tdep.h dwarf2expr.h \
+solib-target.h gdb_vfork.h alpha-tdep.h dwarf2expr.h \
 m2-lang.h stack.h charset.h addrmap.h command.h solist.h source.h \
 target.h prologue-value.h cp-abi.h tui/tui-hooks.h tui/tui.h \
 tui/tui-file.h tui/tui-command.h tui/tui-disasm.h tui/tui-wingeneral.h \
diff --git a/src/gdb-mainline/gdb/configure.tgt b/src/gdb-mainline/gdb/configure.tgt
index c123510..b18e3b2 100644
--- a/src/gdb-mainline/gdb/configure.tgt
+++ b/src/gdb-mainline/gdb/configure.tgt
@@ -420,7 +420,8 @@ score-*-*)
 sh*-*-linux*)
 	# Target: GNU/Linux Super-H
 	gdb_target_obs="sh-tdep.o sh64-tdep.o sh-linux-tdep.o monitor.o \
-			dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o"
+			dsrec.o solib.o solib-svr4.o symfile-mem.o \
+			glibc-tdep.o corelow.o"
 	gdb_sim=../sim/sh/libsim.a
 	build_gdbserver=yes
 	;;
diff --git a/src/gdb-mainline/gdb/sh-linux-tdep.c b/src/gdb-mainline/gdb/sh-linux-tdep.c
index 46aad1d..4e9d18c 100644
--- a/src/gdb-mainline/gdb/sh-linux-tdep.c
+++ b/src/gdb-mainline/gdb/sh-linux-tdep.c
@@ -24,6 +24,50 @@
 #include "symtab.h"
 
 #include "glibc-tdep.h"
+#include "sh-tdep.h"
+
+#define REGSx16(base) \
+  {(base),      0}, \
+  {(base) +  1, 4}, \
+  {(base) +  2, 8}, \
+  {(base) +  3, 12}, \
+  {(base) +  4, 16}, \
+  {(base) +  5, 20}, \
+  {(base) +  6, 24}, \
+  {(base) +  7, 28}, \
+  {(base) +  8, 32}, \
+  {(base) +  9, 36}, \
+  {(base) + 10, 40}, \
+  {(base) + 11, 44}, \
+  {(base) + 12, 48}, \
+  {(base) + 13, 52}, \
+  {(base) + 14, 56}, \
+  {(base) + 15, 60}
+
+/* Describe the contents of the .reg section of the core file.  */
+
+static const struct sh_corefile_regmap gregs_table[] =
+{
+  REGSx16 (R0_REGNUM),
+  {PC_REGNUM,   64},
+  {PR_REGNUM,   68},
+  {SR_REGNUM,   72},
+  {GBR_REGNUM,  76},
+  {MACH_REGNUM, 80},
+  {MACL_REGNUM, 84},
+  {-1 /* Terminator.  */, 0}
+};
+
+/* Describe the contents of the .reg2 section of the core file.  */
+
+static const struct sh_corefile_regmap fpregs_table[] =
+{
+  REGSx16 (FR0_REGNUM),
+  /* REGSx16 xfp_regs omitted.  */
+  {FPSCR_REGNUM, 128},
+  {FPUL_REGNUM,  132},
+  {-1 /* Terminator.  */, 0}
+};
 
 static void
 sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -36,6 +80,15 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_fetch_tls_load_module_address (gdbarch,
                                              svr4_fetch_objfile_link_map);
+
+  /* Core files are supported for 32-bit SH only, at present.  */
+  if (info.bfd_arch_info->mach != bfd_mach_sh5)
+    {
+      struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+      tdep->core_gregmap = (struct sh_corefile_regmap *)gregs_table;
+      tdep->core_fpregmap = (struct sh_corefile_regmap *)fpregs_table;
+    }
 }
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
diff --git a/src/gdb-mainline/gdb/sh-tdep.c b/src/gdb-mainline/gdb/sh-tdep.c
index 3e509bf..e3fa62f 100644
--- a/src/gdb-mainline/gdb/sh-tdep.c
+++ b/src/gdb-mainline/gdb/sh-tdep.c
@@ -43,6 +43,7 @@
 #include "doublest.h"
 #include "osabi.h"
 #include "reggroups.h"
+#include "regset.h"
 
 #include "sh-tdep.h"
 
@@ -2738,12 +2739,98 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
     }
   return 0;
 }
+
+
+/* Supply register REGNUM from the buffer specified by REGS and LEN
+   in the register set REGSET to register cache REGCACHE.
+   REGTABLE specifies where each register can be found in REGS.
+   If REGNUM is -1, do this for all registers in REGSET.  */
+
+void
+sh_corefile_supply_regset (const struct regset *regset,
+			   struct regcache *regcache,
+			   int regnum, const void *regs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
+					     ? tdep->core_gregmap
+					     : tdep->core_fpregmap);
+  int i;
+
+  for (i = 0; regmap[i].regnum != -1; i++)
+    {
+      if ((regnum == -1 || regnum == regmap[i].regnum)
+	  && regmap[i].offset + 4 <= len)
+	regcache_raw_supply (regcache, regmap[i].regnum,
+			     (char *)regs + regmap[i].offset);
+    }
+}
+
+/* Collect register REGNUM in the register set REGSET from register cache
+   REGCACHE into the buffer specified by REGS and LEN.
+   REGTABLE specifies where each register can be found in REGS.
+   If REGNUM is -1, do this for all registers in REGSET.  */
+
+void
+sh_corefile_collect_regset (const struct regset *regset,
+			    const struct regcache *regcache,
+			    int regnum, void *regs, size_t len)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset
+					     ? tdep->core_gregmap
+					     : tdep->core_fpregmap);
+  int i;
+
+  for (i = 0; regmap[i].regnum != -1; i++)
+    {
+      if ((regnum == -1 || regnum == regmap[i].regnum)
+	  && regmap[i].offset + 4 <= len)
+	regcache_raw_collect (regcache, regmap[i].regnum,
+			      (char *)regs + regmap[i].offset);
+    }
+}
+
+/* The following two regsets have the same contents, so it is tempting to
+   unify them, but they are distiguished by their address, so don't.  */
+
+struct regset sh_corefile_gregset =
+{
+  NULL,
+  sh_corefile_supply_regset,
+  sh_corefile_collect_regset
+};
+
+static struct regset sh_corefile_fpregset =
+{
+  NULL,
+  sh_corefile_supply_regset,
+  sh_corefile_collect_regset
+};
+
+static const struct regset *
+sh_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name,
+			     size_t sect_size)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (tdep->core_gregmap && strcmp (sect_name, ".reg") == 0)
+    return &sh_corefile_gregset;
+
+  if (tdep->core_fpregmap && strcmp (sect_name, ".reg2") == 0)
+    return &sh_corefile_fpregset;
+
+  return NULL;
+}
 \f
 
 static struct gdbarch *
 sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
   struct gdbarch *gdbarch;
+  struct gdbarch_tdep *tdep;
 
   sh_show_regs = sh_generic_show_regs;
   switch (info.bfd_arch_info->mach)
@@ -2803,7 +2890,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* None found, create a new architecture from the information
      provided. */
-  gdbarch = gdbarch_alloc (&info, NULL);
+  tdep = XZALLOC (struct gdbarch_tdep);
+  gdbarch = gdbarch_alloc (&info, tdep);
 
   set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
   set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
@@ -2847,6 +2935,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   dwarf2_frame_set_init_reg (gdbarch, sh_dwarf2_frame_init_reg);
 
+  set_gdbarch_regset_from_core_section (gdbarch, sh_regset_from_core_section);
+
   switch (info.bfd_arch_info->mach)
     {
     case bfd_mach_sh:
diff --git a/src/gdb-mainline/gdb/sh-tdep.h b/src/gdb-mainline/gdb/sh-tdep.h
index dfa928e..76a6236 100644
--- a/src/gdb-mainline/gdb/sh-tdep.h
+++ b/src/gdb-mainline/gdb/sh-tdep.h
@@ -30,6 +30,7 @@ enum
     ARG0_REGNUM = 4,
     ARGLAST_REGNUM = 7,
     FP_REGNUM = 14,
+    PC_REGNUM = 16,
     PR_REGNUM = 17,
     GBR_REGNUM = 18,
     VBR_REGNUM = 19,
@@ -85,4 +86,31 @@ enum
 extern gdbarch_init_ftype sh64_gdbarch_init;
 extern void sh64_show_regs (struct frame_info *);
 
+/* This structure describes a register in a core-file.  */
+struct sh_corefile_regmap
+{
+  int regnum;
+  unsigned int offset;
+};
+
+struct gdbarch_tdep
+{
+  /* Non-NULL when debugging from a core file.  Provides the offset
+     where each general-purpose register is stored inside the associated
+     core file section.  */
+  struct sh_corefile_regmap *core_gregmap;
+  /* Non-NULL when debugging from a core file and when FP registers are
+     available.  Provides the offset where each FP register is stored
+     inside the associated core file section.  */
+  struct sh_corefile_regmap *core_fpregmap;
+};
+
+extern struct regset sh_corefile_gregset;
+
+void sh_corefile_supply_regset (const struct regset *regset,
+				struct regcache *regcache,
+				int regnum, const void *regs, size_t len);
+void sh_corefile_collect_regset (const struct regset *regset,
+				 const struct regcache *regcache,
+				 int regnum, void *regs, size_t len);
 #endif /* SH_TDEP_H */
diff --git a/src/gdb-mainline/gdb/shnbsd-nat.c b/src/gdb-mainline/gdb/shnbsd-nat.c
index 90b0406..1aad4ba 100644
--- a/src/gdb-mainline/gdb/shnbsd-nat.c
+++ b/src/gdb-mainline/gdb/shnbsd-nat.c
@@ -28,7 +28,6 @@
 #include <machine/reg.h>
 
 #include "sh-tdep.h"
-#include "shnbsd-tdep.h"
 #include "inf-ptrace.h"
 #include "regcache.h"
 
@@ -40,6 +39,9 @@
 || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \
 || (regno) == SR_REGNUM)
 
+/* Sizeof `struct reg' in <machine/reg.h>.  */
+#define SHNBSD_SIZEOF_GREGS	(21 * 4)
+
 static void
 shnbsd_fetch_inferior_registers (struct target_ops *ops,
 				 struct regcache *regcache, int regno)
@@ -52,7 +54,9 @@ shnbsd_fetch_inferior_registers (struct target_ops *ops,
 		  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
-      shnbsd_supply_reg (regcache, (char *) &inferior_registers, regno);
+      sh_corefile_supply_regset (&sh_corefile_gregset, regcache, regno,
+				 (char *) &inferior_registers,
+				 SHNBSD_SIZEOF_GREGS);
 
       if (regno != -1)
 	return;
@@ -71,7 +75,9 @@ shnbsd_store_inferior_registers (struct target_ops *ops,
 		  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
-      shnbsd_fill_reg (regcache, (char *) &inferior_registers, regno);
+      sh_corefile_collect_regset (&sh_corefile_gregset, regcache, regno,
+				  (char *) &inferior_registers,
+				  SHNBSD_SIZEOF_GREGS);
 
       if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
 		  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
diff --git a/src/gdb-mainline/gdb/shnbsd-tdep.c b/src/gdb-mainline/gdb/shnbsd-tdep.c
index a0cddc5..18a2a73 100644
--- a/src/gdb-mainline/gdb/shnbsd-tdep.c
+++ b/src/gdb-mainline/gdb/shnbsd-tdep.c
@@ -22,163 +22,51 @@
 
 #include "defs.h"
 #include "gdbcore.h"
-#include "regcache.h"
 #include "regset.h"
 #include "value.h"
 #include "osabi.h"
 
-#include "gdb_assert.h"
 #include "gdb_string.h"
 
 #include "sh-tdep.h"
-#include "shnbsd-tdep.h"
 #include "solib-svr4.h"
 
-/* Convert an r0-r15 register number into an offset into a ptrace
+/* Convert a register number into an offset into a ptrace
    register structure.  */
-static const int regmap[] =
+static const struct sh_corefile_regmap regmap[] =
 {
-  (20 * 4),	/* r0 */
-  (19 * 4),	/* r1 */
-  (18 * 4),	/* r2 */ 
-  (17 * 4),	/* r3 */ 
-  (16 * 4),	/* r4 */
-  (15 * 4),	/* r5 */
-  (14 * 4),	/* r6 */
-  (13 * 4),	/* r7 */
-  (12 * 4),	/* r8 */ 
-  (11 * 4),	/* r9 */
-  (10 * 4),	/* r10 */
-  ( 9 * 4),	/* r11 */
-  ( 8 * 4),	/* r12 */
-  ( 7 * 4),	/* r13 */
-  ( 6 * 4),	/* r14 */
-  ( 5 * 4),	/* r15 */
+  {R0_REGNUM,      20 * 4},
+  {R0_REGNUM + 1,  19 * 4},
+  {R0_REGNUM + 2,  18 * 4},
+  {R0_REGNUM + 3,  17 * 4},
+  {R0_REGNUM + 4,  16 * 4},
+  {R0_REGNUM + 5,  15 * 4},
+  {R0_REGNUM + 6,  14 * 4},
+  {R0_REGNUM + 7,  13 * 4},
+  {R0_REGNUM + 8,  12 * 4},
+  {R0_REGNUM + 9,  11 * 4},
+  {R0_REGNUM + 10, 10 * 4},
+  {R0_REGNUM + 11,  9 * 4},
+  {R0_REGNUM + 12,  8 * 4},
+  {R0_REGNUM + 13,  7 * 4},
+  {R0_REGNUM + 14,  6 * 4},
+  {R0_REGNUM + 15,  5 * 4},
+  {PC_REGNUM,       0 * 4},
+  {SR_REGNUM,       1 * 4},
+  {PR_REGNUM,	    2 * 4},
+  {MACH_REGNUM,	    3 * 4},
+  {MACL_REGNUM,	    4 * 4},
+  {-1 /* Terminator.  */, 0}
 };
-
-/* Sizeof `struct reg' in <machine/reg.h>.  */
-#define SHNBSD_SIZEOF_GREGS	(21 * 4)
-
-/* Supply register REGNUM from the buffer specified by GREGS and LEN
-   in the general-purpose register set REGSET to register cache
-   REGCACHE.  If REGNUM is -1, do this for all registers in REGSET.  */
-
-static void
-shnbsd_supply_gregset (const struct regset *regset,
-		       struct regcache *regcache,
-		       int regnum, const void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  const gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
-			 regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_supply (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_supply (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* Collect register REGNUM in the general-purpose register set
-   REGSET. from register cache REGCACHE into the buffer specified by
-   GREGS and LEN.  If REGNUM is -1, do this for all registers in
-   REGSET.  */
-
-static void
-shnbsd_collect_gregset (const struct regset *regset,
-			const struct regcache *regcache,
-			int regnum, void *gregs, size_t len)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  gdb_byte *regs = gregs;
-  int i;
-
-  gdb_assert (len >= SHNBSD_SIZEOF_GREGS);
-
-  if (regnum == gdbarch_pc_regnum (gdbarch) || regnum == -1)
-    regcache_raw_collect (regcache, gdbarch_pc_regnum (gdbarch),
-			  regs + (0 * 4));
-
-  if (regnum == SR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, SR_REGNUM, regs + (1 * 4));
-
-  if (regnum == PR_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, PR_REGNUM, regs + (2 * 4));
-
-  if (regnum == MACH_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACH_REGNUM, regs + (3 * 4));
-
-  if (regnum == MACL_REGNUM || regnum == -1)
-    regcache_raw_collect (regcache, MACL_REGNUM, regs + (4 * 4));
-
-  for (i = R0_REGNUM; i <= (R0_REGNUM + 15); i++)
-    {
-      if (regnum == i || regnum == -1)
-	regcache_raw_collect (regcache, i, regs + regmap[i - R0_REGNUM]);
-    }
-}
-
-/* SH register sets.  */
-
-static struct regset shnbsd_gregset =
-{
-  NULL,
-  shnbsd_supply_gregset,
-  shnbsd_collect_gregset
-};
-
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
-
-static const struct regset *
-shnbsd_regset_from_core_section (struct gdbarch *gdbarch,
-				 const char *sect_name, size_t sect_size)
-{
-  if (strcmp (sect_name, ".reg") == 0 && sect_size >= SHNBSD_SIZEOF_GREGS)
-    return &shnbsd_gregset;
-
-  return NULL;
-}
-
-void
-shnbsd_supply_reg (struct regcache *regcache, const char *regs, int regnum)
-{
-  shnbsd_supply_gregset (&shnbsd_gregset, regcache, regnum,
-			 regs, SHNBSD_SIZEOF_GREGS);
-}
-
-void
-shnbsd_fill_reg (const struct regcache *regcache, char *regs, int regnum)
-{
-  shnbsd_collect_gregset (&shnbsd_gregset, regcache, regnum,
-			  regs, SHNBSD_SIZEOF_GREGS);
-}
 \f
 
 static void
 shnbsd_init_abi (struct gdbarch_info info,
                   struct gdbarch *gdbarch)
 {
-  set_gdbarch_regset_from_core_section
-    (gdbarch, shnbsd_regset_from_core_section);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  tdep->core_gregmap = (struct sh_corefile_regmap *)regmap;
 
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
diff --git a/src/gdb-mainline/gdb/shnbsd-tdep.h b/src/gdb-mainline/gdb/shnbsd-tdep.h
deleted file mode 100644
index 0443c97..0000000
--- a/src/gdb-mainline/gdb/shnbsd-tdep.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Target-dependent definitions for SuperH running NetBSD, for GDB.
-   Copyright (C) 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Wasabi Systems, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef SH_NBSD_TDEP_H
-#define SH_NBSD_TDEP_H
-
-void shnbsd_supply_reg (struct regcache *, const char *, int);
-void shnbsd_fill_reg (const struct regcache *, char *, int);
-
-#endif /* SH_NBSD_TDEP_H */

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

end of thread, other threads:[~2009-10-21 14:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-12 14:26 [PATCH][SH] Implement core-file support for sh-linux Andrew Stubbs
2009-10-14  4:56 ` Joel Brobecker
2009-10-15 13:27   ` Andrew Stubbs
2009-10-15 16:20     ` Joel Brobecker
2009-10-19 17:27       ` Andrew Stubbs
2009-10-19 19:33         ` Joel Brobecker
2009-10-21 14:18           ` Andrew Stubbs

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