2002-02-27 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / gdb / i386bsd-tdep.c
CommitLineData
b7247919
MK
1/* Target-dependent code for i386 BSD's.
2 Copyright 2001 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21#include "defs.h"
22#include "frame.h"
23#include "gdbcore.h"
24#include "regcache.h"
25
26/* Support for signal handlers. */
27
28/* Range in which to find the signaltramp routine, traditionally found
29 on the use stack, just below the user area. Initialized to values
30 that work for NetBSD and FreeBSD. */
31
32CORE_ADDR i386bsd_sigtramp_start = 0xbfbfdf20;
33CORE_ADDR i386bsd_sigtramp_end = 0xbfbfdff0;
34
35/* Return whether PC is in a BSD sigtramp routine. */
36
37int
38i386bsd_in_sigtramp (CORE_ADDR pc, char *name)
39{
40 return (pc >= i386bsd_sigtramp_start && pc < i386bsd_sigtramp_end);
41}
42
43/* Offset in the sigcontext structure of the program counter.
44 Initialized to the value from 4.4 BSD Lite. */
45int i386bsd_sigcontext_pc_offset = 20;
46
47/* Assuming FRAME is for a BSD sigtramp routine, return the address of
48 the associated sigcontext structure. */
49
50static CORE_ADDR
51i386bsd_sigcontext_addr (struct frame_info *frame)
52{
53 if (frame->next)
54 /* If this isn't the top frame, the next frame must be for the
55 signal handler itself. A pointer to the sigcontext structure
56 is passed as the third argument to the signal handler. */
57 return read_memory_unsigned_integer (frame->next->frame + 16, 4);
58
59 /* This is the top frame. We'll have to find the address of the
60 sigcontext structure by looking at the stack pointer. */
61 return read_memory_unsigned_integer (read_register (SP_REGNUM) + 8, 4);
62}
63
64/* Assuming FRAME is for a BSD sigtramp routine, return the saved
65 program counter. */
66
67static CORE_ADDR
68i386bsd_sigtramp_saved_pc (struct frame_info *frame)
69{
70 CORE_ADDR addr;
71 addr = i386bsd_sigcontext_addr (frame);
72 return read_memory_unsigned_integer (addr + i386bsd_sigcontext_pc_offset, 4);
73}
74
75/* Return the saved program counter for FRAME. */
76
77CORE_ADDR
78i386bsd_frame_saved_pc (struct frame_info *frame)
79{
80 if (frame->signal_handler_caller)
81 return i386bsd_sigtramp_saved_pc (frame);
82
83 return read_memory_unsigned_integer (frame->frame + 4, 4);
84}
This page took 0.07404 seconds and 4 git commands to generate.