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

[commit 3/6] Rename ravenscar-sparc-thread.[hc] into sparc-ravenscar-thread.[hc].


First of renaming the arch-specific file: We rename the files, but
otherwise try to keep them as unchanged as possible.  The code changes
inside to reflect the new file names will be done as a followup step.

gdb/ChangeLog:

        * sparc-ravenscar-thread.h: Renames ravenscar-sparc-thread.h.
        * sparc-ravenscar-thread.c: Renames ravenscar-sparc-thread.c.
        Adjust sparc-ravenscar-thread.h #include.
        * sparc-tdep.c: Adjust sparc-ravenscar-thread.h #include
        accordingly.
        * Makefile.in: Replace ravenscar-sparc-thread with
        sparc-ravenscar-thread throughout.
        * configure.tgt: Likewise.
---
 gdb/ChangeLog                |   11 +++
 gdb/Makefile.in              |    6 +-
 gdb/configure.tgt            |   22 ++---
 gdb/ravenscar-sparc-thread.c |  194 ------------------------------------------
 gdb/ravenscar-sparc-thread.h |   26 ------
 gdb/sparc-ravenscar-thread.c |  194 ++++++++++++++++++++++++++++++++++++++++++
 gdb/sparc-ravenscar-thread.h |   26 ++++++
 gdb/sparc-tdep.c             |    2 +-
 8 files changed, 246 insertions(+), 235 deletions(-)
 delete mode 100644 gdb/ravenscar-sparc-thread.c
 delete mode 100644 gdb/ravenscar-sparc-thread.h
 create mode 100644 gdb/sparc-ravenscar-thread.c
 create mode 100644 gdb/sparc-ravenscar-thread.h

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a35f122..c403ecc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
 2012-12-15  Joel Brobecker  <brobecker@adacore.com>
 
+	* sparc-ravenscar-thread.h: Renames ravenscar-sparc-thread.h.
+	* sparc-ravenscar-thread.c: Renames ravenscar-sparc-thread.c.
+	Adjust sparc-ravenscar-thread.h #include.
+	* sparc-tdep.c: Adjust sparc-ravenscar-thread.h #include
+	accordingly.
+	* Makefile.in: Replace ravenscar-sparc-thread with
+	sparc-ravenscar-thread throughout.
+	* configure.tgt: Likewise.
+
+2012-12-15  Joel Brobecker  <brobecker@adacore.com>
+
 	* gdbarch.sh: Add "struct ravenscar_arch_ops" advance
 	declaration.
 	(ravenscar_ops): New gdbarch variable.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 3c83a0e..a646e64 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -570,7 +570,7 @@ ALL_TARGET_OBS = \
 	score-tdep.o \
 	sh64-tdep.o sh-linux-tdep.o shnbsd-tdep.o sh-tdep.o \
 	sparc-linux-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o \
-	sparc-sol2-tdep.o sparc-tdep.o ravenscar-sparc-thread.o \
+	sparc-sol2-tdep.o sparc-tdep.o sparc-ravenscar-thread.o \
 	spu-tdep.o spu-multiarch.o solib-spu.o \
 	tic6x-tdep.o tic6x-linux-tdep.o \
 	tilegx-tdep.o tilegx-linux-tdep.o \
@@ -831,7 +831,7 @@ gnulib/import/stddef.in.h gnulib/import/inttypes.in.h inline-frame.h skip.h \
 common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \
 common/format.h common/host-defs.h utils.h common/queue.h \
 common/linux-osdata.h gdb-dlfcn.h auto-load.h probe.h stap-probe.h \
-gdb_bfd.h ravenscar-sparc-thread.h
+gdb_bfd.h sparc-ravenscar-thread.h
 
 # Header files that already have srcdir in them, or which are in objdir.
 
@@ -1501,7 +1501,7 @@ ALLDEPFILES = \
 	sparc64-nat.c sparc64-tdep.c sparc64fbsd-nat.c sparc64fbsd-tdep.c \
 	sparc64nbsd-nat.c sparc64nbsd-tdep.c sparc64obsd-tdep.c \
 	sparcnbsd-nat.c sparcnbsd-tdep.c sparcobsd-tdep.c \
