* config/{*.mt, *.mh}: All target and host makefile fragment
[deliverable/binutils-gdb.git] / gdb / config / i386 / tm-symmetry.h
1 /* Target machine definitions for GDB on a Sequent Symmetry under dynix 3.0,
2 with Weitek 1167 and i387 support.
3 Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
4 Symmetry version by Jay Vosburgh (uunet!sequent!fubar).
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 /* I don't know if this will work for cross-debugging, even if you do get
23 a copy of the right include file. */
24 #include <machine/reg.h>
25
26 #define TARGET_BYTE_ORDER LITTLE_ENDIAN
27
28 /* Offset from address of function to start of its code.
29 Zero on most machines. */
30
31 #define FUNCTION_START_OFFSET 0
32
33 /* Advance PC across any function entry prologue instructions
34 to reach some "real" code. From m-i386.h */
35
36 #define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
37
38 extern int
39 i386_skip_prologue PARAMS ((int));
40
41 /* Immediately after a function call, return the saved pc.
42 Can't always go through the frames for this because on some machines
43 the new frame is not set up until the new function executes
44 some instructions. */
45
46 #define SAVED_PC_AFTER_CALL(frame) \
47 read_memory_integer(read_register(SP_REGNUM), 4)
48
49 /* I don't know the real values for these. */
50 #define TARGET_UPAGES UPAGES
51 #define TARGET_NBPG NBPG
52
53 /* Address of end of stack space. */
54
55 #define STACK_END_ADDR (0x40000000 - (TARGET_UPAGES * TARGET_NBPG))
56
57 /* Stack grows downward. */
58
59 #define INNER_THAN <
60
61 /* Sequence of bytes for breakpoint instruction. */
62
63 #define BREAKPOINT {0xcc}
64
65 /* Amount PC must be decremented by after a breakpoint.
66 This is often the number of bytes in BREAKPOINT
67 but not always. */
68
69 #define DECR_PC_AFTER_BREAK 0
70
71 /* Nonzero if instruction at PC is a return instruction. */
72 /* For Symmetry, this is really the 'leave' instruction, which */
73 /* is right before the ret */
74
75 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
76
77 /* Return 1 if P points to an invalid floating point value.
78 */
79
80 #define INVALID_FLOAT(p, len) (0)
81
82 #if 0
83 --- this code can't be used unless we know we are running native,
84 since it uses host specific ptrace calls.
85 /* code for 80387 fpu. Functions are from i386-dep.c, copied into
86 * symm-dep.c.
87 */
88 #define FLOAT_INFO { i386_float_info(); }
89 #endif
90
91 /* Say how long (ordinary) registers are. */
92
93 #define REGISTER_TYPE long
94
95 /* Number of machine registers */
96 #define NUM_REGS 49
97
98 /* Initializer for an array of names of registers.
99 There should be NUM_REGS strings in this initializer. */
100
101 /* Symmetry registers are in this weird order to match the register
102 numbers in the symbol table entries. If you change the order,
103 things will probably break mysteriously for no apparent reason.
104 Also note that the st(0)...st(7) 387 registers are represented as
105 st0...st7. */
106
107 #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \
108 "ebx", "esi", "edi", "st2", "st3", \
109 "st4", "st5", "st6", "st7", "esp", \
110 "ebp", "eip", "eflags", "fp1", "fp2", \
111 "fp3", "fp4", "fp5", "fp6", "fp7", \
112 "fp8", "fp9", "fp10", "fp11", "fp12", \
113 "fp13", "fp14", "fp15", "fp16", "fp17", \
114 "fp18", "fp19", "fp20", "fp21", "fp22", \
115 "fp23", "fp24", "fp25", "fp26", "fp27", \
116 "fp28", "fp29", "fp30", "fp31" }
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 FP1_REGNUM 18 /* first 1167 register */
126 #define SP_REGNUM 14 /* Contains address of top of stack */
127 #define FP_REGNUM 15 /* Contains address of executing stack frame */
128 #define PC_REGNUM 16 /* Contains program counter */
129 #define PS_REGNUM 17 /* Contains processor status */
130
131 /* Total amount of space needed to store our copies of the machine's
132 register state, the array `registers'. */
133 /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */
134 #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
135
136 /* Index within `registers' of the first byte of the space for
137 register N. */
138
139 #define REGISTER_BYTE(N) \
140 ((N < 3) ? (N * 4) : \
141 (N < 5) ? (((N - 2) * 10) + 2) : \
142 (N < 8) ? (((N - 5) * 4) + 32) : \
143 (N < 14) ? (((N - 8) * 10) + 44) : \
144 (((N - 14) * 4) + 104))
145
146 /* Number of bytes of storage in the actual machine representation
147 * for register N. All registers are 4 bytes, except 387 st(0) - st(7),
148 * which are 80 bits each.
149 */
150
151 #define REGISTER_RAW_SIZE(N) \
152 ((N < 3) ? 4 : \
153 (N < 5) ? 10 : \
154 (N < 8) ? 4 : \
155 (N < 14) ? 10 : \
156 4)
157
158 /* Number of bytes of storage in the program's representation
159 for register N. On the vax, all regs are 4 bytes. */
160
161 #define REGISTER_VIRTUAL_SIZE(N) 4
162
163 /* Largest value REGISTER_RAW_SIZE can have. */
164
165 #define MAX_REGISTER_RAW_SIZE 10
166
167 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
168
169 #define MAX_REGISTER_VIRTUAL_SIZE 4
170
171 /* Nonzero if register N requires conversion
172 from raw format to virtual format. */
173
174 #define REGISTER_CONVERTIBLE(N) \
175 ((N < 3) ? 0 : \
176 (N < 5) ? 1 : \
177 (N < 8) ? 0 : \
178 (N < 14) ? 1 : \
179 0)
180
181 /* Convert data from raw format for register REGNUM
182 to virtual format for register REGNUM. */
183
184 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
185 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
186 (REGNUM < 5) ? i387_to_double((FROM), (TO)) : \
187 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
188 (REGNUM < 14) ? i387_to_double((FROM), (TO)) : \
189 bcopy ((FROM), (TO), 4))
190
191 extern void
192 i387_to_double PARAMS ((char *, char *));
193
194 /* Convert data from virtual format for register REGNUM
195 to raw format for register REGNUM. */
196
197 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
198 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
199 (REGNUM < 5) ? double_to_i387((FROM), (TO)) : \
200 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
201 (REGNUM < 14) ? double_to_i387((FROM), (TO)) : \
202 bcopy ((FROM), (TO), 4))
203
204 extern void
205 double_to_i387 PARAMS ((char *, char *));
206
207 /* Return the GDB type object for the "standard" data type
208 of data in register N. */
209
210 #define REGISTER_VIRTUAL_TYPE(N) \
211 ((N < 3) ? builtin_type_int : \
212 (N < 5) ? builtin_type_double : \
213 (N < 8) ? builtin_type_int : \
214 (N < 14) ? builtin_type_double : \
215 builtin_type_int)
216
217 /* from m-i386.h */
218 /* Store the address of the place in which to copy the structure the
219 subroutine will return. This is called from call_function. */
220
221 #define STORE_STRUCT_RETURN(ADDR, SP) \
222 { (SP) -= sizeof (ADDR); \
223 write_memory ((SP), &(ADDR), sizeof (ADDR)); \
224 write_register(0, (ADDR)); }
225
226 /* Extract from an array REGBUF containing the (raw) register state
227 a function return value of type TYPE, and copy that, in virtual format,
228 into VALBUF. */
229
230 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
231 symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
232
233 /* Write into appropriate registers a function return value
234 of type TYPE, given in virtual format. */
235
236 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
237 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
238
239 /* Extract from an array REGBUF containing the (raw) register state
240 the address in which a function should return its structure value,
241 as a CORE_ADDR (or an expression that can be used as one). */
242
243 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
244
245 \f
246 /* Describe the pointer in each stack frame to the previous stack frame
247 (its caller). */
248
249 /* FRAME_CHAIN takes a frame's nominal address
250 and produces the frame's chain-pointer.
251
252 However, if FRAME_CHAIN_VALID returns zero,
253 it means the given frame is the outermost one and has no caller. */
254
255 /* On Symmetry, %ebp points to caller's %ebp, and the return address
256 is right on top of that. */
257
258 #define FRAME_CHAIN(thisframe) \
259 (!inside_entry_file ((thisframe)->pc) ? \
260 read_memory_integer((thisframe)->frame, 4) :\
261 0)
262
263 #define FRAME_CHAIN_VALID(chain, thisframe) \
264 (chain != 0)
265
266 /* Define other aspects of the stack frame. */
267
268 /* A macro that tells us whether the function invocation represented
269 by FI does not have a frame on the stack associated with it. If it
270 does not, FRAMELESS is set to 1, else 0. */
271 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
272 (FRAMELESS) = frameless_look_for_prologue(FI)
273
274 #define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4))
275
276 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
277
278 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
279
280 /* Return number of args passed to a frame.
281 Can return -1, meaning no way to tell.
282
283 The weirdness in the "addl $imm8" case is due to gcc sometimes
284 issuing "addl $-int" after function call returns; this would
285 produce ridiculously huge arg counts. */
286
287 #define FRAME_NUM_ARGS(numargs, fi) \
288 { \
289 int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \
290 int narg; \
291 if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \
292 { \
293 numargs = 1; \
294 } \
295 else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \
296 { \
297 narg = ((op >> 16) & 0xff); \
298 numargs = (narg >= 128) ? -1 : narg / 4; \
299 } \
300 else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \
301 { \
302 narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \
303 numargs = (narg < 0) ? -1 : narg / 4; \
304 } \
305 else \
306 { \
307 numargs = -1; \
308 } \
309 }
310
311 /* Return number of bytes at start of arglist that are not really args. */
312
313 #define FRAME_ARGS_SKIP 8
314
315 /* Put here the code to store, into a struct frame_saved_regs,
316 the addresses of the saved registers of frame described by FRAME_INFO.
317 This includes special registers such as pc and fp saved in special
318 ways in the stack frame. sp is even more special:
319 the address we return for it IS the sp for the next frame. */
320
321 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
322 { i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
323
324 #ifdef __STDC__ /* Forward decl's for prototypes */
325 struct frame_info;
326 struct frame_saved_regs;
327 #endif
328
329 extern void
330 i386_frame_find_saved_regs PARAMS ((struct frame_info *,
331 struct frame_saved_regs *));
332
333 \f
334 /* Things needed for making the inferior call functions. */
335
336 #define PUSH_DUMMY_FRAME \
337 { CORE_ADDR sp = read_register (SP_REGNUM); \
338 int regnum; \
339 sp = push_word (sp, read_register (PC_REGNUM)); \
340 sp = push_word (sp, read_register (FP_REGNUM)); \
341 write_register (FP_REGNUM, sp); \
342 for (regnum = 0; regnum < NUM_REGS; regnum++) \
343 sp = push_word (sp, read_register (regnum)); \
344 write_register (SP_REGNUM, sp); \
345 }
346
347 #define POP_FRAME \
348 { \
349 FRAME frame = get_current_frame (); \
350 CORE_ADDR fp; \
351 int regnum; \
352 struct frame_saved_regs fsr; \
353 struct frame_info *fi; \
354 fi = get_frame_info (frame); \
355 fp = fi->frame; \
356 get_frame_saved_regs (fi, &fsr); \
357 for (regnum = 0; regnum < NUM_REGS; regnum++) { \
358 CORE_ADDR adr; \
359 adr = fsr.regs[regnum]; \
360 if (adr) \
361 write_register (regnum, read_memory_integer (adr, 4)); \
362 } \
363 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
364 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
365 write_register (SP_REGNUM, fp + 8); \
366 flush_cached_frames (); \
367 set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
368 read_pc ())); \
369 }
370
371 /* from i386-dep.c, worked better than my original... */
372 /* This sequence of words is the instructions
373 * call (32-bit offset)
374 * int 3
375 * This is 6 bytes.
376 */
377
378 #define CALL_DUMMY { 0x223344e8, 0xcc11 }
379
380 #define CALL_DUMMY_LENGTH 8
381
382 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
383
384 /* Insert the specified number of args and function address
385 into a call sequence of the above form stored at DUMMYNAME. */
386
387 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
388 { \
389 int from, to, delta, loc; \
390 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
391 from = loc + 5; \
392 to = (int)(fun); \
393 delta = to - from; \
394 *(int *)((char *)(dummyname) + 1) = delta; \
395 }
396
397 extern void
398 print_387_control_word PARAMS ((unsigned int));
399
400 extern void
401 print_387_status_word PARAMS ((unsigned int));
This page took 0.055698 seconds and 4 git commands to generate.