Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Parameters for a Sun 386i target machine, for GDB, the GNU debugger. |
b6ba6518 KB |
2 | Copyright 1986, 1987, 1991, 1992, 1993, 1994, 1995, 1999, 2000 |
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 | #if !defined (TM_SUN386_H) | |
23 | #define TM_SUN386_H 1 | |
24 | ||
f88e2c52 | 25 | #include "regcache.h" |
c906108c SS |
26 | #include "i386/tm-i386.h" |
27 | ||
28 | #ifndef sun386 | |
29 | #define sun386 | |
30 | #endif | |
c906108c SS |
31 | #define SUNOS4 |
32 | #define USE_MACHINE_REG_H | |
33 | ||
34 | /* Perhaps some day this will work even without the following #define */ | |
35 | #define COFF_ENCAPSULATE | |
36 | ||
37 | #ifdef COFF_ENCAPSULATE | |
38 | /* Avoid conflicts between our include files and <sys/exec.h> | |
39 | (maybe not needed anymore). */ | |
40 | #define _EXEC_ | |
41 | #endif | |
42 | ||
43 | /* sun386 ptrace seems unable to change the frame pointer */ | |
44 | #define PTRACE_FP_BUG | |
45 | ||
46 | /* Address of end of stack space. */ | |
47 | ||
48 | #define STACK_END_ADDR 0xfc000000 | |
49 | ||
50 | /* Number of machine registers */ | |
51 | ||
52 | #undef NUM_REGS | |
53 | #define NUM_REGS 35 | |
54 | ||
55 | /* Initializer for an array of names of registers. There should be NUM_REGS | |
56 | strings in this initializer. The order of the first 8 registers must match | |
57 | the compiler's numbering scheme (which is the same as the 386 scheme) also, | |
58 | this table must match regmap in i386-pinsn.c. */ | |
59 | ||
60 | #undef REGISTER_NAMES | |
61 | #define REGISTER_NAMES { "gs", "fs", "es", "ds", \ | |
62 | "edi", "esi", "ebp", "esp", \ | |
63 | "ebx", "edx", "ecx", "eax", \ | |
64 | "retaddr", "trapnum", "errcode", "ip", \ | |
65 | "cs", "ps", "sp", "ss", \ | |
66 | "fst0", "fst1", "fst2", "fst3", \ | |
67 | "fst4", "fst5", "fst6", "fst7", \ | |
68 | "fctrl", "fstat", "ftag", "fip", \ | |
69 | "fcs", "fopoff", "fopsel" \ | |
70 | } | |
71 | ||
72 | /* Register numbers of various important registers. | |
73 | Note that some of these values are "real" register numbers, | |
74 | and correspond to the general registers of the machine, | |
75 | and some are "phony" register numbers which are too large | |
76 | to be actual register numbers as far as the user is concerned | |
77 | but do serve to get the desired values when passed to read_register. */ | |
78 | ||
79 | #undef FP_REGNUM | |
c5aa993b | 80 | #define FP_REGNUM 6 /* (ebp) Contains address of executing stack frame */ |
c906108c | 81 | #undef SP_REGNUM |
c5aa993b | 82 | #define SP_REGNUM 18 /* (usp) Contains address of top of stack */ |
c906108c | 83 | #undef PS_REGNUM |
c5aa993b | 84 | #define PS_REGNUM 17 /* (ps) Contains processor status */ |
c906108c | 85 | #undef PC_REGNUM |
c5aa993b | 86 | #define PC_REGNUM 15 /* (eip) Contains program counter */ |
c906108c | 87 | #undef FP0_REGNUM |
c5aa993b | 88 | #define FP0_REGNUM 20 /* Floating point register 0 */ |
c906108c | 89 | #undef FPC_REGNUM |
c5aa993b | 90 | #define FPC_REGNUM 28 /* 80387 control register */ |
c906108c SS |
91 | |
92 | /* Total amount of space needed to store our copies of the machine's | |
93 | register state, the array `registers'. */ | |
94 | ||
95 | #undef REGISTER_BYTES | |
96 | #define REGISTER_BYTES (20*4+8*10+7*4) | |
97 | ||
98 | /* Index within `registers' of the first byte of the space for | |
99 | register N. */ | |
100 | ||
101 | #undef REGISTER_BYTE | |
102 | #define REGISTER_BYTE(N) \ | |
103 | ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 160 \ | |
104 | : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 10) + 80 \ | |
105 | : (N) * 4) | |
106 | ||
107 | /* Number of bytes of storage in the actual machine representation | |
108 | for register N. */ | |
109 | ||
110 | #undef REGISTER_RAW_SIZE | |
111 | #define REGISTER_RAW_SIZE(N) (((unsigned)((N) - FP0_REGNUM)) < 8 ? 10 : 4) | |
112 | ||
113 | /* Number of bytes of storage in the program's representation | |
114 | for register N. */ | |
115 | ||
116 | #undef REGISTER_VIRTUAL_SIZE | |
117 | #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)((N) - FP0_REGNUM)) < 8 ? 8 : 4) | |
118 | ||
119 | /* Nonzero if register N requires conversion | |
120 | from raw format to virtual format. */ | |
121 | ||
122 | #undef REGISTER_CONVERTIBLE | |
123 | #define REGISTER_CONVERTIBLE(N) (((unsigned)((N) - FP0_REGNUM)) < 8) | |
124 | ||
125 | /* Convert data from raw format for register REGNUM in buffer FROM | |
126 | to virtual format with type TYPE in buffer TO. */ | |
127 | ||
128 | #undef REGISTER_CONVERT_TO_VIRTUAL | |
129 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,TYPE,FROM,TO) \ | |
130 | { \ | |
131 | double val; \ | |
132 | i387_to_double ((FROM), (char *)&val); \ | |
133 | store_floating ((TO), TYPE_LENGTH (TYPE), val); \ | |
134 | } | |
a14ed312 | 135 | extern void i387_to_double (char *, char *); |
c906108c SS |
136 | |
137 | /* Convert data from virtual format with type TYPE in buffer FROM | |
138 | to raw format for register REGNUM in buffer TO. */ | |
139 | ||
140 | #undef REGISTER_CONVERT_TO_RAW | |
141 | #define REGISTER_CONVERT_TO_RAW(TYPE,REGNUM,FROM,TO) \ | |
142 | { \ | |
143 | double val = extract_floating ((FROM), TYPE_LENGTH (TYPE)); \ | |
144 | double_to_i387((char *)&val, (TO)); \ | |
145 | } | |
a14ed312 | 146 | extern void double_to_i387 (char *, char *); |
c906108c SS |
147 | |
148 | /* Return the GDB type object for the "standard" data type | |
149 | of data in register N. */ | |
150 | ||
151 | #undef REGISTER_VIRTUAL_TYPE | |
152 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
153 | (((unsigned)((N) - FP0_REGNUM)) < 8 ? builtin_type_double : builtin_type_int) | |
154 | ||
155 | /* Extract from an array REGBUF containing the (raw) register state | |
156 | a function return value of type TYPE, and copy that, in virtual format, | |
157 | into VALBUF. */ | |
158 | ||
159 | #undef EXTRACT_RETURN_VALUE | |
160 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
161 | memcpy (VALBUF, REGBUF + REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 11), TYPE_LENGTH (TYPE)) | |
162 | ||
163 | /* Write into appropriate registers a function return value | |
164 | of type TYPE, given in virtual format. */ | |
165 | ||
166 | #undef STORE_RETURN_VALUE | |
167 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
168 | write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 11), VALBUF, TYPE_LENGTH (TYPE)) | |
169 | ||
170 | /* Describe the pointer in each stack frame to the previous stack frame | |
171 | (its caller). */ | |
172 | ||
173 | /* FRAME_CHAIN takes a frame's nominal address | |
174 | and produces the frame's chain-pointer. */ | |
175 | ||
176 | #undef FRAME_CHAIN | |
177 | #define FRAME_CHAIN(thisframe) \ | |
178 | (!inside_entry_file ((thisframe)->pc) ? \ | |
179 | read_memory_integer ((thisframe)->frame, 4) :\ | |
180 | 0) | |
181 | ||
182 | /* Define other aspects of the stack frame. */ | |
183 | ||
184 | /* A macro that tells us whether the function invocation represented | |
185 | by FI does not have a frame on the stack associated with it. If it | |
186 | does not, FRAMELESS is set to 1, else 0. */ | |
187 | ||
188 | #undef FRAMELESS_FUNCTION_INVOCATION | |
392a587b JM |
189 | #define FRAMELESS_FUNCTION_INVOCATION(FI) \ |
190 | (frameless_look_for_prologue (FI)) | |
c906108c SS |
191 | |
192 | #undef FRAME_SAVED_PC | |
193 | #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) | |
194 | ||
195 | /* Insert the specified number of args and function address | |
196 | into a call sequence of the above form stored at DUMMYNAME. */ | |
197 | ||
198 | #undef FIX_CALL_DUMMY | |
199 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
200 | { \ | |
201 | *(int *)((char *)(dummyname) + 1) = (int)(fun) - (pc) - 5; \ | |
202 | } | |
203 | ||
204 | #endif /* !defined (TM_SUN386_H) */ |