-	ravenscar-sparc-thread.c \
+	sparc-ravenscar-thread.c \
 	spu-linux-nat.c spu-tdep.c spu-multiarch.c solib-spu.c \
 	tilegx-linux-nat.c tilegx-tdep.c tilegx-linux-tdep.c \
 	v850-tdep.c \
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index c13bd97..856b998 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -476,7 +476,7 @@ sparc-*-linux*)
 	gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \
 			sparc-linux-tdep.o solib-svr4.o symfile-mem.o \
 			linux-tdep.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	if test "x$enable_64_bit_bfd" = "xyes"; then
 	    # Target: GNU/Linux UltraSPARC
 	    gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o \
@@ -489,62 +489,62 @@ sparc64-*-linux*)
 	gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sol2-tdep.o \
 			sparc64-linux-tdep.o sparc-tdep.o sparc-sol2-tdep.o \
 			sparc-linux-tdep.o solib-svr4.o linux-tdep.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	build_gdbserver=yes
 	;;
 sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
 	# Target: FreeBSD/sparc64
 	gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64fbsd-tdep.o \
 			solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
 	# Target: NetBSD/sparc
 	gdb_target_obs="sparc-tdep.o sparcnbsd-tdep.o nbsd-tdep.o \
 			solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc64-*-netbsd* | sparc64-*-knetbsd*-gnu)
 	# Target: NetBSD/sparc64
 	gdb_target_obs="sparc64-tdep.o sparc64nbsd-tdep.o sparc-tdep.o \
 			sparcnbsd-tdep.o nbsd-tdep.o solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-openbsd*)
 	# Target: OpenBSD/sparc
 	gdb_target_obs="sparc-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o \
 			nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc64-*-openbsd*)
 	# Target: OpenBSD/sparc64
 	gdb_target_obs="sparc64-tdep.o sparc64nbsd-tdep.o sparc64obsd-tdep.o \
 			sparc-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o \
 			nbsd-tdep.o obsd-tdep.o bsd-uthread.o solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*)
 	# Target: Solaris SPARC
 	gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \
 			solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-solaris2* | sparcv9-*-solaris2* | sparc64-*-solaris2*)
 	# Target: Solaris UltraSPARC
 	gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sparc-tdep.o \
 			sparc-sol2-tdep.o sol2-tdep.o solib-svr4.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 sparc-*-*)
 	# Target: SPARC
 	gdb_target_obs="sparc-tdep.o 
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	gdb_sim=../sim/erc32/libsim.a
 	;;
 sparc64-*-*)
 	# Target: UltraSPARC
 	gdb_target_obs="sparc-tdep.o sparc64-tdep.o \
-			ravenscar-thread.o ravenscar-sparc-thread.o"
+			ravenscar-thread.o sparc-ravenscar-thread.o"
 	;;
 
 spu*-*-*)
