import gdb-1999-08-02 snapshot
[deliverable/binutils-gdb.git] / gdb / config / i386 / tm-linux.h
1 /* Definitions to target GDB to GNU/Linux on 386.
2 Copyright 1992, 1993 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 #ifndef TM_LINUX_H
22 #define TM_LINUX_H
23
24 /* FIXME: If nothing else gets added to this file, it could be removed
25 and configure could just use tm-i386.h instead. -fnf */
26
27 #include "i386/tm-i386.h"
28
29 /* Size of sigcontext, from <asm/sigcontext.h>. */
30 #define LINUX_SIGCONTEXT_SIZE (88)
31
32 /* Offset to saved PC in sigcontext, from <asm/sigcontext.h>. */
33 #define LINUX_SIGCONTEXT_PC_OFFSET (56)
34
35 /* Offset to saved SP in sigcontext, from <asm/sigcontext.h>. */
36 #define LINUX_SIGCONTEXT_SP_OFFSET (28)
37
38 /* We need this file for the SOLIB_TRAMPOLINE stuff. */
39
40 #include "tm-sysv4.h"
41
42 /* The following works around a problem with /usr/include/sys/procfs.h */
43 #define sys_quotactl 1
44
45 /* When the i386 Linux kernel calls a signal handler, the return
46 address points to a bit of code on the stack. These definitions
47 are used to identify this bit of code as a signal trampoline in
48 order to support backtracing through calls to signal handlers. */
49
50 #define I386_LINUX_SIGTRAMP
51 #define IN_SIGTRAMP(pc, name) ((name) == NULL && i386_linux_sigtramp (pc))
52
53 extern int i386_linux_sigtramp PARAMS ((CORE_ADDR));
54
55 /* We need our own version of sigtramp_saved_pc to get the saved PC in
56 a sigtramp routine. */
57
58 #define sigtramp_saved_pc i386_linux_sigtramp_saved_pc
59 extern CORE_ADDR i386_linux_sigtramp_saved_pc PARAMS ((struct frame_info *));
60
61 /* Signal trampolines don't have a meaningful frame. As in tm-i386.h,
62 the frame pointer value we use is actually the frame pointer of the
63 calling frame--that is, the frame which was in progress when the
64 signal trampoline was entered. gdb mostly treats this frame
65 pointer value as a magic cookie. We detect the case of a signal
66 trampoline by looking at the SIGNAL_HANDLER_CALLER field, which is
67 set based on IN_SIGTRAMP.
68
69 When a signal trampoline is invoked from a frameless function, we
70 essentially have two frameless functions in a row. In this case,
71 we use the same magic cookie for three frames in a row. We detect
72 this case by seeing whether the next frame has
73 SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the
74 current frame is actually frameless. In this case, we need to get
75 the PC by looking at the SP register value stored in the signal
76 context.
77
78 This should work in most cases except in horrible situations where
79 a signal occurs just as we enter a function but before the frame
80 has been set up. */
81
82 #define FRAMELESS_SIGNAL(FRAME) \
83 ((FRAME)->next != NULL \
84 && (FRAME)->next->signal_handler_caller \
85 && frameless_look_for_prologue (FRAME))
86
87 #undef FRAME_CHAIN
88 #define FRAME_CHAIN(FRAME) \
89 ((FRAME)->signal_handler_caller \
90 ? (FRAME)->frame \
91 : (FRAMELESS_SIGNAL (FRAME) \
92 ? (FRAME)->frame \
93 : (!inside_entry_file ((FRAME)->pc) \
94 ? read_memory_integer ((FRAME)->frame, 4) \
95 : 0)))
96
97 #undef FRAME_SAVED_PC
98 #define FRAME_SAVED_PC(FRAME) \
99 ((FRAME)->signal_handler_caller \
100 ? sigtramp_saved_pc (FRAME) \
101 : (FRAMELESS_SIGNAL (FRAME) \
102 ? read_memory_integer (i386_linux_sigtramp_saved_sp ((FRAME)->next), 4) \
103 : read_memory_integer ((FRAME)->frame + 4, 4)))
104
105 extern CORE_ADDR i386_linux_sigtramp_saved_sp PARAMS ((struct frame_info *));
106
107 #endif /* #ifndef TM_LINUX_H */
This page took 0.046635 seconds and 4 git commands to generate.