Added GNU gdb to src/gnu
[unix-history] / gnu / usr.bin / gdb / config / m-i386bsd.h
CommitLineData
04497f0b
NW
1/*-
2 * This code is derived from software copyrighted by the Free Software
3 * Foundation.
4 *
5 * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
6 * Modified 1991 by William Jolitz at UUNET Technologies, Inc.
7 *
8 * @(#)m-i386bsd.h 6.7 (Berkeley) 5/8/91
9 */
10
11/* Macro definitions for i386.
12 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
13
14This file is part of GDB.
15
16GDB is free software; you can redistribute it and/or modify
17it under the terms of the GNU General Public License as published by
18the Free Software Foundation; either version 1, or (at your option)
19any later version.
20
21GDB is distributed in the hope that it will be useful,
22but WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24GNU General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with GDB; see the file COPYING. If not, write to
28the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
29
30/* Define the bit, byte, and word ordering of the machine. */
31/* #define BITS_BIG_ENDIAN */
32/* #define BYTES_BIG_ENDIAN */
33/* #define WORDS_BIG_ENDIAN */
34
35/*
36 * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu)
37 * July 1988
38 * [ MODIFIED FOR 386BSD W. Jolitz ]
39 */
40
41#ifndef i386
42#define i386 1
43#define i386b 1
44#endif
45
46#define IEEE_FLOAT
47
48/* Library stuff: POSIX tty (not supported yet), V7 tty (sigh), vprintf. */
49
50#define HAVE_TERMIOS 1
51#define USE_OLD_TTY 1
52#define HAVE_VPRINTF 1
53
54/* We support local and remote kernel debugging. */
55
56#define KERNELDEBUG 1
57
58/* Get rid of any system-imposed stack limit if possible. */
59
60#define SET_STACK_LIMIT_HUGE
61
62/* Define this if the C compiler puts an underscore at the front
63 of external names before giving them to the linker. */
64
65#define NAMES_HAVE_UNDERSCORE
66
67/* Specify debugger information format. */
68
69#define READ_DBX_FORMAT
70
71/* number of traps that happen between exec'ing the shell
72 * to run an inferior, and when we finally get to
73 * the inferior code. This is 2 on most implementations.
74 */
75#define START_INFERIOR_TRAPS_EXPECTED 2
76
77/* Offset from address of function to start of its code.
78 Zero on most machines. */
79
80#define FUNCTION_START_OFFSET 0
81
82/* Advance PC across any function entry prologue instructions
83 to reach some "real" code. */
84
85#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
86
87/* Immediately after a function call, return the saved pc.
88 Can't always go through the frames for this because on some machines
89 the new frame is not set up until the new function executes
90 some instructions. */
91
92#define SAVED_PC_AFTER_CALL(frame) \
93 (read_memory_integer (read_register (SP_REGNUM), 4))
94
95/* This is the amount to subtract from u.u_ar0
96 to get the offset in the core file of the register values. */
97
98#ifdef NEWVM
99#include <machine/vmparam.h>
100#define KERNEL_U_ADDR USRSTACK
101#else
102#define KERNEL_U_ADDR 0xfdffd000
103#endif
104
105/* Address of end of stack space. */
106
107#define STACK_END_ADDR KERNEL_U_ADDR
108
109/* Stack grows downward. */
110
111#define INNER_THAN <
112
113/* Sequence of bytes for breakpoint instruction. */
114
115#define BREAKPOINT {0xcc}
116
117/* Amount PC must be decremented by after a breakpoint.
118 This is often the number of bytes in BREAKPOINT
119 but not always. */
120
121#define DECR_PC_AFTER_BREAK 1
122
123/* Nonzero if instruction at PC is a return instruction. */
124
125#define ABOUT_TO_RETURN(pc) \
126 strchr("\302\303\312\313\317", read_memory_integer(pc, 1))
127
128/* Return 1 if P points to an invalid floating point value.
129 LEN is the length in bytes -- not relevant on the 386. */
130
131#define INVALID_FLOAT(p, len) (0)
132
133/* code to execute to print interesting information about the
134 * floating point processor (if any)
135 * No need to define if there is nothing to do.
136 */
137#define FLOAT_INFO { i386_float_info (); }
138
139
140/* Largest integer type */
141#define LONGEST long
142
143/* Name of the builtin type for the LONGEST type above. */
144#define BUILTIN_TYPE_LONGEST builtin_type_long
145
146/* Say how long (ordinary) registers are. */
147
148#define REGISTER_TYPE long
149
150/* Number of machine registers */
151
152#define NUM_REGS 16
153
154/* Initializer for an array of names of registers.
155 There should be NUM_REGS strings in this initializer. */
156
157/* the order of the first 8 registers must match the compiler's
158 * numbering scheme (which is the same as the 386 scheme)
159 * also, this table must match regmap in i386-pinsn.c.
160 */
161#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \
162 "esp", "ebp", "esi", "edi", \
163 "eip", "ps", "cs", "ss", \
164 "ds", "es", "fs", "gs", \
165 }
166
167/* Register numbers of various important registers.
168 Note that some of these values are "real" register numbers,
169 and correspond to the general registers of the machine,
170 and some are "phony" register numbers which are too large
171 to be actual register numbers as far as the user is concerned
172 but do serve to get the desired values when passed to read_register. */
173
174#define FP_REGNUM 5 /* Contains address of executing stack frame */
175#define SP_REGNUM 4 /* Contains address of top of stack */
176
177#define PC_REGNUM 8
178#define PS_REGNUM 9
179
180#define REGISTER_U_ADDR(addr, blockend, regno) \
181 (addr) = i386_register_u_addr ((blockend),(regno));
182
183/* Total amount of space needed to store our copies of the machine's
184 register state, the array `registers'. */
185#define REGISTER_BYTES (NUM_REGS * 4)
186
187/* Index within `registers' of the first byte of the space for
188 register N. */
189
190#define REGISTER_BYTE(N) ((N)*4)
191
192/* Number of bytes of storage in the actual machine representation
193 for register N. */
194
195#define REGISTER_RAW_SIZE(N) (4)
196
197/* Number of bytes of storage in the program's representation
198 for register N. */
199
200#define REGISTER_VIRTUAL_SIZE(N) (4)
201
202/* Largest value REGISTER_RAW_SIZE can have. */
203
204#define MAX_REGISTER_RAW_SIZE 4
205
206/* Largest value REGISTER_VIRTUAL_SIZE can have. */
207
208#define MAX_REGISTER_VIRTUAL_SIZE 4
209
210/* Nonzero if register N requires conversion
211 from raw format to virtual format. */
212
213#define REGISTER_CONVERTIBLE(N) (0)
214
215/* Convert data from raw format for register REGNUM
216 to virtual format for register REGNUM. */
217
218#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
219
220/* Convert data from virtual format for register REGNUM
221 to raw format for register REGNUM. */
222
223#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);}
224
225/* Return the GDB type object for the "standard" data type
226 of data in register N. */
227
228#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
229
230/* Store the address of the place in which to copy the structure the
231 subroutine will return. This is called from call_function. */
232
233#define STORE_STRUCT_RETURN(ADDR, SP) \
234 { (SP) -= sizeof (ADDR); \
235 write_memory ((SP), &(ADDR), sizeof (ADDR)); }
236
237/* Extract from an array REGBUF containing the (raw) register state
238 a function return value of type TYPE, and copy that, in virtual format,
239 into VALBUF. */
240
241#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
242 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
243
244/* Write into appropriate registers a function return value
245 of type TYPE, given in virtual format. */
246
247#define STORE_RETURN_VALUE(TYPE,VALBUF) \
248 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
249
250/* Extract from an array REGBUF containing the (raw) register state
251 the address in which a function should return its structure value,
252 as a CORE_ADDR (or an expression that can be used as one). */
253
254#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
255
256\f
257/* Describe the pointer in each stack frame to the previous stack frame
258 (its caller). */
259
260/* FRAME_CHAIN takes a frame's nominal address
261 and produces the frame's chain-pointer.
262
263 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
264 and produces the nominal address of the caller frame.
265
266 However, if FRAME_CHAIN_VALID returns zero,
267 it means the given frame is the outermost one and has no caller.
268 In that case, FRAME_CHAIN_COMBINE is not used. */
269
270#define FRAME_CHAIN(thisframe) \
271 (outside_startup_file ((thisframe)->pc) ? \
272 read_memory_integer ((thisframe)->frame, 4) :\
273 0)
274
275#ifdef KERNELDEBUG
276#define KERNTEXT_BASE 0xfe000000
277#ifdef NEWVM
278#define KERNSTACK_TOP (read_register(SP_REGNUM) + 0x2000) /* approximate */
279#else
280/* #define KERNSTACK_TOP (P1PAGES << PGSHIFT) */
281#define KERNSTACK_TOP 0xfe000000
282#endif
283extern int kernel_debugging;
284#define FRAME_CHAIN_VALID(chain, thisframe) \
285 (chain != 0 && \
286 !kernel_debugging ? outside_startup_file(FRAME_SAVED_PC(thisframe)) :\
287 (chain >= read_register(SP_REGNUM) && chain < KERNSTACK_TOP))
288#else
289#define FRAME_CHAIN_VALID(chain, thisframe) \
290 (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe))))
291#endif
292
293#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
294
295/* Define other aspects of the stack frame. */
296
297/* A macro that tells us whether the function invocation represented
298 by FI does not have a frame on the stack associated with it. If it
299 does not, FRAMELESS is set to 1, else 0. */
300#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
301 FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
302
303#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4))
304
305#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
306
307#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
308
309/* Return number of args passed to a frame.
310 Can return -1, meaning no way to tell. */
311
312#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi)
313
314/* Return number of bytes at start of arglist that are not really args. */
315
316#define FRAME_ARGS_SKIP 8
317
318/* Put here the code to store, into a struct frame_saved_regs,
319 the addresses of the saved registers of frame described by FRAME_INFO.
320 This includes special registers such as pc and fp saved in special
321 ways in the stack frame. sp is even more special:
322 the address we return for it IS the sp for the next frame. */
323
324#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
325{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
326
327\f
328/* Discard from the stack the innermost frame, restoring all registers. */
329
330#define POP_FRAME { i386_pop_frame (); }
331
332#define NEW_CALL_FUNCTION
333\f
334#if 0
335/* Interface definitions for kernel debugger KDB. */
336
337/* Map machine fault codes into signal numbers.
338 First subtract 0, divide by 4, then index in a table.
339 Faults for which the entry in this table is 0
340 are not handled by KDB; the program's own trap handler
341 gets to handle then. */
342
343#define FAULT_CODE_ORIGIN 0
344#define FAULT_CODE_UNITS 4
345#define FAULT_TABLE \
346{ 0, 0, 0, 0, 0, 0, 0, 0, \
347 0, 0, 0, 0, 0, 0, 0, 0, \
348 0, 0, 0, 0, 0, 0, 0, 0}
349
350/* Start running with a stack stretching from BEG to END.
351 BEG and END should be symbols meaningful to the assembler.
352 This is used only for kdb. */
353
354#define INIT_STACK(beg, end) {}
355
356/* Push the frame pointer register on the stack. */
357#define PUSH_FRAME_PTR {}
358
359/* Copy the top-of-stack to the frame pointer register. */
360#define POP_FRAME_PTR {}
361
362/* After KDB is entered by a fault, push all registers
363 that GDB thinks about (all NUM_REGS of them),
364 so that they appear in order of ascending GDB register number.
365 The fault code will be on the stack beyond the last register. */
366
367#define PUSH_REGISTERS {}
368
369/* Assuming the registers (including processor status) have been
370 pushed on the stack in order of ascending GDB register number,
371 restore them and return to the address in the saved PC register. */
372
373#define POP_REGISTERS {}
374#endif