aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/Makefile.in5
-rw-r--r--gdb/config/sparc/obsd.mt4
-rw-r--r--gdb/configure.tgt5
-rw-r--r--gdb/sparc-tdep.h5
-rw-r--r--gdb/sparcnbsd-tdep.c100
-rw-r--r--gdb/sparcobsd-tdep.c171
7 files changed, 254 insertions, 50 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0762d14..0c9cc01 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
2004-01-25 Mark Kettenis <kettenis@gnu.org>
+ * sparc-tdep.h (sparc32nbsd_sigcontext_saved_regs): New prototype.
+ * sparcnbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): New
+ function with code split out from
+ sparc32nbsd_sigcontext_frame_cache.
+ (sparc32nbsd_sigcontext_frame_cache): Use
+ sparc32nbsd_sigcontext_saved_regs.
+ (_initialize_sparc32nbsd_tdep): Don't register OS ABI handler for
+ OpenBSD.
+ * sparcobsd-tdep.c: New file.
+ * Makefile.in (ALLDEPFILES): Add sparcobsd-tdep.c.
+ (sparcobsd-tdep.o): New dependency.
+ * configure.tgt (sparc-*-openbsd*): Set gdb_target to obsd.
+ * config/sparc/obsd.mt: New file.
+
* sparc-tdep.c (sparc32_gdbarch_init): Don't require
TDEP->fpregset to be initialized to enable core file register
sets.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 5883f80..55bfc4b 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1328,7 +1328,7 @@ ALLDEPFILES = \
sparc64-linux-tdep.c sparc64-nat.c sparc64-sol2-tdep.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 \
+ sparcnbsd-nat.c sparcnbsd-tdep.c sparcobsd-tdep.c \
sun3-nat.c \
symm-tdep.c symm-nat.c \
vax-tdep.c \
@@ -2386,6 +2386,9 @@ sparcnbsd-tdep.o: sparcnbsd-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
$(frame_unwind_h) $(gdbcore_h) $(osabi_h) $(regcache_h) $(regset_h) \
$(solib_svr4_h) $(symtab_h) $(trad_frame_h) $(gdb_assert_h) \
$(gdb_string_h) $(sparc_tdep_h) $(nbsd_tdep_h)
+sparcobsd-tdep.o: sparcobsd-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
+ $(frame_unwind_h) $(osabi_h) $(solib_svr4_h) $(symtab_h) \
+ $(trad_frame_h) $(gdb_assert_h) $(sparc_tdep_h) $(nbsd_tdep_h)
sparc-sol2-nat.o: sparc-sol2-nat.c $(defs_h) $(regcache_h) $(gregset_h) \
$(sparc_tdep_h) $(sparc64_tdep_h)
sparc-sol2-tdep.o: sparc-sol2-tdep.c $(defs_h) $(frame_h) $(frame_unwind_h) \
diff --git a/gdb/config/sparc/obsd.mt b/gdb/config/sparc/obsd.mt
new file mode 100644
index 0000000..800cb04
--- /dev/null
+++ b/gdb/config/sparc/obsd.mt
@@ -0,0 +1,4 @@
+# Target: OpenBSD/sparc
+TDEPFILES= sparc-tdep.o sparcnbsd-tdep.o sparcobsd-tdep.o nbsd-tdep.o \
+ corelow.o solib.o solib-svr4.o
+TM_FILE= tm-nbsd.h
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 23863e5..ef9484c 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -38,8 +38,7 @@ esac
case "${target}" in
x86_64-*-freebsd*) gdb_target=fbsd64 ;;
-*-*-freebsd*) gdb_target=fbsd
- ;;
+*-*-freebsd*) gdb_target=fbsd ;;
alpha*-*-osf*) gdb_target=alpha-osf1 ;;
alpha*-*-linux*) gdb_target=alpha-linux ;;
@@ -190,7 +189,7 @@ sparc-*-linux*) gdb_target=linux ;;
sparc64-*-linux*) gdb_target=linux64 ;;
sparc-*-netbsd*) gdb_target=nbsd ;;
sparc64-*-netbsd*) gdb_target=nbsd64 ;;
-sparc-*-openbsd*) gdb_target=nbsd ;;
+sparc-*-openbsd*) gdb_target=obsd ;;
sparc64-*-openbsd*) gdb_target=obsd64
gdb_osabi=GDB_OSABI_OPENBSD_ELF
;;
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index d8d0582..00c4136 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -22,11 +22,11 @@
#ifndef SPARC_TDEP_H
#define SPARC_TDEP_H 1
+struct frame_info;
struct gdbarch;
struct regcache;
struct regset;
struct trad_frame_saved_reg;
-struct frame_info;
/* Register offsets for the general-purpose register set. */
@@ -195,4 +195,7 @@ extern void sparc32_sol2_init_abi (struct gdbarch_info info,
/* Register offsets for NetBSD. */
extern const struct sparc_gregset sparc32nbsd_gregset;
+extern struct trad_frame_saved_reg *
+ sparc32nbsd_sigcontext_saved_regs (struct frame_info *next_frame);
+
#endif /* sparc-tdep.h */
diff --git a/gdb/sparcnbsd-tdep.c b/gdb/sparcnbsd-tdep.c
index 631697c..21b3aca 100644
--- a/gdb/sparcnbsd-tdep.c
+++ b/gdb/sparcnbsd-tdep.c
@@ -90,92 +90,104 @@ sparc32nbsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
return nbsd_pc_in_sigtramp (pc, name);
}
-static struct sparc_frame_cache *
-sparc32nbsd_sigcontext_frame_cache (struct frame_info *next_frame,
- void **this_cache)
+struct trad_frame_saved_reg *
+sparc32nbsd_sigcontext_saved_regs (struct frame_info *next_frame)
{
- struct sparc_frame_cache *cache;
+ struct trad_frame_saved_reg *saved_regs;
CORE_ADDR addr, sigcontext_addr;
- LONGEST psr;
int regnum, delta;
+ ULONGEST psr;
- if (*this_cache)
- return *this_cache;
+ saved_regs = trad_frame_alloc_saved_regs (next_frame);
- cache = sparc_frame_cache (next_frame, this_cache);
- gdb_assert (cache == *this_cache);
+ /* We find the appropriate instance of `struct sigcontext' at a
+ fixed offset in the signal frame. */
+ addr = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
+ sigcontext_addr = addr + 64 + 16;
/* The registers are saved in bits and pieces scattered all over the
place. The code below records their location on the assumption
that the part of the signal trampoline that saves the state has
been executed. */
- /* If we couldn't find the frame's function, we're probably dealing
- with an on-stack signal trampoline. */
- if (cache->pc == 0)
- {
- cache->pc = sparc32nbsd_sigtramp_start;
-
- /* Since we couldn't find the frame's function, the cache was
- initialized under the assumption that we're frameless. */
- cache->frameless_p = 0;
- addr = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
- cache->base = addr;
- }
-
- cache->saved_regs = trad_frame_alloc_saved_regs (next_frame);
-
- /* We find the appropriate instance of `struct sigcontext' at a
- fixed offset in the signal frame. */
- sigcontext_addr = cache->base + 64 + 16;
-
- cache->saved_regs[SPARC_SP_REGNUM].addr = sigcontext_addr + 8;
- cache->saved_regs[SPARC32_PC_REGNUM].addr = sigcontext_addr + 12;
- cache->saved_regs[SPARC32_NPC_REGNUM].addr = sigcontext_addr + 16;
- cache->saved_regs[SPARC32_PSR_REGNUM].addr = sigcontext_addr + 20;
- cache->saved_regs[SPARC_G1_REGNUM].addr = sigcontext_addr + 24;
- cache->saved_regs[SPARC_O0_REGNUM].addr = sigcontext_addr + 28;
+ saved_regs[SPARC_SP_REGNUM].addr = sigcontext_addr + 8;
+ saved_regs[SPARC32_PC_REGNUM].addr = sigcontext_addr + 12;
+ saved_regs[SPARC32_NPC_REGNUM].addr = sigcontext_addr + 16;
+ saved_regs[SPARC32_PSR_REGNUM].addr = sigcontext_addr + 20;
+ saved_regs[SPARC_G1_REGNUM].addr = sigcontext_addr + 24;
+ saved_regs[SPARC_O0_REGNUM].addr = sigcontext_addr + 28;
/* The remaining `global' registers and %y are saved in the `local'
registers. */
delta = SPARC_L0_REGNUM - SPARC_G0_REGNUM;
for (regnum = SPARC_G2_REGNUM; regnum <= SPARC_G7_REGNUM; regnum++)
- cache->saved_regs[regnum].realreg = regnum + delta;
- cache->saved_regs[SPARC32_Y_REGNUM].realreg = SPARC_L1_REGNUM;
+ saved_regs[regnum].realreg = regnum + delta;
+ saved_regs[SPARC32_Y_REGNUM].realreg = SPARC_L1_REGNUM;
/* The remaining `out' registers can be found in the current frame's
`in' registers. */
delta = SPARC_I0_REGNUM - SPARC_O0_REGNUM;
for (regnum = SPARC_O1_REGNUM; regnum <= SPARC_O5_REGNUM; regnum++)
- cache->saved_regs[regnum].realreg = regnum + delta;
- cache->saved_regs[SPARC_O7_REGNUM].realreg = SPARC_I7_REGNUM;
+ saved_regs[regnum].realreg = regnum + delta;
+ saved_regs[SPARC_O7_REGNUM].realreg = SPARC_I7_REGNUM;
/* The `local' and `in' registers have been saved in the register
save area. */
- addr = cache->saved_regs[SPARC_SP_REGNUM].addr;
+ addr = saved_regs[SPARC_SP_REGNUM].addr;
addr = get_frame_memory_unsigned (next_frame, addr, 4);
for (regnum = SPARC_L0_REGNUM;
regnum <= SPARC_I7_REGNUM; regnum++, addr += 4)
- cache->saved_regs[regnum].addr = addr;
+ saved_regs[regnum].addr = addr;
/* The floating-point registers are only saved if the EF bit in %prs
has been set. */
#define PSR_EF 0x00001000
- addr = cache->saved_regs[SPARC32_PSR_REGNUM].addr;
+ addr = saved_regs[SPARC32_PSR_REGNUM].addr;
psr = get_frame_memory_unsigned (next_frame, addr, 4);
if (psr & PSR_EF)
{
CORE_ADDR sp;
sp = frame_unwind_register_unsigned (next_frame, SPARC_SP_REGNUM);
- cache->saved_regs[SPARC32_FSR_REGNUM].addr = sp + 96;
+ saved_regs[SPARC32_FSR_REGNUM].addr = sp + 96;
for (regnum = SPARC_F0_REGNUM, addr = sp + 96 + 8;
regnum <= SPARC_F31_REGNUM; regnum++, addr += 4)
- cache->saved_regs[regnum].addr = addr;
+ saved_regs[regnum].addr = addr;
+ }
+
+ return saved_regs;
+}
+
+static struct sparc_frame_cache *
+sparc32nbsd_sigcontext_frame_cache (struct frame_info *next_frame,
+ void **this_cache)
+{
+ struct sparc_frame_cache *cache;
+ CORE_ADDR addr;
+
+ if (*this_cache)
+ return *this_cache;
+
+ cache = sparc_frame_cache (next_frame, this_cache);
+ gdb_assert (cache == *this_cache);
+
+ /* If we couldn't find the frame's function, we're probably dealing
+ with an on-stack signal trampoline. */
+ if (cache->pc == 0)
+ {
+ cache->pc = sparc32nbsd_sigtramp_start;
+
+ /* Since we couldn't find the frame's function, the cache was
+ initialized under the assumption that we're frameless. */
+ cache->frameless_p = 0;
+ addr = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
+ cache->base = addr;
}
+ cache->saved_regs = sparc32nbsd_sigcontext_saved_regs (next_frame);
+
return cache;
}
@@ -325,6 +337,4 @@ _initialize_sparnbsd_tdep (void)
sparc32nbsd_aout_init_abi);
gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_NETBSD_ELF,
sparc32nbsd_elf_init_abi);
- gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_OPENBSD_ELF,
- sparc32nbsd_elf_init_abi);
}
diff --git a/gdb/sparcobsd-tdep.c b/gdb/sparcobsd-tdep.c
new file mode 100644
index 0000000..108e255
--- /dev/null
+++ b/gdb/sparcobsd-tdep.c
@@ -0,0 +1,171 @@
+/* Target-dependent code for OpenBSD/sparc.
+
+ Copyright 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "floatformat.h"
+#include "frame.h"
+#include "frame-unwind.h"
+#include "osabi.h"
+#include "solib-svr4.h"
+#include "symtab.h"
+#include "trad-frame.h"
+
+#include "gdb_assert.h"
+
+#include "sparc-tdep.h"
+#include "nbsd-tdep.h"
+
+/* Signal trampolines. */
+
+/* The OpenBSD kernel maps the signal trampoline at some random
+ location in user space, which means that the traditional BSD way of
+ detecting it won't work.
+
+ The signal trampoline will be mapped at an address that is page
+ aligned. We recognize the signal trampoline by the looking for the
+ sigreturn system call. */
+
+static const int sparc32obsd_page_size = 4096;
+
+static int
+sparc32obsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+{
+ CORE_ADDR start_pc = (pc & ~(sparc32obsd_page_size - 1));
+ unsigned long insn;
+
+ if (name)
+ return 0;
+
+ /* Check for "restore %g0, SYS_sigreturn, %g1". */
+ insn = sparc_fetch_instruction (start_pc + 0xec);
+ if (insn != 0x83e82067)
+ return 0;
+
+ /* Check for "t ST_SYSCALL". */
+ insn = sparc_fetch_instruction (start_pc + 0xf4);
+ if (insn != 0x91d02000)
+ return 0;
+
+ return 1;
+}
+
+static struct sparc_frame_cache *
+sparc32obsd_frame_cache (struct frame_info *next_frame, void **this_cache)
+{
+ struct sparc_frame_cache *cache;
+ CORE_ADDR addr;
+
+ if (*this_cache)
+ return *this_cache;
+
+ cache = sparc_frame_cache (next_frame, this_cache);
+ gdb_assert (cache == *this_cache);
+
+ /* If we couldn't find the frame's function, we're probably dealing
+ with an on-stack signal trampoline. */
+ if (cache->pc == 0)
+ {
+ cache->pc = frame_pc_unwind (next_frame);
+ cache->pc &= ~(sparc32obsd_page_size - 1);
+
+ /* Since we couldn't find the frame's function, the cache was
+ initialized under the assumption that we're frameless. */
+ cache->frameless_p = 0;
+ addr = frame_unwind_register_unsigned (next_frame, SPARC_FP_REGNUM);
+ cache->base = addr;
+ }
+
+ cache->saved_regs = sparc32nbsd_sigcontext_saved_regs (next_frame);
+
+ return cache;
+}
+
+static void
+sparc32obsd_frame_this_id (struct frame_info *next_frame, void **this_cache,
+ struct frame_id *this_id)
+{
+ struct sparc_frame_cache *cache =
+ sparc32obsd_frame_cache (next_frame, this_cache);
+
+ (*this_id) = frame_id_build (cache->base, cache->pc);
+}
+
+static void
+sparc32obsd_frame_prev_register (struct frame_info *next_frame,
+ void **this_cache,
+ int regnum, int *optimizedp,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnump, void *valuep)
+{
+ struct sparc_frame_cache *cache =
+ sparc32obsd_frame_cache (next_frame, this_cache);
+
+ trad_frame_prev_register (next_frame, cache->saved_regs, regnum,
+ optimizedp, lvalp, addrp, realnump, valuep);
+}
+
+static const struct frame_unwind sparc32obsd_frame_unwind =
+{
+ SIGTRAMP_FRAME,
+ sparc32obsd_frame_this_id,
+ sparc32obsd_frame_prev_register
+};
+
+static const struct frame_unwind *
+sparc32obsd_sigtramp_frame_sniffer (struct frame_info *next_frame)
+{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+ char *name;
+
+ find_pc_partial_function (pc, &name, NULL, NULL);
+ if (sparc32obsd_pc_in_sigtramp (pc, name))
+ return &sparc32obsd_frame_unwind;
+
+ return NULL;
+}
+
+
+static void
+sparc32obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ /* OpenBSD doesn't support the 128-bit `long double' from the psABI. */
+ set_gdbarch_long_double_bit (gdbarch, 64);
+ set_gdbarch_long_double_format (gdbarch, &floatformat_ieee_double_big);
+
+ set_gdbarch_pc_in_sigtramp (gdbarch, sparc32obsd_pc_in_sigtramp);
+ frame_unwind_append_sniffer (gdbarch, sparc32obsd_sigtramp_frame_sniffer);
+
+ set_solib_svr4_fetch_link_map_offsets
+ (gdbarch, nbsd_ilp32_solib_svr4_fetch_link_map_offsets);
+}
+
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+void _initialize_sparc32obsd_tdep (void);
+
+void
+_initialize_sparc32obsd_tdep (void)
+{
+ gdbarch_register_osabi (bfd_arch_sparc, 0, GDB_OSABI_OPENBSD_ELF,
+ sparc32obsd_init_abi);
+}