aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386bsd-tdep.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2001-07-13 18:27:21 +0000
committerMark Kettenis <kettenis@gnu.org>2001-07-13 18:27:21 +0000
commitb724791951f3af34758ac7ea521f5967b3f5e0d8 (patch)
treeb5921d0acb28b33f384c2620deba0d91e72d60c4 /gdb/i386bsd-tdep.c
parentd1bacddc243a8bfd9d0a70eeb7e8e5c86dc1e3ee (diff)
downloadfsf-binutils-gdb-b724791951f3af34758ac7ea521f5967b3f5e0d8.zip
fsf-binutils-gdb-b724791951f3af34758ac7ea521f5967b3f5e0d8.tar.gz
fsf-binutils-gdb-b724791951f3af34758ac7ea521f5967b3f5e0d8.tar.bz2
* i386bsd-nat.c: Include <signal.h>, <stddef.h> and
<sys/sysctl.h>. (store_inferior_registers): Wrap long line. (i386bsd_dr_get_status): Fix typo in comment. (_initialize_i386bsd_nat): New function. * i386bsd-tdep.c: New file. * config/i386/tm-fbsd.h (IN_SIGTRAMP): New define. (i386bsd_in_sigtramp): New prototype. (SIGTRAMP_START, SIGTRAMP_END): Redefine in terms... (i386bsd_sigtramp_start, i386bsd_sigtramp_end): ...these new (external) variables. (SIGCONTEXT_PC_OFFSET): Removed. (FRAME_SAVED_PC): New define. (i386bsd_frame_saved_pc): New function. * config/i386/fbsd.mt (TDEPFILES): Add i386bsd-tdep.o.
Diffstat (limited to 'gdb/i386bsd-tdep.c')
-rw-r--r--gdb/i386bsd-tdep.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/gdb/i386bsd-tdep.c b/gdb/i386bsd-tdep.c
new file mode 100644
index 0000000..a01ed6b
--- /dev/null
+++ b/gdb/i386bsd-tdep.c
@@ -0,0 +1,84 @@
+/* Target-dependent code for i386 BSD's.
+ Copyright 2001 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 "frame.h"
+#include "gdbcore.h"
+#include "regcache.h"
+
+/* Support for signal handlers. */
+
+/* Range in which to find the signaltramp routine, traditionally found
+ on the use stack, just below the user area. Initialized to values
+ that work for NetBSD and FreeBSD. */
+
+CORE_ADDR i386bsd_sigtramp_start = 0xbfbfdf20;
+CORE_ADDR i386bsd_sigtramp_end = 0xbfbfdff0;
+
+/* Return whether PC is in a BSD sigtramp routine. */
+
+int
+i386bsd_in_sigtramp (CORE_ADDR pc, char *name)
+{
+ return (pc >= i386bsd_sigtramp_start && pc < i386bsd_sigtramp_end);
+}
+
+/* Offset in the sigcontext structure of the program counter.
+ Initialized to the value from 4.4 BSD Lite. */
+int i386bsd_sigcontext_pc_offset = 20;
+
+/* Assuming FRAME is for a BSD sigtramp routine, return the address of
+ the associated sigcontext structure. */
+
+static CORE_ADDR
+i386bsd_sigcontext_addr (struct frame_info *frame)
+{
+ if (frame->next)
+ /* If this isn't the top frame, the next frame must be for the
+ signal handler itself. A pointer to the sigcontext structure
+ is passed as the third argument to the signal handler. */
+ return read_memory_unsigned_integer (frame->next->frame + 16, 4);
+
+ /* This is the top frame. We'll have to find the address of the
+ sigcontext structure by looking at the stack pointer. */
+ return read_memory_unsigned_integer (read_register (SP_REGNUM) + 8, 4);
+}
+
+/* Assuming FRAME is for a BSD sigtramp routine, return the saved
+ program counter. */
+
+static CORE_ADDR
+i386bsd_sigtramp_saved_pc (struct frame_info *frame)
+{
+ CORE_ADDR addr;
+ addr = i386bsd_sigcontext_addr (frame);
+ return read_memory_unsigned_integer (addr + i386bsd_sigcontext_pc_offset, 4);
+}
+
+/* Return the saved program counter for FRAME. */
+
+CORE_ADDR
+i386bsd_frame_saved_pc (struct frame_info *frame)
+{
+ if (frame->signal_handler_caller)
+ return i386bsd_sigtramp_saved_pc (frame);
+
+ return read_memory_unsigned_integer (frame->frame + 4, 4);
+}