]> Git Repo - binutils.git/blob - gdb/config/i386/tm-symmetry.h
* config/i960/nindy960.mt: Don't define REMOTE_O; REMOTE_O was
[binutils.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 ([email protected]).
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 #ifdef _SEQUENT_
25 /* ptx */
26 #include <sys/reg.h>
27 #else
28 /* dynix */
29 #include <machine/reg.h>
30 #endif
31
32 #ifdef _SEQUENT_
33 /* ptx, not dynix */
34 #define SDB_REG_TO_REGNUM(value) ptx_coff_regno_to_gdb(value)
35 extern int ptx_coff_regno_to_gdb();
36 #endif /* _SEQUENT_ */
37
38 #define START_INFERIOR_TRAPS_EXPECTED 2
39
40 /* Amount PC must be decremented by after a breakpoint.
41    This is often the number of bytes in BREAKPOINT
42    but not always.  */
43
44 #define DECR_PC_AFTER_BREAK 0
45
46 #include "i386/tm-i386v.h"
47
48 /* Nonzero if instruction at PC is a return instruction.  */
49 /* For Symmetry, this is really the 'leave' instruction, which */
50 /* is right before the ret */
51
52 #undef
53 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
54
55 #if 0
56  --- this code can't be used unless we know we are running native,
57      since it uses host specific ptrace calls.
58 /* code for 80387 fpu.  Functions are from i386-dep.c, copied into
59  * symm-dep.c.
60  */
61 #define FLOAT_INFO { i386_float_info(); }
62 #endif
63
64 /* Number of machine registers */
65 #undef NUM_REGS
66 #define NUM_REGS 49
67
68 /* Initializer for an array of names of registers.
69    There should be NUM_REGS strings in this initializer.  */
70
71 /* Symmetry registers are in this weird order to match the register
72    numbers in the symbol table entries.  If you change the order,
73    things will probably break mysteriously for no apparent reason.
74    Also note that the st(0)...st(7) 387 registers are represented as
75    st0...st7.  */
76
77 #undef REGISTER_NAMES
78 #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \
79                              "ebx", "esi", "edi", "st2", "st3", \
80                              "st4", "st5", "st6", "st7", "esp", \
81                              "ebp", "eip", "eflags", "fp1", "fp2", \
82                              "fp3", "fp4", "fp5", "fp6", "fp7", \
83                              "fp8", "fp9", "fp10", "fp11", "fp12", \
84                              "fp13", "fp14", "fp15", "fp16", "fp17", \
85                              "fp18", "fp19", "fp20", "fp21", "fp22", \
86                              "fp23", "fp24", "fp25", "fp26", "fp27", \
87                              "fp28", "fp29", "fp30", "fp31" }
88
89 /* Register numbers of various important registers.
90    Note that some of these values are "real" register numbers,
91    and correspond to the general registers of the machine,
92    and some are "phony" register numbers which are too large
93    to be actual register numbers as far as the user is concerned
94    but do serve to get the desired values when passed to read_register.  */
95
96 #define EAX_REGNUM      0
97 #define EDX_REGNUM      1
98 #define ECX_REGNUM      2
99 #define ST0_REGNUM      3
100 #define ST1_REGNUM      4
101 #define EBX_REGNUM      5
102 #define ESI_REGNUM      6
103 #define EDI_REGNUM      7
104 #define ST2_REGNUM      8
105 #define ST3_REGNUM      9
106
107 #define ST4_REGNUM      10
108 #define ST5_REGNUM      11
109 #define ST6_REGNUM      12
110 #define ST7_REGNUM      13
111
112 #define FP1_REGNUM 18           /* first 1167 register */
113 /* Get %fp2 - %fp31 by addition, since they are contiguous */
114
115 #undef SP_REGNUM
116 #define SP_REGNUM 14            /* Contains address of top of stack */
117 #undef FP_REGNUM
118 #define FP_REGNUM 15            /* Contains address of executing stack frame */
119 #undef PC_REGNUM
120 #define PC_REGNUM 16            /* Contains program counter */
121 #undef PS_REGNUM
122 #define PS_REGNUM 17            /* Contains processor status */
123
124 #ifndef _SEQUENT_
125 /* dynix, not ptx.  For ptx, see register_addr in symm-tdep.c */
126
127 /* The magic numbers below are offsets into u_ar0 in the user struct.
128  * They live in <machine/reg.h>.  Gdb calls this macro with blockend
129  * holding u.u_ar0 - KERNEL_U_ADDR.  Only the registers listed are
130  * saved in the u area (along with a few others that aren't useful
131  * here.  See <machine/reg.h>).
132  */
133
134 #define REGISTER_U_ADDR(addr, blockend, regno) \
135 { struct user foo;      /* needed for finding fpu regs */ \
136 switch (regno) { \
137     case 0: \
138       addr = blockend + EAX * sizeof(int); break; \
139   case 1: \
140       addr = blockend + EDX * sizeof(int); break; \
141   case 2: \
142       addr = blockend + ECX * sizeof(int); break; \
143   case 3:                       /* st(0) */ \
144       addr = blockend - \
145           ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \
146       break; \
147   case 4:                       /* st(1) */ \
148       addr = blockend - \
149           ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \
150       break; \
151   case 5: \
152       addr = blockend + EBX * sizeof(int); break; \
153   case 6: \
154       addr = blockend + ESI * sizeof(int); break; \
155   case 7: \
156       addr = blockend + EDI * sizeof(int); break; \
157   case 8:                       /* st(2) */ \
158       addr = blockend - \
159           ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \
160       break; \
161   case 9:                       /* st(3) */ \
162       addr = blockend - \
163           ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \
164       break; \
165   case 10:                      /* st(4) */ \
166       addr = blockend - \
167           ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \
168       break; \
169   case 11:                      /* st(5) */ \
170       addr = blockend - \
171           ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \
172       break; \
173   case 12:                      /* st(6) */ \
174       addr = blockend - \
175           ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \
176       break; \
177   case 13:                      /* st(7) */ \
178       addr = blockend - \
179           ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \
180       break; \
181   case 14: \
182       addr = blockend + ESP * sizeof(int); break; \
183   case 15: \
184       addr = blockend + EBP * sizeof(int); break; \
185   case 16: \
186       addr = blockend + EIP * sizeof(int); break; \
187   case 17: \
188       addr = blockend + FLAGS * sizeof(int); break; \
189   case 18:                      /* fp1 */ \
190   case 19:                      /* fp2 */ \
191   case 20:                      /* fp3 */ \
192   case 21:                      /* fp4 */ \
193   case 22:                      /* fp5 */ \
194   case 23:                      /* fp6 */ \
195   case 24:                      /* fp7 */ \
196   case 25:                      /* fp8 */ \
197   case 26:                      /* fp9 */ \
198   case 27:                      /* fp10 */ \
199   case 28:                      /* fp11 */ \
200   case 29:                      /* fp12 */ \
201   case 30:                      /* fp13 */ \
202   case 31:                      /* fp14 */ \
203   case 32:                      /* fp15 */ \
204   case 33:                      /* fp16 */ \
205   case 34:                      /* fp17 */ \
206   case 35:                      /* fp18 */ \
207   case 36:                      /* fp19 */ \
208   case 37:                      /* fp20 */ \
209   case 38:                      /* fp21 */ \
210   case 39:                      /* fp22 */ \
211   case 40:                      /* fp23 */ \
212   case 41:                      /* fp24 */ \
213   case 42:                      /* fp25 */ \
214   case 43:                      /* fp26 */ \
215   case 44:                      /* fp27 */ \
216   case 45:                      /* fp28 */ \
217   case 46:                      /* fp29 */ \
218   case 47:                      /* fp30 */ \
219   case 48:                      /* fp31 */ \
220      addr = blockend - \
221          ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \
222   } \
223 }
224 #endif /* _SEQUENT_ */
225 \f
226 /* Total amount of space needed to store our copies of the machine's
227    register state, the array `registers'.  */
228 /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */
229 #undef REGISTER_BYTES
230 #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
231
232 /* Index within `registers' of the first byte of the space for
233    register N.  */
234
235 #undef REGISTER_BYTE
236 #define REGISTER_BYTE(N)                \
237 ((N < 3) ? (N * 4) :                    \
238 (N < 5) ? (((N - 2) * 10) + 2) :        \
239 (N < 8) ? (((N - 5) * 4) + 32) :        \
240 (N < 14) ? (((N - 8) * 10) + 44) :      \
241     (((N - 14) * 4) + 104))
242
243 /* Number of bytes of storage in the actual machine representation
244  * for register N.  All registers are 4 bytes, except 387 st(0) - st(7),
245  * which are 80 bits each. 
246  */
247
248 #undef REGISTER_RAW_SIZE
249 #define REGISTER_RAW_SIZE(N) \
250 ((N < 3) ? 4 :  \
251 (N < 5) ? 10 :  \
252 (N < 8) ? 4 :   \
253 (N < 14) ? 10 : \
254     4)
255
256 /* Largest value REGISTER_RAW_SIZE can have.  */
257
258 #undef MAX_REGISTER_RAW_SIZE
259 #define MAX_REGISTER_RAW_SIZE 10
260
261 /* Nonzero if register N requires conversion
262    from raw format to virtual format.  */
263
264 #undef REGISTER_CONVERTIBLE
265 #define REGISTER_CONVERTIBLE(N) \
266 ((N < 3) ? 0 : \
267 (N < 5) ? 1  : \
268 (N < 8) ? 0  : \
269 (N < 14) ? 1 : \
270     0)
271
272 /* Convert data from raw format for register REGNUM
273    to virtual format for register REGNUM.  */
274
275 #undef REGISTER_CONVERT_TO_VIRTUAL
276 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO)     \
277 ((REGNUM < 3) ? memcpy ((TO), (FROM), 4) : \
278 (REGNUM < 5) ? i387_to_double((FROM), (TO)) : \
279 (REGNUM < 8) ? memcpy ((TO), (FROM), 4) : \
280 (REGNUM < 14) ? i387_to_double((FROM), (TO)) : \
281     memcpy ((TO), (FROM), 4))
282
283 extern void
284 i387_to_double PARAMS ((char *, char *));
285
286 /* Convert data from virtual format for register REGNUM
287    to raw format for register REGNUM.  */
288
289 #undef REGISTER_CONVERT_TO_RAW
290 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
291 ((REGNUM < 3) ? memcpy ((TO), (FROM), 4) : \
292 (REGNUM < 5) ? double_to_i387((FROM), (TO)) : \
293 (REGNUM < 8) ? memcpy ((TO), (FROM), 4) : \
294 (REGNUM < 14) ? double_to_i387((FROM), (TO)) : \
295     memcpy ((TO), (FROM), 4))
296
297 extern void
298 double_to_i387 PARAMS ((char *, char *));
299
300 /* Return the GDB type object for the "standard" data type
301    of data in register N.  */
302
303 #undef REGISTER_VIRTUAL_TYPE
304 #define REGISTER_VIRTUAL_TYPE(N) \
305 ((N < 3) ? builtin_type_int : \
306 (N < 5) ? builtin_type_double : \
307 (N < 8) ? builtin_type_int : \
308 (N < 14) ? builtin_type_double : \
309     builtin_type_int)
310
311 /* from m-i386.h (now known as tm-i386v.h).  */
312 /* Store the address of the place in which to copy the structure the
313    subroutine will return.  This is called from call_function.  FIXME:
314    Why is it writing register 0?  Is the symmetry different from tm-i386v.h,
315    or is it some sort of artifact?  FIXME.  */
316
317 #undef STORE_STRUCT_RETURN
318 #define STORE_STRUCT_RETURN(ADDR, SP) \
319   { (SP) -= sizeof (ADDR);              \
320     write_memory ((SP), &(ADDR), sizeof (ADDR)); \
321     write_register(0, (ADDR)); }
322
323 /* Extract from an array REGBUF containing the (raw) register state
324    a function return value of type TYPE, and copy that, in virtual format,
325    into VALBUF.  */
326
327 #undef EXTRACT_RETURN_VALUE
328 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
329   symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
330
331 \f
332 /* Things needed for making the inferior call functions.  FIXME: Merge
333    this with the main 386 stuff.  */
334
335 #define PUSH_DUMMY_FRAME \
336 {  CORE_ADDR sp = read_register (SP_REGNUM); \
337   int regnum; \
338   sp = push_word (sp, read_register (PC_REGNUM)); \
339   sp = push_word (sp, read_register (FP_REGNUM)); \
340   write_register (FP_REGNUM, sp); \
341   for (regnum = 0; regnum < NUM_REGS; regnum++) \
342     sp = push_word (sp, read_register (regnum)); \
343   write_register (SP_REGNUM, sp); \
344 }
345
346 #define POP_FRAME  \
347 { \
348   FRAME frame = get_current_frame (); \
349   CORE_ADDR fp; \
350   int regnum; \
351   struct frame_saved_regs fsr; \
352   struct frame_info *fi; \
353   fi = get_frame_info (frame); \
354   fp = fi->frame; \
355   get_frame_saved_regs (fi, &fsr); \
356   for (regnum = 0; regnum < NUM_REGS; regnum++) { \
357       CORE_ADDR adr; \
358       adr = fsr.regs[regnum]; \
359       if (adr) \
360         write_register (regnum, read_memory_integer (adr, 4)); \
361   } \
362   write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
363   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
364   write_register (SP_REGNUM, fp + 8); \
365   flush_cached_frames (); \
366   set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
367                                         read_pc ())); \
368 }
369
370 /* from i386-dep.c, worked better than my original... */
371 /* This sequence of words is the instructions
372  * call (32-bit offset)
373  * int 3
374  * This is 6 bytes.
375  */
376
377 #define CALL_DUMMY { 0x223344e8, 0xcc11 }
378
379 #define CALL_DUMMY_LENGTH 8
380
381 #define CALL_DUMMY_START_OFFSET 0  /* Start execution at beginning of dummy */
382
383 /* Insert the specified number of args and function address
384    into a call sequence of the above form stored at DUMMYNAME.  */
385
386 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \
387 { \
388         int from, to, delta, loc; \
389         loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
390         from = loc + 5; \
391         to = (int)(fun); \
392         delta = to - from; \
393         *(int *)((char *)(dummyname) + 1) = delta; \
394 }
395
396 extern void
397 print_387_control_word PARAMS ((unsigned int));
398
399 extern void
400 print_387_status_word PARAMS ((unsigned int));
This page took 0.047572 seconds and 4 git commands to generate.