]>
Commit | Line | Data |
---|---|---|
dd3b648e RP |
1 | /* Definitions to make GDB run on a Sequent Symmetry under dynix 3.0, |
2 | with Weitek 1167 and i387 support. | |
fbcb5095 | 3 | Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. |
dd3b648e RP |
4 | |
5 | This file is part of GDB. | |
6 | ||
99a7de40 | 7 | This program is free software; you can redistribute it and/or modify |
dd3b648e | 8 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
dd3b648e | 11 | |
99a7de40 | 12 | This program is distributed in the hope that it will be useful, |
dd3b648e RP |
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
99a7de40 JG |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
dd3b648e RP |
20 | |
21 | /* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */ | |
22 | ||
23 | /* I don't know if this will work for cross-debugging, even if you do get | |
24 | a copy of the right include file. */ | |
25 | #include <machine/reg.h> | |
26 | ||
27 | #define TARGET_BYTE_ORDER LITTLE_ENDIAN | |
28 | ||
29 | /* Define this if the C compiler puts an underscore at the front | |
30 | of external names before giving them to the linker. */ | |
31 | ||
32 | #define NAMES_HAVE_UNDERSCORE | |
33 | ||
dd3b648e RP |
34 | /* Offset from address of function to start of its code. |
35 | Zero on most machines. */ | |
36 | ||
37 | #define FUNCTION_START_OFFSET 0 | |
38 | ||
39 | /* Advance PC across any function entry prologue instructions | |
40 | to reach some "real" code. From m-i386.h */ | |
41 | ||
42 | #define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));} | |
43 | ||
44 | /* Immediately after a function call, return the saved pc. | |
45 | Can't always go through the frames for this because on some machines | |
46 | the new frame is not set up until the new function executes | |
47 | some instructions. */ | |
48 | ||
49 | #define SAVED_PC_AFTER_CALL(frame) \ | |
50 | read_memory_integer(read_register(SP_REGNUM), 4) | |
51 | ||
52 | /* I don't know the real values for these. */ | |
53 | #define TARGET_UPAGES UPAGES | |
54 | #define TARGET_NBPG NBPG | |
55 | ||
56 | /* Address of end of stack space. */ | |
57 | ||
58 | #define STACK_END_ADDR (0x40000000 - (TARGET_UPAGES * TARGET_NBPG)) | |
59 | ||
60 | /* Stack grows downward. */ | |
61 | ||
62 | #define INNER_THAN < | |
63 | ||
64 | /* Sequence of bytes for breakpoint instruction. */ | |
65 | ||
66 | #define BREAKPOINT {0xcc} | |
67 | ||
68 | /* Amount PC must be decremented by after a breakpoint. | |
69 | This is often the number of bytes in BREAKPOINT | |
70 | but not always. */ | |
71 | ||
72 | #define DECR_PC_AFTER_BREAK 0 | |
73 | ||
74 | /* Nonzero if instruction at PC is a return instruction. */ | |
75 | /* For Symmetry, this is really the 'leave' instruction, which */ | |
76 | /* is right before the ret */ | |
77 | ||
78 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9) | |
79 | ||
80 | /* Return 1 if P points to an invalid floating point value. | |
81 | */ | |
82 | ||
83 | #define INVALID_FLOAT(p, len) (0) | |
84 | ||
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 | ||
90 | /* Say how long (ordinary) registers are. */ | |
91 | ||
92 | #define REGISTER_TYPE long | |
93 | ||
94 | /* Number of machine registers */ | |
95 | #define NUM_REGS 49 | |
96 | ||
97 | /* Initializer for an array of names of registers. | |
98 | There should be NUM_REGS strings in this initializer. */ | |
99 | ||
100 | /* Symmetry registers are in this weird order to match the register | |
101 | numbers in the symbol table entries. If you change the order, | |
102 | things will probably break mysteriously for no apparent reason. | |
103 | Also note that the st(0)...st(7) 387 registers are represented as | |
104 | st0...st7. */ | |
105 | ||
106 | #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \ | |
107 | "ebx", "esi", "edi", "st2", "st3", \ | |
108 | "st4", "st5", "st6", "st7", "esp", \ | |
109 | "ebp", "eip", "eflags", "fp1", "fp2", \ | |
110 | "fp3", "fp4", "fp5", "fp6", "fp7", \ | |
111 | "fp8", "fp9", "fp10", "fp11", "fp12", \ | |
112 | "fp13", "fp14", "fp15", "fp16", "fp17", \ | |
113 | "fp18", "fp19", "fp20", "fp21", "fp22", \ | |
114 | "fp23", "fp24", "fp25", "fp26", "fp27", \ | |
115 | "fp28", "fp29", "fp30", "fp31" } | |
116 | ||
117 | /* Register numbers of various important registers. | |
118 | Note that some of these values are "real" register numbers, | |
119 | and correspond to the general registers of the machine, | |
120 | and some are "phony" register numbers which are too large | |
121 | to be actual register numbers as far as the user is concerned | |
122 | but do serve to get the desired values when passed to read_register. */ | |
123 | ||
124 | #define FP1_REGNUM 18 /* first 1167 register */ | |
125 | #define SP_REGNUM 14 /* Contains address of top of stack */ | |
126 | #define FP_REGNUM 15 /* Contains address of executing stack frame */ | |
127 | #define PC_REGNUM 16 /* Contains program counter */ | |
128 | #define PS_REGNUM 17 /* Contains processor status */ | |
129 | ||
dd3b648e RP |
130 | /* Total amount of space needed to store our copies of the machine's |
131 | register state, the array `registers'. */ | |
132 | /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */ | |
133 | #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4)) | |
134 | ||
135 | /* Index within `registers' of the first byte of the space for | |
136 | register N. */ | |
137 | ||
138 | #define REGISTER_BYTE(N) \ | |
139 | ((N < 3) ? (N * 4) : \ | |
140 | (N < 5) ? (((N - 2) * 10) + 2) : \ | |
141 | (N < 8) ? (((N - 5) * 4) + 32) : \ | |
142 | (N < 14) ? (((N - 8) * 10) + 44) : \ | |
143 | (((N - 14) * 4) + 104)) | |
144 | ||
145 | /* Number of bytes of storage in the actual machine representation | |
146 | * for register N. All registers are 4 bytes, except 387 st(0) - st(7), | |
147 | * which are 80 bits each. | |
148 | */ | |
149 | ||
150 | #define REGISTER_RAW_SIZE(N) \ | |
151 | ((N < 3) ? 4 : \ | |
152 | (N < 5) ? 10 : \ | |
153 | (N < 8) ? 4 : \ | |
154 | (N < 14) ? 10 : \ | |
155 | 4) | |
156 | ||
157 | /* Number of bytes of storage in the program's representation | |
158 | for register N. On the vax, all regs are 4 bytes. */ | |
159 | ||
160 | #define REGISTER_VIRTUAL_SIZE(N) 4 | |
161 | ||
162 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
163 | ||
164 | #define MAX_REGISTER_RAW_SIZE 10 | |
165 | ||
166 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
167 | ||
168 | #define MAX_REGISTER_VIRTUAL_SIZE 4 | |
169 | ||
170 | /* Nonzero if register N requires conversion | |
171 | from raw format to virtual format. */ | |
172 | ||
173 | #define REGISTER_CONVERTIBLE(N) \ | |
174 | ((N < 3) ? 0 : \ | |
175 | (N < 5) ? 1 : \ | |
176 | (N < 8) ? 0 : \ | |
177 | (N < 14) ? 1 : \ | |
178 | 0) | |
179 | ||
180 | /* Convert data from raw format for register REGNUM | |
181 | to virtual format for register REGNUM. */ | |
182 | ||
183 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ | |
184 | ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \ | |
185 | (REGNUM < 5) ? i387_to_double((FROM), (TO)) : \ | |
186 | (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \ | |
187 | (REGNUM < 14) ? i387_to_double((FROM), (TO)) : \ | |
188 | bcopy ((FROM), (TO), 4)) | |
189 | ||
190 | /* Convert data from virtual format for register REGNUM | |
191 | to raw format for register REGNUM. */ | |
192 | ||
193 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ | |
194 | ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \ | |
195 | (REGNUM < 5) ? double_to_i387((FROM), (TO)) : \ | |
196 | (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \ | |
197 | (REGNUM < 14) ? double_to_i387((FROM), (TO)) : \ | |
198 | bcopy ((FROM), (TO), 4)) | |
199 | ||
200 | /* Return the GDB type object for the "standard" data type | |
201 | of data in register N. */ | |
202 | ||
203 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
204 | ((N < 3) ? builtin_type_int : \ | |
205 | (N < 5) ? builtin_type_double : \ | |
206 | (N < 8) ? builtin_type_int : \ | |
207 | (N < 14) ? builtin_type_double : \ | |
208 | builtin_type_int) | |
209 | ||
210 | /* from m-i386.h */ | |
211 | /* Store the address of the place in which to copy the structure the | |
212 | subroutine will return. This is called from call_function. */ | |
213 | ||
214 | #define STORE_STRUCT_RETURN(ADDR, SP) \ | |
215 | { (SP) -= sizeof (ADDR); \ | |
216 | write_memory ((SP), &(ADDR), sizeof (ADDR)); \ | |
217 | write_register(0, (ADDR)); } | |
218 | ||
219 | /* Extract from an array REGBUF containing the (raw) register state | |
220 | a function return value of type TYPE, and copy that, in virtual format, | |
221 | into VALBUF. */ | |
222 | ||
223 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
224 | symmetry_extract_return_value(TYPE, REGBUF, VALBUF) | |
225 | ||
226 | /* Write into appropriate registers a function return value | |
227 | of type TYPE, given in virtual format. */ | |
228 | ||
229 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
230 | write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) | |
231 | ||
232 | /* Extract from an array REGBUF containing the (raw) register state | |
233 | the address in which a function should return its structure value, | |
234 | as a CORE_ADDR (or an expression that can be used as one). */ | |
235 | ||
236 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) | |
237 | ||
238 | \f | |
239 | /* Describe the pointer in each stack frame to the previous stack frame | |
240 | (its caller). */ | |
241 | ||
242 | /* FRAME_CHAIN takes a frame's nominal address | |
243 | and produces the frame's chain-pointer. | |
244 | ||
245 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address | |
246 | and produces the nominal address of the caller frame. | |
247 | ||
248 | However, if FRAME_CHAIN_VALID returns zero, | |
249 | it means the given frame is the outermost one and has no caller. | |
250 | In that case, FRAME_CHAIN_COMBINE is not used. */ | |
251 | ||
252 | /* On Symmetry, %ebp points to caller's %ebp, and the return address | |
253 | is right on top of that. | |
254 | */ | |
255 | ||
256 | #define FRAME_CHAIN(thisframe) \ | |
257 | (outside_startup_file ((thisframe)->pc) ? \ | |
258 | read_memory_integer((thisframe)->frame, 4) :\ | |
259 | 0) | |
260 | ||
261 | #define FRAME_CHAIN_VALID(chain, thisframe) \ | |
262 | (chain != 0) | |
263 | ||
264 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) | |
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 | \f | |
325 | /* Things needed for making the inferior call functions. */ | |
326 | ||
327 | #define PUSH_DUMMY_FRAME \ | |
328 | { CORE_ADDR sp = read_register (SP_REGNUM); \ | |
329 | int regnum; \ | |
330 | sp = push_word (sp, read_register (PC_REGNUM)); \ | |
331 | sp = push_word (sp, read_register (FP_REGNUM)); \ | |
332 | write_register (FP_REGNUM, sp); \ | |
333 | for (regnum = 0; regnum < NUM_REGS; regnum++) \ | |
334 | sp = push_word (sp, read_register (regnum)); \ | |
335 | write_register (SP_REGNUM, sp); \ | |
336 | } | |
337 | ||
338 | #define POP_FRAME \ | |
339 | { \ | |
340 | FRAME frame = get_current_frame (); \ | |
341 | CORE_ADDR fp; \ | |
342 | int regnum; \ | |
343 | struct frame_saved_regs fsr; \ | |
344 | struct frame_info *fi; \ | |
345 | fi = get_frame_info (frame); \ | |
346 | fp = fi->frame; \ | |
347 | get_frame_saved_regs (fi, &fsr); \ | |
348 | for (regnum = 0; regnum < NUM_REGS; regnum++) { \ | |
349 | CORE_ADDR adr; \ | |
350 | adr = fsr.regs[regnum]; \ | |
351 | if (adr) \ | |
352 | write_register (regnum, read_memory_integer (adr, 4)); \ | |
353 | } \ | |
354 | write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ | |
355 | write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ | |
356 | write_register (SP_REGNUM, fp + 8); \ | |
357 | flush_cached_frames (); \ | |
358 | set_current_frame ( create_new_frame (read_register (FP_REGNUM), \ | |
359 | read_pc ())); \ | |
360 | } | |
361 | ||
362 | /* from i386-dep.c, worked better than my original... */ | |
363 | /* This sequence of words is the instructions | |
364 | * call (32-bit offset) | |
365 | * int 3 | |
366 | * This is 6 bytes. | |
367 | */ | |
368 | ||
369 | #define CALL_DUMMY { 0x223344e8, 0xcc11 } | |
370 | ||
371 | #define CALL_DUMMY_LENGTH 8 | |
372 | ||
373 | #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ | |
374 | ||
375 | /* Insert the specified number of args and function address | |
376 | into a call sequence of the above form stored at DUMMYNAME. */ | |
377 | ||
378 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
379 | { \ | |
380 | int from, to, delta, loc; \ | |
381 | loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \ | |
382 | from = loc + 5; \ | |
383 | to = (int)(fun); \ | |
384 | delta = to - from; \ | |
385 | *(int *)((char *)(dummyname) + 1) = delta; \ | |
386 | } |