1 /* Definitions to target GDB to GNU/Linux on 386.
2 Copyright 1992, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
24 #define I386_GNULINUX_TARGET
26 #include "i386/tm-i386.h"
28 /* Size of sigcontext, from <asm/sigcontext.h>. */
29 #define LINUX_SIGCONTEXT_SIZE (88)
31 /* Offset to saved PC in sigcontext, from <asm/sigcontext.h>. */
32 #define LINUX_SIGCONTEXT_PC_OFFSET (56)
34 /* Offset to saved SP in sigcontext, from <asm/sigcontext.h>. */
35 #define LINUX_SIGCONTEXT_SP_OFFSET (28)
37 /* We need this file for the SOLIB_TRAMPOLINE stuff. */
41 /* copy of tm-cygwin32.h */
42 #undef REGISTER_RAW_SIZE
43 #undef REGISTER_VIRTUAL_SIZE
44 #undef REGISTER_VIRTUAL_TYPE
48 #undef MAX_REGISTER_VIRTUAL_SIZE
52 /* Number of machine registers */
57 /* Initializer for an array of names of registers.
58 There should be NUM_REGS strings in this initializer. */
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.
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",}
74 #define LOW_RETURN_REGNUM 0 /* holds low four bytes of result */
75 #define HIGH_RETURN_REGNUM 2 /* holds high four bytes of result */
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 */
84 #define FPENV_BYTES (7 * 4)
86 #define FPREG_RAW_SIZE (10)
88 /* Total amount of space needed to store our copies of the machine's
91 #define FPREG_BYTES (FPENV_BYTES + 8 * FPREG_RAW_SIZE)
93 /* Total amount of space needed to store our copies of the machine's
94 register state, the array `registers'. */
96 #define REGISTER_BYTES (FPSTART_REGNUM * 4 + FPREG_BYTES)
98 /* Index within `registers' of the first byte of the space for
101 #define REGISTER_BYTE(N) (((N) < FPDATA_REGNUM) ? \
103 (((N) - FPDATA_REGNUM) * FPREG_RAW_SIZE) \
104 + (FPDATA_REGNUM * 4))
106 /* Number of bytes of storage in the actual machine representation
109 #define REGISTER_RAW_SIZE(N) (((N) < FPDATA_REGNUM) ? 4 : FPREG_RAW_SIZE)
111 /* Number of bytes of storage in the program's representation
114 #define REGISTER_VIRTUAL_SIZE(N) (((N) < FPDATA_REGNUM) ? 4 : FPREG_RAW_SIZE)
116 /* Largest value REGISTER_RAW_SIZE can have. */
118 #undef MAX_REGISTER_RAW_SIZE
119 #define MAX_REGISTER_RAW_SIZE FPREG_RAW_SIZE
121 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
123 #define MAX_REGISTER_VIRTUAL_SIZE FPREG_RAW_SIZE
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. */
132 #define TARGET_LONG_DOUBLE_BIT 80
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
);
138 #define TARGET_EXTRACT_FLOATING i387_extract_floating
139 #define TARGET_STORE_FLOATING i387_store_floating
141 #define TARGET_ANALYZE_FLOATING \
146 low = extract_unsigned_integer (valaddr, 4); \
147 high = extract_unsigned_integer (valaddr + 4, 4); \
148 expon = extract_unsigned_integer (valaddr + 8, 2); \
150 nonnegative = ((expon & 0x8000) == 0); \
151 is_nan = ((expon & 0x7fff) == 0x7fff) \
152 && ((high & 0x80000000) == 0x80000000) \
153 && (((high & 0x7fffffff) | low) != 0); \
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)
166 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
168 long double val = *((long double *)FROM); \
169 store_floating ((TO), TYPE_LENGTH (TYPE), val); \
172 /* Convert data from raw format for register REGNUM in buffer FROM
173 to virtual format with type TYPE in buffer TO. */
175 i387_to_double
PARAMS ((char *, char *));
177 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
180 i387_to_double ((FROM), (char *)&val); \
181 store_floating ((TO), TYPE_LENGTH (TYPE), val); \
186 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
188 long double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
189 *((long double *)TO) = val; \
193 double_to_i387
PARAMS ((char *, char *));
195 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
197 double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
198 double_to_i387((char *)&val, (TO)); \
202 /* Return the GDB type object for the "standard" data type
203 of data in register N. */
206 #define REGISTER_VIRTUAL_TYPE(N) \
207 ((N < FPDATA_REGNUM) ? builtin_type_int : \
208 builtin_type_long_double)
210 #define REGISTER_VIRTUAL_TYPE(N) \
211 ((N < FPDATA_REGNUM) ? builtin_type_int : \
217 /* The following works around a problem with /usr/include/sys/procfs.h */
218 #define sys_quotactl 1
220 /* When the i386 Linux kernel calls a signal handler, the return
221 address points to a bit of code on the stack. These definitions
222 are used to identify this bit of code as a signal trampoline in
223 order to support backtracing through calls to signal handlers. */
225 #define I386_LINUX_SIGTRAMP
226 #define IN_SIGTRAMP(pc, name) ((name) == NULL && i386_linux_sigtramp (pc))
228 extern int i386_linux_sigtramp
PARAMS ((CORE_ADDR
));
230 /* We need our own version of sigtramp_saved_pc to get the saved PC in
231 a sigtramp routine. */
233 #define sigtramp_saved_pc i386_linux_sigtramp_saved_pc
234 extern CORE_ADDR i386_linux_sigtramp_saved_pc
PARAMS ((struct frame_info
*));
236 /* Signal trampolines don't have a meaningful frame. As in tm-i386.h,
237 the frame pointer value we use is actually the frame pointer of the
238 calling frame--that is, the frame which was in progress when the
239 signal trampoline was entered. gdb mostly treats this frame
240 pointer value as a magic cookie. We detect the case of a signal
241 trampoline by looking at the SIGNAL_HANDLER_CALLER field, which is
242 set based on IN_SIGTRAMP.
244 When a signal trampoline is invoked from a frameless function, we
245 essentially have two frameless functions in a row. In this case,
246 we use the same magic cookie for three frames in a row. We detect
247 this case by seeing whether the next frame has
248 SIGNAL_HANDLER_CALLER set, and, if it does, checking whether the
249 current frame is actually frameless. In this case, we need to get
250 the PC by looking at the SP register value stored in the signal
253 This should work in most cases except in horrible situations where
254 a signal occurs just as we enter a function but before the frame
257 #define FRAMELESS_SIGNAL(FRAME) \
258 ((FRAME)->next != NULL \
259 && (FRAME)->next->signal_handler_caller \
260 && frameless_look_for_prologue (FRAME))
263 #define FRAME_CHAIN(FRAME) \
264 ((FRAME)->signal_handler_caller \
266 : (FRAMELESS_SIGNAL (FRAME) \
268 : (!inside_entry_file ((FRAME)->pc) \
269 ? read_memory_integer ((FRAME)->frame, 4) \
272 #undef FRAME_SAVED_PC
273 #define FRAME_SAVED_PC(FRAME) \
274 ((FRAME)->signal_handler_caller \
275 ? sigtramp_saved_pc (FRAME) \
276 : (FRAMELESS_SIGNAL (FRAME) \
277 ? read_memory_integer (i386_linux_sigtramp_saved_sp ((FRAME)->next), 4) \
278 : read_memory_integer ((FRAME)->frame + 4, 4)))
280 extern CORE_ADDR i386_linux_sigtramp_saved_sp
PARAMS ((struct frame_info
*));
282 /* Some versions of Linux have real-time signal support in the C library, and
283 some don't. We have to include this file to find out. */
287 #define REALTIME_LO __SIGRTMIN
288 #define REALTIME_HI (__SIGRTMAX + 1)
290 #define REALTIME_LO 32
291 #define REALTIME_HI 64
294 /* When we call a function in a shared library, and the PLT sends us
295 into the dynamic linker to find the function's real address, we
296 need to skip over the dynamic linker call. This function decides
297 when to skip, and where to skip to. See the comments for
298 SKIP_SOLIB_RESOLVER at the top of infrun.c. */
299 #define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver
300 extern CORE_ADDR
i386_linux_skip_solib_resolver (CORE_ADDR pc
);
302 /* N_FUN symbols in shared libaries have 0 for their values and need
304 #define SOFUN_ADDRESS_MAYBE_MISSING
306 #endif /* #ifndef TM_LINUX_H */