8fae6104c529f5c64d2947fe5ddb3feb04b17c5a
[deliverable/binutils-gdb.git] / gdb / config / i386 / tm-i386.h
1 /* Macro definitions for GDB on an Intel i[345]86.
2 Copyright 1995, 1996, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #ifndef TM_I386_H
23 #define TM_I386_H 1
24
25 #define GDB_MULTI_ARCH GDB_MULTI_ARCH_PARTIAL
26
27 #include "regcache.h"
28
29 /* Forward declarations for prototypes. */
30 struct frame_info;
31 struct frame_saved_regs;
32 struct value;
33 struct type;
34
35 /* The format used for `long double' on almost all i386 targets is the
36 i387 extended floating-point format. In fact, of all targets in the
37 GCC 2.95 tree, only OSF/1 does it different, and insists on having
38 a `long double' that's not `long' at all. */
39
40 #define TARGET_LONG_DOUBLE_FORMAT &floatformat_i387_ext
41
42 /* Although the i386 extended floating-point has only 80 significant
43 bits, a `long double' actually takes up 96, probably to enforce
44 alignment. */
45
46 #define TARGET_LONG_DOUBLE_BIT 96
47
48 /* Number of traps that happen between exec'ing the shell to run an
49 inferior, and when we finally get to the inferior code. This is 2
50 on most implementations. */
51
52 #define START_INFERIOR_TRAPS_EXPECTED 2
53
54 /* Offset from address of function to start of its code.
55 Zero on most machines. */
56
57 #define FUNCTION_START_OFFSET 0
58
59 /* Advance PC across any function entry prologue instructions to reach some
60 "real" code. */
61
62 #define SKIP_PROLOGUE(frompc) (i386_skip_prologue (frompc))
63
64 extern int i386_skip_prologue (int);
65
66 /* Stack grows downward. */
67
68 #define INNER_THAN(lhs,rhs) ((lhs) < (rhs))
69
70 /* Sequence of bytes for breakpoint instruction. */
71
72 #define BREAKPOINT {0xcc}
73
74 /* Amount PC must be decremented by after a breakpoint. This is often the
75 number of bytes in BREAKPOINT but not always. */
76
77 #define DECR_PC_AFTER_BREAK 1
78
79 /* Say how long (ordinary) registers are. This is a piece of bogosity
80 used in push_word and a few other places; REGISTER_RAW_SIZE is the
81 real way to know how big a register is. */
82
83 #define REGISTER_SIZE 4
84
85 /* This register file is parameterized by two macros:
86 HAVE_I387_REGS --- register file should include i387 registers
87 HAVE_SSE_REGS --- register file should include SSE registers
88 If HAVE_SSE_REGS is #defined, then HAVE_I387_REGS must also be #defined.
89
90 However, GDB code should not test those macros with #ifdef, since
91 that makes code which is annoying to multi-arch. Instead, GDB code
92 should check the values of NUM_GREGS, NUM_FREGS, and NUM_SSE_REGS,
93 which will eventually get mapped onto architecture vector entries.
94
95 It's okay to use the macros in tm-*.h files, though, since those
96 files will get completely replaced when we multi-arch anyway. */
97
98 /* Number of general registers, present on every 32-bit x86 variant. */
99 #define NUM_GREGS (16)
100
101 /* Number of floating-point unit registers. */
102 #ifdef HAVE_I387_REGS
103 #define NUM_FREGS (16)
104 #else
105 #define NUM_FREGS (0)
106 #endif
107
108 /* Number of SSE registers. */
109 #ifdef HAVE_SSE_REGS
110 #define NUM_SSE_REGS (9)
111 #else
112 #define NUM_SSE_REGS (0)
113 #endif
114
115 /* Largest number of registers we could have in any configuration. */
116 #define MAX_NUM_REGS (16 + 16 + 9 + 1)
117
118 /* Register numbers of various important registers.
119 Note that some of these values are "real" register numbers,
120 and correspond to the general registers of the machine,
121 and some are "phony" register numbers which are too large
122 to be actual register numbers as far as the user is concerned
123 but do serve to get the desired values when passed to read_register. */
124
125 #define FP_REGNUM 5 /* (ebp) Contains address of executing stack
126 frame */
127 #define SP_REGNUM 4 /* (usp) Contains address of top of stack */
128 #define PC_REGNUM 8 /* (eip) Contains program counter */
129 #define PS_REGNUM 9 /* (ps) Contains processor status */
130
131 /* First FPU data register. */
132 #ifdef HAVE_I387_REGS
133 #define FP0_REGNUM 16
134 #else
135 #define FP0_REGNUM 0
136 #endif
137 \f
138
139 /* Largest value REGISTER_RAW_SIZE can have. */
140 #define MAX_REGISTER_RAW_SIZE 16
141
142 /* Return the size in bytes of the virtual type of register REG. */
143 #define REGISTER_VIRTUAL_SIZE(reg) i386_register_virtual_size ((reg))
144 extern int i386_register_virtual_size (int reg);
145
146 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
147 #define MAX_REGISTER_VIRTUAL_SIZE 16
148
149 /* Return the GDB type object for the "standard" data type of data in
150 register REGNUM. */
151
152 #define REGISTER_VIRTUAL_TYPE(regnum) i386_register_virtual_type (regnum)
153 extern struct type *i386_register_virtual_type (int regnum);
154
155 /* Return true iff register REGNUM's virtual format is different from
156 its raw format. */
157
158 #define REGISTER_CONVERTIBLE(regnum) i386_register_convertible (regnum)
159 extern int i386_register_convertible (int regnum);
160
161 /* Convert data from raw format for register REGNUM in buffer FROM to
162 virtual format with type TYPE in buffer TO. */
163
164 #define REGISTER_CONVERT_TO_VIRTUAL(regnum, type, from, to) \
165 i386_register_convert_to_virtual ((regnum), (type), (from), (to))
166 extern void i386_register_convert_to_virtual (int regnum, struct type *type,
167 char *from, char *to);
168
169 /* Convert data from virtual format with type TYPE in buffer FROM to
170 raw format for register REGNUM in buffer TO. */
171
172 #define REGISTER_CONVERT_TO_RAW(type, regnum, from, to) \
173 i386_register_convert_to_raw ((type), (regnum), (from), (to))
174 extern void i386_register_convert_to_raw (struct type *type, int regnum,
175 char *from, char *to);
176
177 /* Print out the i387 floating point state. */
178 #ifdef HAVE_I387_REGS
179 extern void i387_float_info (void);
180 #define FLOAT_INFO { i387_float_info (); }
181 #endif
182 \f
183
184 #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \
185 i386_push_arguments ((nargs), (args), (sp), (struct_return), (struct_addr))
186 extern CORE_ADDR i386_push_arguments (int nargs, struct value **args,
187 CORE_ADDR sp, int struct_return,
188 CORE_ADDR struct_addr);
189
190 /* Store the address of the place in which to copy the structure the
191 subroutine will return. This is called from call_function. */
192
193 #define STORE_STRUCT_RETURN(addr, sp) \
194 i386_store_struct_return ((addr), (sp))
195 extern void i386_store_struct_return (CORE_ADDR addr, CORE_ADDR sp);
196
197 /* Extract from an array REGBUF containing the (raw) register state
198 a function return value of type TYPE, and copy that, in virtual format,
199 into VALBUF. */
200
201 #define EXTRACT_RETURN_VALUE(type, regbuf, valbuf) \
202 i386_extract_return_value ((type), (regbuf), (valbuf))
203 extern void i386_extract_return_value (struct type *type, char *regbuf,
204 char *valbuf);
205
206 /* Write into the appropriate registers a function return value stored
207 in VALBUF of type TYPE, given in virtual format. */
208
209 #define STORE_RETURN_VALUE(type, valbuf) \
210 i386_store_return_value ((type), (valbuf))
211 extern void i386_store_return_value (struct type *type, char *valbuf);
212
213 /* Extract from an array REGBUF containing the (raw) register state
214 the address in which a function should return its structure value,
215 as a CORE_ADDR. */
216
217 #define EXTRACT_STRUCT_VALUE_ADDRESS(regbuf) \
218 i386_extract_struct_value_address ((regbuf))
219 extern CORE_ADDR i386_extract_struct_value_address (char *regbuf);
220
221 /* Determine whether the function invocation represented by FRAME does
222 not have a from on the stack associated with it. If it does not,
223 return non-zero, otherwise return zero. */
224
225 #define FRAMELESS_FUNCTION_INVOCATION(frame) \
226 i386_frameless_function_invocation (frame)
227 extern int i386_frameless_function_invocation (struct frame_info *frame);
228
229 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
230
231 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
232
233 /* Return number of args passed to a frame. Can return -1, meaning no way
234 to tell, which is typical now that the C compiler delays popping them. */
235
236 #define FRAME_NUM_ARGS(fi) (i386_frame_num_args(fi))
237
238 extern int i386_frame_num_args (struct frame_info *);
239
240 /* Return number of bytes at start of arglist that are not really args. */
241
242 #define FRAME_ARGS_SKIP 8
243
244 /* Put here the code to store, into a struct frame_saved_regs,
245 the addresses of the saved registers of frame described by FRAME_INFO.
246 This includes special registers such as pc and fp saved in special
247 ways in the stack frame. sp is even more special:
248 the address we return for it IS the sp for the next frame. */
249
250 extern void i386_frame_init_saved_regs (struct frame_info *);
251 #define FRAME_INIT_SAVED_REGS(FI) i386_frame_init_saved_regs (FI)
252
253 \f
254
255 /* Things needed for making the inferior call functions. */
256
257 /* "An argument's size is increased, if necessary, to make it a
258 multiple of [32 bit] words. This may require tail padding,
259 depending on the size of the argument" - from the x86 ABI. */
260 #define PARM_BOUNDARY 32
261
262 /* Push an empty stack frame, to record the current PC, etc. */
263
264 #define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); }
265
266 extern void i386_push_dummy_frame (void);
267
268 /* Discard from the stack the innermost frame, restoring all registers. */
269
270 #define POP_FRAME { i386_pop_frame (); }
271
272 extern void i386_pop_frame (void);
273 \f
274
275 /* this is
276 * call 11223344 (32 bit relative)
277 * int3
278 */
279
280 #define CALL_DUMMY { 0x223344e8, 0xcc11 }
281
282 #define CALL_DUMMY_LENGTH 8
283
284 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
285
286 #define CALL_DUMMY_BREAKPOINT_OFFSET 5
287
288 /* Insert the specified number of args and function address
289 into a call sequence of the above form stored at DUMMYNAME. */
290
291 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
292 i386_fix_call_dummy (dummyname, pc, fun, nargs, args, type, gcc_p)
293 extern void i386_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun,
294 int nargs, struct value **args,
295 struct type *type, int gcc_p);
296
297 /* FIXME: kettenis/2000-06-12: These do not belong here. */
298 extern void print_387_control_word (unsigned int);
299 extern void print_387_status_word (unsigned int);
300
301 /* Offset from SP to first arg on stack at first instruction of a function */
302
303 #define SP_ARG0 (1 * 4)
304
305 #endif /* ifndef TM_I386_H */
This page took 0.052233 seconds and 4 git commands to generate.