a15f45f1c9595f32cae9f84766a03307c9c74aa6
[external/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
4    Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 2003 Free
5    Software Foundation, Inc.
6
7    Symmetry version by Jay Vosburgh (fubar@sequent.com).
8
9    This file is part of GDB.
10
11    This program is free software; you can redistribute it and/or modify
12    it under the terms of the GNU General Public License as published by
13    the Free Software Foundation; either version 2 of the License, or
14    (at your option) any later version.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19    GNU General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 59 Temple Place - Suite 330,
24    Boston, MA 02111-1307, USA.  */
25
26 #ifndef TM_SYMMETRY_H
27 #define TM_SYMMETRY_H 1
28
29 #include "regcache.h"
30 #include "doublest.h"
31
32 /* I don't know if this will work for cross-debugging, even if you do get
33    a copy of the right include file.  */
34 #include <machine/reg.h>
35
36 #include "i386/tm-i386.h"
37
38 /* Amount PC must be decremented by after a breakpoint.  This is often the
39    number of bytes in BREAKPOINT but not always (such as now). */
40
41 #undef DECR_PC_AFTER_BREAK
42 #define DECR_PC_AFTER_BREAK 0
43
44 /* Number of machine registers */
45
46 #undef NUM_REGS
47 #define NUM_REGS 49
48
49 /* Initializer for an array of names of registers.
50    There should be NUM_REGS strings in this initializer.  */
51
52 /* Initializer for an array of names of registers.  There should be at least
53    NUM_REGS strings in this initializer.  Any excess ones are simply ignored.
54    Symmetry registers are in this weird order to match the register numbers
55    in the symbol table entries.  If you change the order, things will probably
56    break mysteriously for no apparent reason.  Also note that the st(0)...
57    st(7) 387 registers are represented as st0...st7.  */
58
59 #undef REGISTER_NAME
60 #define REGISTER_NAMES {     "eax",  "edx",  "ecx",   "st0",  "st1", \
61                              "ebx",  "esi",  "edi",   "st2",  "st3", \
62                              "st4",  "st5",  "st6",   "st7",  "esp", \
63                              "ebp",  "eip",  "eflags","fp1",  "fp2", \
64                              "fp3",  "fp4",  "fp5",   "fp6",  "fp7", \
65                              "fp8",  "fp9",  "fp10",  "fp11", "fp12", \
66                              "fp13", "fp14", "fp15",  "fp16", "fp17", \
67                              "fp18", "fp19", "fp20",  "fp21", "fp22", \
68                              "fp23", "fp24", "fp25",  "fp26", "fp27", \
69                              "fp28", "fp29", "fp30",  "fp31" }
70
71 /* Register numbers of various important registers.
72    Note that some of these values are "real" register numbers,
73    and correspond to the general registers of the machine,
74    and some are "phony" register numbers which are too large
75    to be actual register numbers as far as the user is concerned
76    but do serve to get the desired values when passed to read_register.  */
77
78 #define EAX_REGNUM      0
79 #define EDX_REGNUM      1
80 #define ECX_REGNUM      2
81 #define ST0_REGNUM      3
82 #define ST1_REGNUM      4
83 #define EBX_REGNUM      5
84 #define ESI_REGNUM      6
85 #define EDI_REGNUM      7
86 #define ST2_REGNUM      8
87 #define ST3_REGNUM      9
88
89 #define ST4_REGNUM      10
90 #define ST5_REGNUM      11
91 #define ST6_REGNUM      12
92 #define ST7_REGNUM      13
93
94 #define FP1_REGNUM 18           /* first 1167 register */
95 /* Get %fp2 - %fp31 by addition, since they are contiguous */
96
97 #undef  SP_REGNUM
98 #define SP_REGNUM 14            /* (usp) Contains address of top of stack */
99 #define ESP_REGNUM 14
100 #undef  FP_REGNUM
101 #define FP_REGNUM 15            /* (ebp) Contains address of executing stack frame */
102 #define EBP_REGNUM 15
103 #undef  PC_REGNUM
104 #define PC_REGNUM 16            /* (eip) Contains program counter */
105 #define EIP_REGNUM 16
106 #undef  PS_REGNUM
107 #define PS_REGNUM 17            /* (ps)  Contains processor status */
108 #define EFLAGS_REGNUM 17
109
110 /*
111  * Following macro translates i386 opcode register numbers to Symmetry
112  * register numbers.  This is used by i386_frame_find_saved_regs.
113  *
114  *           %eax  %ecx  %edx  %ebx  %esp  %ebp  %esi  %edi
115  * i386        0     1     2     3     4     5     6     7
116  * Symmetry    0     2     1     5    14    15     6     7
117  *
118  */
119 #define I386_REGNO_TO_SYMMETRY(n) \
120 ((n)==0?0 :(n)==1?2 :(n)==2?1 :(n)==3?5 :(n)==4?14 :(n)==5?15 :(n))
121
122 /* The magic numbers below are offsets into u_ar0 in the user struct.
123  * They live in <machine/reg.h>.  Gdb calls this macro with blockend
124  * holding u.u_ar0 - KERNEL_U_ADDR.  Only the registers listed are
125  * saved in the u area (along with a few others that aren't useful
126  * here.  See <machine/reg.h>).
127  */
128
129 #define REGISTER_U_ADDR(addr, blockend, regno) \
130 { struct user foo;      /* needed for finding fpu regs */ \
131 switch (regno) { \
132     case 0: \
133       addr = blockend + EAX * sizeof(int); break; \
134   case 1: \
135       addr = blockend + EDX * sizeof(int); break; \
136   case 2: \
137       addr = blockend + ECX * sizeof(int); break; \
138   case 3:                       /* st(0) */ \
139       addr = ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \
140       break; \
141   case 4:                       /* st(1) */ \
142       addr = ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \
143       break; \
144   case 5: \
145       addr = blockend + EBX * sizeof(int); break; \
146   case 6: \
147       addr = blockend + ESI * sizeof(int); break; \
148   case 7: \
149       addr = blockend + EDI * sizeof(int); break; \
150   case 8:                       /* st(2) */ \
151       addr = ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \
152       break; \
153   case 9:                       /* st(3) */ \
154       addr = ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \
155       break; \
156   case 10:                      /* st(4) */ \
157       addr = ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \
158       break; \
159   case 11:                      /* st(5) */ \
160       addr = ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \
161       break; \
162   case 12:                      /* st(6) */ \
163       addr = ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \
164       break; \
165   case 13:                      /* st(7) */ \
166       addr = ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \
167       break; \
168   case 14: \
169       addr = blockend + ESP * sizeof(int); break; \
170   case 15: \
171       addr = blockend + EBP * sizeof(int); break; \
172   case 16: \
173       addr = blockend + EIP * sizeof(int); break; \
174   case 17: \
175       addr = blockend + FLAGS * sizeof(int); break; \
176   case 18:                      /* fp1 */ \
177   case 19:                      /* fp2 */ \
178   case 20:                      /* fp3 */ \
179   case 21:                      /* fp4 */ \
180   case 22:                      /* fp5 */ \
181   case 23:                      /* fp6 */ \
182   case 24:                      /* fp7 */ \
183   case 25:                      /* fp8 */ \
184   case 26:                      /* fp9 */ \
185   case 27:                      /* fp10 */ \
186   case 28:                      /* fp11 */ \
187   case 29:                      /* fp12 */ \
188   case 30:                      /* fp13 */ \
189   case 31:                      /* fp14 */ \
190   case 32:                      /* fp15 */ \
191   case 33:                      /* fp16 */ \
192   case 34:                      /* fp17 */ \
193   case 35:                      /* fp18 */ \
194   case 36:                      /* fp19 */ \
195   case 37:                      /* fp20 */ \
196   case 38:                      /* fp21 */ \
197   case 39:                      /* fp22 */ \
198   case 40:                      /* fp23 */ \
199   case 41:                      /* fp24 */ \
200   case 42:                      /* fp25 */ \
201   case 43:                      /* fp26 */ \
202   case 44:                      /* fp27 */ \
203   case 45:                      /* fp28 */ \
204   case 46:                      /* fp29 */ \
205   case 47:                      /* fp30 */ \
206   case 48:                      /* fp31 */ \
207      addr = ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \
208   } \
209 }
210
211 /* Total amount of space needed to store our copies of the machine's
212    register state, the array `registers'.  10 i*86 registers, 8 i387
213    registers, and 31 Weitek 1167 registers */
214
215 #undef  REGISTER_BYTES
216 #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
217
218 /* Nonzero if register N requires conversion
219    from raw format to virtual format.  */
220
221 #undef  REGISTER_CONVERTIBLE
222 #define REGISTER_CONVERTIBLE(N) \
223 (((N) < 3) ? 0 : \
224 ((N) < 5) ? 1  : \
225 ((N) < 8) ? 0  : \
226 ((N) < 14) ? 1 : \
227     0)
228
229 #include "floatformat.h"
230
231 /* Convert data from raw format for register REGNUM in buffer FROM
232    to virtual format with type TYPE in buffer TO.  */
233
234 #undef REGISTER_CONVERT_TO_VIRTUAL
235 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \
236 { \
237   DOUBLEST val; \
238   floatformat_to_doublest (&floatformat_i387_ext, (FROM), &val); \
239   store_floating ((TO), TYPE_LENGTH (TYPE), val); \
240 }
241
242 /* Convert data from virtual format with type TYPE in buffer FROM
243    to raw format for register REGNUM in buffer TO.  */
244
245 #undef REGISTER_CONVERT_TO_RAW
246 #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \
247 { \
248   DOUBLEST val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \
249   floatformat_from_doublest (&floatformat_i387_ext, &val, (TO)); \
250 }
251
252 /* Return the GDB type object for the "standard" data type
253    of data in register N.  */
254
255 #undef REGISTER_VIRTUAL_TYPE
256 #define REGISTER_VIRTUAL_TYPE(N) \
257 ((N < 3) ? builtin_type_int : \
258 (N < 5) ? builtin_type_double : \
259 (N < 8) ? builtin_type_int : \
260 (N < 14) ? builtin_type_double : \
261     builtin_type_int)
262
263 /* Store the address of the place in which to copy the structure the
264    subroutine will return.  This is called from call_function.
265    Native cc passes the address in eax, gcc (up to version 2.5.8)
266    passes it on the stack.  gcc should be fixed in future versions to
267    adopt native cc conventions.  */
268
269 #undef  PUSH_ARGUMENTS
270 #undef  STORE_STRUCT_RETURN
271 #define STORE_STRUCT_RETURN(ADDR, SP) write_register(0, (ADDR))
272
273 /* Extract from an array REGBUF containing the (raw) register state
274    a function return value of type TYPE, and copy that, in virtual format,
275    into VALBUF.  */
276
277 #undef  DEPRECATED_EXTRACT_RETURN_VALUE
278 #define DEPRECATED_EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
279   symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
280
281 /* The following redefines make backtracing through sigtramp work.
282    They manufacture a fake sigtramp frame and obtain the saved pc in sigtramp
283    from the sigcontext structure which is pushed by the kernel on the
284    user stack, along with a pointer to it.  */
285
286 #define IN_SIGTRAMP(pc, name) ((name) && STREQ ("_sigcode", name))
287
288 /* Offset to saved PC in sigcontext, from <signal.h>.  */
289 #define SIGCONTEXT_PC_OFFSET 16
290
291 #endif /* ifndef TM_SYMMETRY_H */