Index: gdb/sparc-ravenscar-thread.c |
diff --git a/gdb/ravenscar-sparc-thread.c b/gdb/sparc-ravenscar-thread.c |
similarity index 84% |
rename from gdb/ravenscar-sparc-thread.c |
rename to gdb/sparc-ravenscar-thread.c |
index 9132109d62bedf6c502837c465ecb5cf00510691..d27514fc7f5259f90782ec83afa2c3be183ba109 100644 |
--- a/gdb/ravenscar-sparc-thread.c |
+++ b/gdb/sparc-ravenscar-thread.c |
@@ -1,6 +1,6 @@ |
/* Ravenscar SPARC target support. |
- Copyright 2004, 2010-2012 Free Software Foundation, Inc. |
+ Copyright (C) 2004-2013 Free Software Foundation, Inc. |
This file is part of GDB. |
@@ -23,14 +23,13 @@ |
#include "sparc-tdep.h" |
#include "inferior.h" |
#include "ravenscar-thread.h" |
+#include "sparc-ravenscar-thread.h" |
-static struct ravenscar_arch_ops ravenscar_sparc_ops; |
- |
-static void ravenscar_sparc_fetch_registers (struct regcache *regcache, |
+static void sparc_ravenscar_fetch_registers (struct regcache *regcache, |
int regnum); |
-static void ravenscar_sparc_store_registers (struct regcache *regcache, |
+static void sparc_ravenscar_store_registers (struct regcache *regcache, |
int regnum); |
-static void ravenscar_sparc_prepare_to_store (struct regcache *regcache); |
+static void sparc_ravenscar_prepare_to_store (struct regcache *regcache); |
/* Register offsets from a referenced address (exempli gratia the |
Thread_Descriptor). The referenced address depends on the register |
@@ -65,9 +64,9 @@ supply_register_at_address (struct regcache *regcache, int regnum, |
{ |
struct gdbarch *gdbarch = get_regcache_arch (regcache); |
int buf_size = register_size (gdbarch, regnum); |
- char *buf; |
+ gdb_byte *buf; |
- buf = (char *) alloca (buf_size); |
+ buf = alloca (buf_size); |
read_memory (register_addr, buf, buf_size); |
regcache_raw_supply (regcache, regnum, buf); |
} |
@@ -102,7 +101,7 @@ register_in_thread_descriptor_p (int regnum) |
thread. */ |
static void |
-ravenscar_sparc_fetch_registers (struct regcache *regcache, int regnum) |
+sparc_ravenscar_fetch_registers (struct regcache *regcache, int regnum) |
{ |
struct gdbarch *gdbarch = get_regcache_arch (regcache); |
const int sp_regnum = gdbarch_sp_regnum (gdbarch); |
@@ -112,12 +111,16 @@ ravenscar_sparc_fetch_registers (struct regcache *regcache, int regnum) |
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)) |
@@ -141,7 +144,7 @@ ravenscar_sparc_fetch_registers (struct regcache *regcache, int regnum) |
thread. */ |
static void |
-ravenscar_sparc_prepare_to_store (struct regcache *regcache) |
+sparc_ravenscar_prepare_to_store (struct regcache *regcache) |
{ |
/* Nothing to do. */ |
} |
@@ -150,11 +153,11 @@ ravenscar_sparc_prepare_to_store (struct regcache *regcache) |
thread. */ |
static void |
-ravenscar_sparc_store_registers (struct regcache *regcache, int regnum) |
+sparc_ravenscar_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]; |
+ gdb_byte buf[buf_size]; |
ULONGEST register_address; |
if (register_in_thread_descriptor_p (regnum)) |
@@ -175,14 +178,17 @@ ravenscar_sparc_store_registers (struct regcache *regcache, int regnum) |
buf_size); |
} |
-/* Provide a prototype to silence -Wmissing-prototypes. */ |
-extern void _initialize_ravenscar_sparc (void); |
+static struct ravenscar_arch_ops sparc_ravenscar_ops = |
+{ |
+ sparc_ravenscar_fetch_registers, |
+ sparc_ravenscar_store_registers, |
+ sparc_ravenscar_prepare_to_store |
+}; |
+ |
+/* Register ravenscar_arch_ops in GDBARCH. */ |
void |
-_initialize_ravenscar_sparc (void) |
+register_sparc_ravenscar_ops (struct gdbarch *gdbarch) |
{ |
- ravenscar_sparc_ops.to_fetch_registers = ravenscar_sparc_fetch_registers; |
- ravenscar_sparc_ops.to_store_registers = ravenscar_sparc_store_registers; |
- ravenscar_sparc_ops.to_prepare_to_store = ravenscar_sparc_prepare_to_store; |
- ravenscar_register_arch_ops (&ravenscar_sparc_ops); |
+ set_gdbarch_ravenscar_ops (gdbarch, &sparc_ravenscar_ops); |
} |