]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/config/i386/tm-linux.h
import gdb-1999-09-08 snapshot
[thirdparty/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 #define I386_GNULINUX_TARGET
25
26 #include "i386/tm-i386.h"
27
28 /* Size of sigcontext, from <asm/sigcontext.h>. */
29 #define LINUX_SIGCONTEXT_SIZE (88)
30
31 /* Offset to saved PC in sigcontext, from <asm/sigcontext.h>. */
32 #define LINUX_SIGCONTEXT_PC_OFFSET (56)
33
34 /* Offset to saved SP in sigcontext, from <asm/sigcontext.h>. */
35 #define LINUX_SIGCONTEXT_SP_OFFSET (28)
36
37 /* We need this file for the SOLIB_TRAMPOLINE stuff. */
38
39 #include "tm-sysv4.h"
40
41 /* copy of tm-cygwin32.h */
42 #undef REGISTER_RAW_SIZE
43 #undef REGISTER_VIRTUAL_SIZE
44 #undef REGISTER_VIRTUAL_TYPE
45 #undef REGISTER_NAMES
46 #undef REGISTER_BYTES
47 #undef REGISTER_BYTE
48 #undef MAX_REGISTER_VIRTUAL_SIZE
49 #undef NUM_REGS
50 #undef NUM_FREGS
51
52 /* Number of machine registers */
53
54 #define NUM_REGS 31
55 #define NUM_FREGS 15
56
57 /* Initializer for an array of names of registers.
58 There should be NUM_REGS strings in this initializer. */
59
60 /* the order of the first 8 registers must match the compiler's
61 * numbering scheme (which is the same as the 386 scheme)
62 * also, this table must match regmap in i386-pinsn.c.
63 */
64
65 #define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
66 "esp", "ebp", "esi", "edi", \
67 "eip", "eflags","cs", "ss", \
68 "ds", "es", "fs", "gs", \
69 "cwd", "swd", "twd", "fip", \
70 "fcs", "fopo", "fos", \
71 "st", "st1", "st2", "st3", \
72 "st4", "st5", "st6", "st7",}
73
74 #define LOW_RETURN_REGNUM 0 /* holds low four bytes of result */
75 #define HIGH_RETURN_REGNUM 2 /* holds high four bytes of result */
76
77 #define FPSTART_REGNUM 16 /* start of FPU registers */
78 #define FPCONTROL_REGNUM 16 /* FPU control register */
79 #define FPSTATUS_REGNUM 17 /* FPU status register */
80 #define FPTAG_REGNUM 18 /* FPU tag register */
81 #define FPDATA_REGNUM 23 /* actual floating-point values */
82 #define FPEND_REGNUM (FPSTART_REGNUM + 14) /* last FPU register */
83
84 #define FPENV_BYTES (7 * 4)
85
86 #define FPREG_RAW_SIZE (10)
87
88 /* Total amount of space needed to store our copies of the machine's
89 FPU state. */
90
91 #define FPREG_BYTES (FPENV_BYTES + 8 * FPREG_RAW_SIZE)
92
93 /* Total amount of space needed to store our copies of the machine's
94 register state, the array `registers'. */
95
96 #define REGISTER_BYTES (FPSTART_REGNUM * 4 + FPREG_BYTES)
97
98 /* Index within `registers' of the first byte of the space for
99 register N. */
100
101 #define REGISTER_BYTE(N) (((N) < FPDATA_REGNUM) ? \
102 (N) * 4 : \
103 (((N) - FPDATA_REGNUM) * FPREG_RAW_SIZE) \
104 + (FPDATA_REGNUM * 4))
105
106 /* Number of bytes of storage in the actual machine representation
107 for register N. */
108
109 #define REGISTER_RAW_SIZE(N) (((N) < FPDATA_REGNUM) ? 4 : FPREG_RAW_SIZE)
110
111 /* Number of bytes of storage in the program's representation
112 for register N. */
113
114 #define REGISTER_VIRTUAL_SIZE(N) (((N) < FPDATA_REGNUM) ? 4 : FPREG_RAW_SIZE)
115
116 /* Largest value REGISTER_RAW_SIZE can have. */
117
118 #undef MAX_REGISTER_RAW_SIZE
119 #define MAX_REGISTER_RAW_SIZE FPREG_RAW_SIZE
120
121 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
122
123 #define MAX_REGISTER_VIRTUAL_SIZE FPREG_RAW_SIZE
124
125 #if defined(HAVE_LONG_DOUBLE) && defined(HOST_I386)
126 /* The host and target are i386 machines and the compiler supports
127 long doubles. Long doubles on the host therefore have the same
128 layout as a 387 FPU stack register. */
129 #define LD_I387
130 #endif
131
132 #define TARGET_LONG_DOUBLE_BIT 80
133
134 #ifdef LD_I387
135 extern int i387_extract_floating (PTR addr, int len, long double *dretptr);
136 extern int i387_store_floating (PTR addr, int len, long double val);
137
138 #define TARGET_EXTRACT_FLOATING i387_extract_floating
139 #define TARGET_STORE_FLOATING i387_store_floating
140
141 #define TARGET_ANALYZE_FLOATING \
142 do \
143 { \
144 unsigned expon; \
145 \
146 low = extract_unsigned_integer (valaddr, 4); \
147 high = extract_unsigned_integer (valaddr + 4, 4); \
148 expon = extract_unsigned_integer (valaddr + 8, 2); \
149 \
150 nonnegative = ((expon & 0x8000) == 0); \
151 is_nan = ((expon & 0x7fff) == 0x7fff) \
152 && ((high & 0x80000000) == 0x80000000) \
153 && (((high & 0x7fffffff) | low) != 0); \
154 } \
155 while (0)
156 #endif
157
158 #ifndef LD_I387
159 /* Nonzero if register N requires conversion
160 from raw format to virtual format. */
161 #define REGISTER_CONVERTIBLE(N) \
162 ((N < FPDATA_REGNUM) ? 0 : 1)
163 #endif
164
165 #ifdef LD_I387
166 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
167 { \
168 long double val = *((long double *)FROM); \
169 store_floating ((TO), TYPE_LENGTH (TYPE), val); \
170 }
171 #else
172 /* Convert data from raw format for register REGNUM in buffer FROM
173 to virtual format with type TYPE in buffer TO. */
174 extern void
175 i387_to_double PARAMS ((char *, char *));
176
177 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
178 { \
179 double val; \
180 i387_to_double ((FROM), (char *)&val); \
181 store_floating ((TO), TYPE_LENGTH (TYPE), val); \
182 }
183 #endif
184
185 #ifdef LD_I387
186 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
187 { \
188 long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
189 *((long double *)TO) = val; \
190 }
191 #else
192 extern void
193 double_to_i387 PARAMS ((char *, char *));
194
195 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
196 { \
197 double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
198 double_to_i387((char *)&val, (TO)); \
199 }
200 #endif
201
202 /* Return the GDB type object for the "standard" data type
203 of data in register N. */
204
205 #ifdef LD_I387
206 #define REGISTER_VIRTUAL_TYPE(N) \
207 ((N < FPDATA_REGNUM) ? builtin_type_int : \
208 builtin_type_long_double)
209 #else
210 #define REGISTER_VIRTUAL_TYPE(N) \
211 ((N < FPDATA_REGNUM) ? builtin_type_int : \
212 builtin_type_double)
213 #endif
214
215 /* end of copy */
216
217 extern void i387_float_info(void);
218 #define FLOAT_INFO { i387_float_info (); }
219
220 /* The following works around a problem with /usr/include/sys/procfs.h */
221 #define sys_quotactl 1
222
223 /* Define DO_REGISTERS_INFO() to do machine-specific formatting
224 of register dumps. */
225
226 #define DO_REGISTERS_INFO(_regnum, fp) i386_do_registers_info(_regnum, fp)
227 extern void i386_do_registers_info PARAMS ((int, int));
228
229 extern void i387_print_register PARAMS ((char *, int));
230
231 /* When the i386 Linux kernel calls a signal handler, the return
232 address points to a bit of code on the stack. These definitions
233 are used to identify this bit of code as a signal trampoline in
234 order to support backtracing through calls to signal handlers. */
235
236 #define I386_LINUX_SIGTRAMP
237 #define IN_SIGTRAMP(pc, name) ((name) == NULL && i386_linux_sigtramp (pc))
238
239 extern int i386_linux_sigtramp PARAMS ((CORE_ADDR));
240
241 /* We need our own version of sigtramp_saved_pc to get the saved PC in
242 a sigtramp routine. */
243
244 #define sigtramp_saved_pc i386_linux_sigtramp_saved_pc
245 extern CORE_ADDR i386_linux_sigtramp_saved_pc PARAMS ((struct frame_info *));
246
247 /* Signal trampolines don't have a meaningful frame. As in tm-i386.h,
248 the frame pointer value we use is actually the frame pointer of the
249 calling frame--that is, the frame which was in progress when the
250 signal trampoline was entered. gdb mostly treats this frame
251 pointer value as a magic cookie. We detect the case of a signal
252 trampoline by looking at the SIGNAL_HANDLER_CALLER field, which is
253 set based on IN_SIGTRAMP.
254
255 When a signal trampoline is invoked from a frameless function, we
256 essentially have two frameless functions in a row. In this case,
257 we use the same magic cookie for three frames in a row. We detect
258 this case by seeing whether the next frame has
259 SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the
260 current frame is actually frameless. In this case, we need to get
261 the PC by looking at the SP register value stored in the signal
262 context.
263
264 This should work in most cases except in horrible situations where
265 a signal occurs just as we enter a function but before the frame
266 has been set up. */
267
268 #define FRAMELESS_SIGNAL(FRAME) \
269 ((FRAME)->next != NULL \
270 && (FRAME)->next->signal_handler_caller \
271 && frameless_look_for_prologue (FRAME))
272
273 #undef FRAME_CHAIN
274 #define FRAME_CHAIN(FRAME) \
275 ((FRAME)->signal_handler_caller \
276 ? (FRAME)->frame \
277 : (FRAMELESS_SIGNAL (FRAME) \
278 ? (FRAME)->frame \
279 : (!inside_entry_file ((FRAME)->pc) \
280 ? read_memory_integer ((FRAME)->frame, 4) \
281 : 0)))
282
283 #undef FRAME_SAVED_PC
284 #define FRAME_SAVED_PC(FRAME) \
285 ((FRAME)->signal_handler_caller \
286 ? sigtramp_saved_pc (FRAME) \
287 : (FRAMELESS_SIGNAL (FRAME) \
288 ? read_memory_integer (i386_linux_sigtramp_saved_sp ((FRAME)->next), 4) \
289 : read_memory_integer ((FRAME)->frame + 4, 4)))
290
291 extern CORE_ADDR i386_linux_sigtramp_saved_sp PARAMS ((struct frame_info *));
292
293 /* Some versions of Linux have real-time signal support in the C library, and
294 some don't. We have to include this file to find out. */
295 #include <signal.h>
296
297 #ifdef __SIGRTMIN
298 #define REALTIME_LO __SIGRTMIN
299 #define REALTIME_HI (__SIGRTMAX + 1)
300 #else
301 #define REALTIME_LO 32
302 #define REALTIME_HI 64
303 #endif
304
305 /* When we call a function in a shared library, and the PLT sends us
306 into the dynamic linker to find the function's real address, we
307 need to skip over the dynamic linker call. This function decides
308 when to skip, and where to skip to. See the comments for
309 SKIP_SOLIB_RESOLVER at the top of infrun.c. */
310 #define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver
311 extern CORE_ADDR i386_linux_skip_solib_resolver (CORE_ADDR pc);
312
313 /* N_FUN symbols in shared libaries have 0 for their values and need
314 to be relocated. */
315 #define SOFUN_ADDRESS_MAYBE_MISSING
316
317 #endif /* #ifndef TM_LINUX_H */
318