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