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