summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/gdb
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2005-03-29 17:17:21 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2005-03-29 17:17:21 +0000
commitef2a67c27238d6fea4459f14ad44855201f23139 (patch)
tree2fa123cbe27c78731bc37673d0a3665db9d8e8bb /gnu/usr.bin/binutils/gdb
parent84d1e2770a9fda82e64456c846055bd0102575ed (diff)
StackGhost support for sparc64.
Diffstat (limited to 'gnu/usr.bin/binutils/gdb')
-rw-r--r--gnu/usr.bin/binutils/gdb/sparc-nat.c19
-rw-r--r--gnu/usr.bin/binutils/gdb/sparc-tdep.c20
-rw-r--r--gnu/usr.bin/binutils/gdb/sparc64-tdep.c24
-rw-r--r--gnu/usr.bin/binutils/gdb/sparc64nbsd-tdep.c34
4 files changed, 87 insertions, 10 deletions
diff --git a/gnu/usr.bin/binutils/gdb/sparc-nat.c b/gnu/usr.bin/binutils/gdb/sparc-nat.c
index a3836ce892e..4bd7b725384 100644
--- a/gnu/usr.bin/binutils/gdb/sparc-nat.c
+++ b/gnu/usr.bin/binutils/gdb/sparc-nat.c
@@ -305,6 +305,23 @@ sparc_xfer_wcookie (struct target_ops *ops, enum target_object object,
memcpy (readbuf, buf + offset, len);
return len;
}
+
+LONGEST (*inf_ptrace_xfer_partial) (struct target_ops *, enum target_object,
+ const char *, void *, const void *,
+ ULONGEST, LONGEST);
+
+static LONGEST
+sparc_xfer_partial (struct target_ops *ops, enum target_object object,
+ const char *annex, void *readbuf, const void *writebuf,
+ ULONGEST offset, LONGEST len)
+{
+ if (object == TARGET_OBJECT_WCOOKIE)
+ return sparc_xfer_wcookie (ops, object, annex, readbuf, writebuf,
+ offset, len);
+
+ return inf_ptrace_xfer_partial (ops, object, annex, readbuf, writebuf,
+ offset, len);
+}
/* Create a prototype generic SPARC target. The client can override
it with local methods. */
@@ -317,6 +334,8 @@ sparc_target (void)
t = inf_ptrace_target ();
t->to_fetch_registers = fetch_inferior_registers;
t->to_store_registers = store_inferior_registers;
+ inf_ptrace_xfer_partial = t->to_xfer_partial;
+ t->to_xfer_partial = sparc_xfer_partial;
return t;
}
diff --git a/gnu/usr.bin/binutils/gdb/sparc-tdep.c b/gnu/usr.bin/binutils/gdb/sparc-tdep.c
index 7fbd9de62b0..05b42aca59c 100644
--- a/gnu/usr.bin/binutils/gdb/sparc-tdep.c
+++ b/gnu/usr.bin/binutils/gdb/sparc-tdep.c
@@ -1211,6 +1211,16 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
if (regnum == i || regnum == -1)
{
target_read_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf, 8);
+
+ /* Handle StackGhost. */
+ if (i == SPARC_I7_REGNUM)
+ {
+ ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+
+ store_unsigned_integer (buf + offset, 8, i7 ^ wcookie);
+ }
+
regcache_raw_supply (regcache, i, buf);
}
}
@@ -1269,6 +1279,16 @@ sparc_collect_rwindow (const struct regcache *regcache,
if (regnum == -1 || regnum == SPARC_SP_REGNUM || regnum == i)
{
regcache_raw_collect (regcache, i, buf);
+
+ /* Handle StackGhost. */
+ if (i == SPARC_I7_REGNUM)
+ {
+ ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+
+ store_unsigned_integer (buf, 8, i7 ^ wcookie);
+ }
+
target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf, 8);
}
}
diff --git a/gnu/usr.bin/binutils/gdb/sparc64-tdep.c b/gnu/usr.bin/binutils/gdb/sparc64-tdep.c
index a4398d57adb..94dc9c12201 100644
--- a/gnu/usr.bin/binutils/gdb/sparc64-tdep.c
+++ b/gnu/usr.bin/binutils/gdb/sparc64-tdep.c
@@ -519,6 +519,30 @@ sparc64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
return;
}
+ /* Handle StackGhost. */
+ {
+ ULONGEST wcookie = sparc_fetch_wcookie ();
+
+ if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
+ {
+ *optimizedp = 0;
+ *lvalp = not_lval;
+ *addrp = 0;
+ *realnump = -1;
+ if (valuep)
+ {
+ CORE_ADDR addr =
+ cache->base + BIAS + (regnum - SPARC_L0_REGNUM) * 8;
+ ULONGEST i7;
+
+ /* Read the value in from memory. */
+ i7 = get_frame_memory_unsigned (next_frame, addr, 8);
+ store_unsigned_integer (valuep, 8, i7 ^ wcookie);
+ }
+ return;
+ }
+ }
+
/* The previous frame's `local' and `in' registers have been saved
in the register save area. */
if (!cache->frameless_p
diff --git a/gnu/usr.bin/binutils/gdb/sparc64nbsd-tdep.c b/gnu/usr.bin/binutils/gdb/sparc64nbsd-tdep.c
index 8e7987008e7..be6aceb63dd 100644
--- a/gnu/usr.bin/binutils/gdb/sparc64nbsd-tdep.c
+++ b/gnu/usr.bin/binutils/gdb/sparc64nbsd-tdep.c
@@ -28,6 +28,7 @@
#include "regcache.h"
#include "regset.h"
#include "symtab.h"
+#include "objfiles.h"
#include "solib-svr4.h"
#include "trad-frame.h"
@@ -57,7 +58,7 @@ sparc64nbsd_supply_gregset (const struct regset *regset,
struct regcache *regcache,
int regnum, const void *gregs, size_t len)
{
- sparc64_supply_gregset (regset->descr, regcache, regnum, gregs);
+ sparc64_supply_gregset (&sparc64nbsd_gregset, regcache, regnum, gregs);
}
static void
@@ -132,6 +133,20 @@ sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
regnum <= SPARC_I7_REGNUM; regnum++, addr += 8)
saved_regs[regnum].addr = addr;
+ /* Handle StackGhost. */
+ {
+ ULONGEST wcookie = sparc_fetch_wcookie ();
+
+ if (wcookie != 0)
+ {
+ ULONGEST i7;
+
+ addr = saved_regs[SPARC_I7_REGNUM].addr;
+ i7 = get_frame_memory_unsigned (next_frame, addr, 8);
+ trad_frame_set_value (saved_regs, SPARC_I7_REGNUM, i7 ^ wcookie);
+ }
+ }
+
/* TODO: Handle the floating-point registers. */
return saved_regs;
@@ -193,8 +208,8 @@ sparc64nbsd_sigcontext_frame_prev_register (struct frame_info *next_frame,
struct sparc_frame_cache *cache =
sparc64nbsd_sigcontext_frame_cache (next_frame, this_cache);
- trad_frame_prev_register (next_frame, cache->saved_regs, regnum,
- optimizedp, lvalp, addrp, realnump, valuep);
+ trad_frame_get_prev_register (next_frame, cache->saved_regs, regnum,
+ optimizedp, lvalp, addrp, realnump, valuep);
}
static const struct frame_unwind sparc64nbsd_sigcontext_frame_unwind =
@@ -226,22 +241,21 @@ sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- tdep->gregset = XMALLOC (struct regset);
- tdep->gregset->descr = &sparc64nbsd_gregset;
- tdep->gregset->supply_regset = sparc64nbsd_supply_gregset;
+ tdep->gregset = regset_alloc (gdbarch, sparc64nbsd_supply_gregset, NULL);
tdep->sizeof_gregset = 160;
- tdep->fpregset = XMALLOC (struct regset);
- tdep->fpregset->supply_regset = sparc64nbsd_supply_fpregset;
+ tdep->fpregset = regset_alloc (gdbarch, sparc64nbsd_supply_fpregset, NULL);
tdep->sizeof_fpregset = 272;
- set_gdbarch_pc_in_sigtramp (gdbarch, sparc64nbsd_pc_in_sigtramp);
frame_unwind_append_sniffer (gdbarch, sparc64nbsd_sigtramp_frame_sniffer);
sparc64_init_abi (info, gdbarch);
+ /* NetBSD/sparc64 has SVR4-style shared libraries... */
+ set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
+ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_solib_svr4_fetch_link_map_offsets
- (gdbarch, nbsd_lp64_solib_svr4_fetch_link_map_offsets);
+ (gdbarch, svr4_lp64_fetch_link_map_offsets);
}