diff --git a/gdb/ravenscar-sparc-thread.c b/gdb/ravenscar-sparc-thread.c
deleted file mode 100644
index 93888c8..0000000
--- a/gdb/ravenscar-sparc-thread.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/* Ravenscar SPARC target support.
-
-   Copyright 2004, 2010-2012 Free Software Foundation, 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/>.  */
-
-#include "defs.h"
-#include "gdbcore.h"
-#include "regcache.h"
-#include "sparc-tdep.h"
-#include "inferior.h"
-#include "ravenscar-thread.h"
-#include "ravenscar-sparc-thread.h"
-
-static void ravenscar_sparc_fetch_registers (struct regcache *regcache,
-                                             int regnum);
-static void ravenscar_sparc_store_registers (struct regcache *regcache,
-                                             int regnum);
-static void ravenscar_sparc_prepare_to_store (struct regcache *regcache);
-
-/* Register offsets from a referenced address (exempli gratia the
-   Thread_Descriptor).  The referenced address depends on the register
-   number.  The Thread_Descriptor layout and the stack layout are documented
-   in the GNAT sources, in sparc-bb.h.  */
-
-static const int sparc_register_offsets[] =
-{
-  /* G0 - G7 */
-  -1,   0x24, 0x28, 0x2C, 0x30, 0x34, 0x38, 0x3C,
-  /* O0 - O7 */
-  0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x18, 0x1C,
-  /* L0 - L7 */
-  0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x18, 0x1C,
-  /* I0 - I7 */
-  0x20, 0x24, 0x28, 0x2C, 0x30, 0x34, 0x38, 0x3C,
-  /* F0 - F31 */
-  0x50, 0x54, 0x58, 0x5C, 0x60, 0x64, 0x68, 0x6C,
-  0x70, 0x74, 0x78, 0x7C, 0x80, 0x84, 0x88, 0x8C,
-  0x90, 0x94, 0x99, 0x9C, 0xA0, 0xA4, 0xA8, 0xAC,
-  0xB0, 0xB4, 0xBB, 0xBC, 0xC0, 0xC4, 0xC8, 0xCC,
-  /* Y  PSR   WIM   TBR   PC    NPC   FPSR  CPSR */
-  0x40, 0x20, 0x44, -1,   0x1C, -1,   0x4C, -1
-};
-
-/* supply register REGNUM, which has been saved on REGISTER_ADDR, to the
-   regcache.  */
-
-static void
-supply_register_at_address (struct regcache *regcache, int regnum,
-                            CORE_ADDR register_addr)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int buf_size = register_size (gdbarch, regnum);
-  char *buf;
-
-  buf = (char *) alloca (buf_size);
-  read_memory (register_addr, buf, buf_size);
-  regcache_raw_supply (regcache, regnum, buf);
-}
-
-/* Return true if, for a non-running thread, REGNUM has been saved on the
-   stack.  */
-
-static int
-register_on_stack_p (int regnum)
-{
-  return (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM)
-    || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM);
-}
-
-/* Return true if, for a non-running thread, REGNUM has been saved on the
-   Thread_Descriptor.  */
-
-static int
-register_in_thread_descriptor_p (int regnum)
-{
-  return (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM)
-    || (regnum == SPARC32_PSR_REGNUM)
-    || (regnum >= SPARC_G1_REGNUM && regnum <= SPARC_G7_REGNUM)
-    || (regnum == SPARC32_Y_REGNUM)
-    || (regnum == SPARC32_WIM_REGNUM)
-    || (regnum == SPARC32_FSR_REGNUM)
-    || (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F0_REGNUM + 31)
-    || (regnum == SPARC32_PC_REGNUM);
-}
-
-/* to_fetch_registers when inferior_ptid is different from the running
-   thread.  */
-
-static void
-ravenscar_sparc_fetch_registers (struct regcache *regcache, int regnum)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  const int sp_regnum = gdbarch_sp_regnum (gdbarch);
-  const int num_regs = gdbarch_num_regs (gdbarch);
-  int current_regnum;
-  CORE_ADDR current_address;
-  CORE_ADDR thread_descriptor_address;
-  ULONGEST stack_address;
-
-  /* The tid is the thread_id field, which is a pointer to the thread.  */
-  thread_descriptor_address = (CORE_ADDR) ptid_get_tid (inferior_ptid);
-
-  /* Read the saved SP in the context buffer.  */
-  current_address = thread_descriptor_address
-    + sparc_register_offsets [sp_regnum];
-  supply_register_at_address (regcache, sp_regnum, current_address);
-  regcache_cooked_read_unsigned (regcache, sp_regnum, &stack_address);
-
-  /* Read registers.  */
-  for (current_regnum = 0; current_regnum < num_regs; current_regnum ++)
-    {
-      if (register_in_thread_descriptor_p (current_regnum))
-        {
-          current_address = thread_descriptor_address
-            + sparc_register_offsets [current_regnum];
-          supply_register_at_address (regcache, current_regnum,
-                                      current_address);
-        }
-      else if (register_on_stack_p (current_regnum))
-        {
-          current_address = stack_address
-            + sparc_register_offsets [current_regnum];
-          supply_register_at_address (regcache, current_regnum,
-                                      current_address);
-        }
-    }
-}
-
-/* to_prepare_to_store when inferior_ptid is different from the running
-   thread.  */
-
-static void
-ravenscar_sparc_prepare_to_store (struct regcache *regcache)
-{
-  /* Nothing to do.  */
-}
-
-/* to_store_registers when inferior_ptid is different from the running
-   thread.  */
-
-static void
-ravenscar_sparc_store_registers (struct regcache *regcache, int regnum)
-{
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int buf_size = register_size (gdbarch, regnum);
-  char buf [buf_size];
-  ULONGEST register_address;
-
-  if (register_in_thread_descriptor_p (regnum))
-    register_address =
-      ptid_get_tid (inferior_ptid) + sparc_register_offsets [regnum];
-  else if (register_on_stack_p (regnum))
-    {
-      regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM,
-                                     &register_address);
-      register_address += sparc_register_offsets [regnum];
-    }
-  else
-    return;
-
-  regcache_raw_collect (regcache, regnum, buf);
-  write_memory (register_address,
-                buf,
-                buf_size);
-}
-
-static struct ravenscar_arch_ops ravenscar_sparc_ops =
-{
-  ravenscar_sparc_fetch_registers,
-  ravenscar_sparc_store_registers,
-  ravenscar_sparc_prepare_to_store
-};
-
-/* Register ravenscar_arch_ops in GDBARCH.  */
-
-void
-register_sparc_ravenscar_ops (struct gdbarch *gdbarch)
-{
-  set_gdbarch_ravenscar_ops (gdbarch, &ravenscar_sparc_ops);
-}
diff --git a/gdb/ravenscar-sparc-thread.h b/gdb/ravenscar-sparc-thread.h
deleted file mode 100644
index fc86e69..0000000
--- a/gdb/ravenscar-sparc-thread.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Ravenscar SPARC target support.
-
-   Copyright 2012 Free Software Foundation, 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 RAVENSCAR_SPARC_THREAD_H
-#define RAVENSCAR_SPARC_THREAD_H
-
-struct gdbarch;
-
-extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch);
-#endif
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c
new file mode 100644
index 0000000..da80dc8
--- /dev/null
+++ b/gdb/sparc-ravenscar-thread.c
@@ -0,0 +1,194 @@
+/* Ravenscar SPARC target support.
+
+   Copyright 2004, 2010-2012 Free Software Foundation, 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/>.  */
+
+#include "defs.h"
+#include "gdbcore.h"
+#include "regcache.h"
+#include "sparc-tdep.h"
+#include "inferior.h"
+#include "ravenscar-thread.h"
+#include "sparc-ravenscar-thread.h"
+
+static void ravenscar_sparc_fetch_registers (struct regcache *regcache,
+                                             int regnum);
+static void ravenscar_sparc_store_registers (struct regcache *regcache,
+                                             int regnum);
+static void ravenscar_sparc_prepare_to_store (struct regcache *regcache);
+
+/* Register offsets from a referenced address (exempli gratia the
+   Thread_Descriptor).  The referenced address depends on the register
+   number.  The Thread_Descriptor layout and the stack layout are documented
+   in the GNAT sources, in sparc-bb.h.  */
+
+static const int sparc_register_offsets[] =
+{
+  /* G0 - G7 */
+  -1,   0x24, 0x28, 0x2C, 0x30, 0x34, 0x38, 0x3C,
+  /* O0 - O7 */
+  0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x18, 0x1C,
+  /* L0 - L7 */
+  0x00, 0x04, 0x08, 0x0C, 0x10, 0x14, 0x18, 0x1C,
+  /* I0 - I7 */
+  0x20, 0x24, 0x28, 0x2C, 0x30, 0x34, 0x38, 0x3C,
+  /* F0 - F31 */
+  0x50, 0x54, 0x58, 0x5C, 0x60, 0x64, 0x68, 0x6C,
+  0x70, 0x74, 0x78, 0x7C, 0x80, 0x84, 0x88, 0x8C,
+  0x90, 0x94, 0x99, 0x9C, 0xA0, 0xA4, 0xA8, 0xAC,
+  0xB0, 0xB4, 0xBB, 0xBC, 0xC0, 0xC4, 0xC8, 0xCC,
+  /* Y  PSR   WIM   TBR   PC    NPC   FPSR  CPSR */
+  0x40, 0x20, 0x44, -1,   0x1C, -1,   0x4C, -1
+};
+
+/* supply register REGNUM, which has been saved on REGISTER_ADDR, to the
+   regcache.  */
+
+static void
+supply_register_at_address (struct regcache *regcache, int regnum,
+                            CORE_ADDR register_addr)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  int buf_size = register_size (gdbarch, regnum);
+  char *buf;
+
+  buf = (char *) alloca (buf_size);
+  read_memory (register_addr, buf, buf_size);
+  regcache_raw_supply (regcache, regnum, buf);
+}
+
+/* Return true if, for a non-running thread, REGNUM has been saved on the
+   stack.  */
+
+static int
+register_on_stack_p (int regnum)
+{
+  return (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_L7_REGNUM)
+    || (regnum >= SPARC_I0_REGNUM && regnum <= SPARC_I7_REGNUM);
+}
+
+/* Return true if, for a non-running thread, REGNUM has been saved on the
+   Thread_Descriptor.  */
+
+static int
+register_in_thread_descriptor_p (int regnum)
+{
+  return (regnum >= SPARC_O0_REGNUM && regnum <= SPARC_O7_REGNUM)
+    || (regnum == SPARC32_PSR_REGNUM)
+    || (regnum >= SPARC_G1_REGNUM && regnum <= SPARC_G7_REGNUM)
+    || (regnum == SPARC32_Y_REGNUM)
+    || (regnum == SPARC32_WIM_REGNUM)
+    || (regnum == SPARC32_FSR_REGNUM)
+    || (regnum >= SPARC_F0_REGNUM && regnum <= SPARC_F0_REGNUM + 31)
+    || (regnum == SPARC32_PC_REGNUM);
+}
+
+/* to_fetch_registers when inferior_ptid is different from the running
+   thread.  */
+
+static void
+ravenscar_sparc_fetch_registers (struct regcache *regcache, int regnum)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  const int sp_regnum = gdbarch_sp_regnum (gdbarch);
+  const int num_regs = gdbarch_num_regs (gdbarch);
+  int current_regnum;
+  CORE_ADDR current_address;
+  CORE_ADDR thread_descriptor_address;
+  ULONGEST stack_address;
+
+  /* The tid is the thread_id field, which is a pointer to the thread.  */
+  thread_descriptor_address = (CORE_ADDR) ptid_get_tid (inferior_ptid);
+
+  /* Read the saved SP in the context buffer.  */
+  current_address = thread_descriptor_address
+    + sparc_register_offsets [sp_regnum];
+  supply_register_at_address (regcache, sp_regnum, current_address);
+  regcache_cooked_read_unsigned (regcache, sp_regnum, &stack_address);
+
+  /* Read registers.  */
+  for (current_regnum = 0; current_regnum < num_regs; current_regnum ++)
+    {
+      if (register_in_thread_descriptor_p (current_regnum))
+        {
+          current_address = thread_descriptor_address
+            + sparc_register_offsets [current_regnum];
+          supply_register_at_address (regcache, current_regnum,
+                                      current_address);
+        }
+      else if (register_on_stack_p (current_regnum))
+        {
+          current_address = stack_address
+            + sparc_register_offsets [current_regnum];
+          supply_register_at_address (regcache, current_regnum,
+                                      current_address);
+        }
+    }
+}
+
+/* to_prepare_to_store when inferior_ptid is different from the running
+   thread.  */
+
+static void
+ravenscar_sparc_prepare_to_store (struct regcache *regcache)
+{
+  /* Nothing to do.  */
+}
+
+/* to_store_registers when inferior_ptid is different from the running
+   thread.  */
+
+static void
+ravenscar_sparc_store_registers (struct regcache *regcache, int regnum)
+{
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  int buf_size = register_size (gdbarch, regnum);
+  char buf [buf_size];
+  ULONGEST register_address;
+
+  if (register_in_thread_descriptor_p (regnum))
+    register_address =
+      ptid_get_tid (inferior_ptid) + sparc_register_offsets [regnum];
+  else if (register_on_stack_p (regnum))
+    {
+      regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM,
+                                     &register_address);
+      register_address += sparc_register_offsets [regnum];
+    }
+  else
+    return;
+
+  regcache_raw_collect (regcache, regnum, buf);
+  write_memory (register_address,
+                buf,
+                buf_size);
+}
+
+static struct ravenscar_arch_ops ravenscar_sparc_ops =
+{
+  ravenscar_sparc_fetch_registers,
+  ravenscar_sparc_store_registers,
+  ravenscar_sparc_prepare_to_store
+};
+
+/* Register ravenscar_arch_ops in GDBARCH.  */
+
+void
+register_sparc_ravenscar_ops (struct gdbarch *gdbarch)
+{
+  set_gdbarch_ravenscar_ops (gdbarch, &ravenscar_sparc_ops);
+}
diff --git a/gdb/sparc-ravenscar-thread.h b/gdb/sparc-ravenscar-thread.h
new file mode 100644
index 0000000..fc86e69
--- /dev/null
+++ b/gdb/sparc-ravenscar-thread.h
@@ -0,0 +1,26 @@
+/* Ravenscar SPARC target support.
+
+   Copyright 2012 Free Software Foundation, 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 RAVENSCAR_SPARC_THREAD_H
+#define RAVENSCAR_SPARC_THREAD_H
+
+struct gdbarch;
+
+extern void register_sparc_ravenscar_ops (struct gdbarch *gdbarch);
+#endif
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 7dfa7da..42d6f7e 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -39,7 +39,7 @@
 #include "gdb_string.h"
 
 #include "sparc-tdep.h"
-#include "ravenscar-sparc-thread.h"
+#include "sparc-ravenscar-thread.h"
 
 struct regset;
 
-- 
1.7.10.4


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