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.
5 This file is part of GDB.
7 GDB 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 1, or (at your option)
12 GDB 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.
17 You should have received a copy of the GNU General Public License
18 along with GDB; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */
23 #include <machine/reg.h>
27 /* This machine doesn't have the siginterrupt call. */
28 #define NO_SIGINTERRUPT
30 #define HAVE_WAIT_STRUCT
32 /* Define the bit, byte, and word ordering of the machine. */
33 /* #define BITS_BIG_ENDIAN */
34 /* #define BYTES_BIG_ENDIAN */
35 /* #define WORDS_BIG_ENDIAN */
37 /* Define SFILE_FN_FLAGGED if the source file is flagged with an N_FN
38 symbol instead of an N_TEXT symbol. */
40 #define OFILE_FN_FLAGGED
42 /* Get rid of any system-imposed stack limit if possible. */
44 #define SET_STACK_LIMIT_HUGE
46 /* Define this if the C compiler puts an underscore at the front
47 of external names before giving them to the linker. */
49 #define NAMES_HAVE_UNDERSCORE
51 /* Debugger information will be in DBX format. */
53 #define READ_DBX_FORMAT
55 /* Offset from address of function to start of its code.
56 Zero on most machines. */
58 #define FUNCTION_START_OFFSET 0
60 /* Advance PC across any function entry prologue instructions
61 to reach some "real" code. From m-i386.h */
63 #define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
65 /* Immediately after a function call, return the saved pc.
66 Can't always go through the frames for this because on some machines
67 the new frame is not set up until the new function executes
70 #define SAVED_PC_AFTER_CALL(frame) \
71 read_memory_integer(read_register(SP_REGNUM), 4)
73 /* This is the amount to subtract from u.u_ar0
74 to get the offset in the core file of the register values. */
76 #define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG))
78 /* Address of end of stack space. */
80 #define STACK_END_ADDR (0x40000000 - (UPAGES * NBPG))
82 /* Stack grows downward. */
86 /* Sequence of bytes for breakpoint instruction. */
88 #define BREAKPOINT {0xcc}
90 /* Amount PC must be decremented by after a breakpoint.
91 This is often the number of bytes in BREAKPOINT
94 #define DECR_PC_AFTER_BREAK 0
96 /* Nonzero if instruction at PC is a return instruction. */
97 /* For Symmetry, this is really the 'leave' instruction, which */
98 /* is right before the ret */
100 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
102 /* Return 1 if P points to an invalid floating point value.
105 #define INVALID_FLOAT(p, len) (0)
107 /* code for 80387 fpu. Functions are from i386-dep.c, copied into
110 #define FLOAT_INFO { i386_float_info(); }
112 /* largest int type */
115 #define BUILTIN_TYPE_LONGEST builtin_type_long
118 /* Say how long (ordinary) registers are. */
120 #define REGISTER_TYPE long
122 /* Number of machine registers */
125 /* Initializer for an array of names of registers.
126 There should be NUM_REGS strings in this initializer. */
128 /* Symmetry registers are in this weird order to match the register
129 numbers in the symbol table entries. If you change the order,
130 things will probably break mysteriously for no apparent reason.
131 Also note that the st(0)...st(7) 387 registers are represented as
134 #define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \
135 "ebx", "esi", "edi", "st2", "st3", \
136 "st4", "st5", "st6", "st7", "esp", \
137 "ebp", "eip", "eflags", "fp1", "fp2", \
138 "fp3", "fp4", "fp5", "fp6", "fp7", \
139 "fp8", "fp9", "fp10", "fp11", "fp12", \
140 "fp13", "fp14", "fp15", "fp16", "fp17", \
141 "fp18", "fp19", "fp20", "fp21", "fp22", \
142 "fp23", "fp24", "fp25", "fp26", "fp27", \
143 "fp28", "fp29", "fp30", "fp31" }
145 /* Register numbers of various important registers.
146 Note that some of these values are "real" register numbers,
147 and correspond to the general registers of the machine,
148 and some are "phony" register numbers which are too large
149 to be actual register numbers as far as the user is concerned
150 but do serve to get the desired values when passed to read_register. */
152 #define FP1_REGNUM 18 /* first 1167 register */
153 #define SP_REGNUM 14 /* Contains address of top of stack */
154 #define FP_REGNUM 15 /* Contains address of executing stack frame */
155 #define PC_REGNUM 16 /* Contains program counter */
156 #define PS_REGNUM 17 /* Contains processor status */
158 /* The magic numbers below are offsets into u_ar0 in the user struct.
159 * They live in <machine/reg.h>. Gdb calls this macro with blockend
160 * holding u.u_ar0 - KERNEL_U_ADDR. Only the registers listed are
161 * saved in the u area (along with a few others that aren't useful
162 * here. See <machine/reg.h>).
165 #define REGISTER_U_ADDR(addr, blockend, regno) \
166 { struct user foo; /* needed for finding fpu regs */ \
169 addr = blockend + EAX * sizeof(int); break; \
171 addr = blockend + EDX * sizeof(int); break; \
173 addr = blockend + ECX * sizeof(int); break; \
174 case 3: /* st(0) */ \
176 ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \
178 case 4: /* st(1) */ \
180 ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \
183 addr = blockend + EBX * sizeof(int); break; \
185 addr = blockend + ESI * sizeof(int); break; \
187 addr = blockend + EDI * sizeof(int); break; \
188 case 8: /* st(2) */ \
190 ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \
192 case 9: /* st(3) */ \
194 ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \
196 case 10: /* st(4) */ \
198 ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \
200 case 11: /* st(5) */ \
202 ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \
204 case 12: /* st(6) */ \
206 ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \
208 case 13: /* st(7) */ \
210 ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \
213 addr = blockend + ESP * sizeof(int); break; \
215 addr = blockend + EBP * sizeof(int); break; \
217 addr = blockend + EIP * sizeof(int); break; \
219 addr = blockend + FLAGS * sizeof(int); break; \
229 case 27: /* fp10 */ \
230 case 28: /* fp11 */ \
231 case 29: /* fp12 */ \
232 case 30: /* fp13 */ \
233 case 31: /* fp14 */ \
234 case 32: /* fp15 */ \
235 case 33: /* fp16 */ \
236 case 34: /* fp17 */ \
237 case 35: /* fp18 */ \
238 case 36: /* fp19 */ \
239 case 37: /* fp20 */ \
240 case 38: /* fp21 */ \
241 case 39: /* fp22 */ \
242 case 40: /* fp23 */ \
243 case 41: /* fp24 */ \
244 case 42: /* fp25 */ \
245 case 43: /* fp26 */ \
246 case 44: /* fp27 */ \
247 case 45: /* fp28 */ \
248 case 46: /* fp29 */ \
249 case 47: /* fp30 */ \
250 case 48: /* fp31 */ \
252 ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \
256 /* Total amount of space needed to store our copies of the machine's
257 register state, the array `registers'. */
258 /* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */
259 #define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4))
261 /* Index within `registers' of the first byte of the space for
264 #define REGISTER_BYTE(N) \
265 ((N < 3) ? (N * 4) : \
266 (N < 5) ? (((N - 2) * 10) + 2) : \
267 (N < 8) ? (((N - 5) * 4) + 32) : \
268 (N < 14) ? (((N - 8) * 10) + 44) : \
269 (((N - 14) * 4) + 104))
271 /* Number of bytes of storage in the actual machine representation
272 * for register N. All registers are 4 bytes, except 387 st(0) - st(7),
273 * which are 80 bits each.
276 #define REGISTER_RAW_SIZE(N) \
283 /* Number of bytes of storage in the program's representation
284 for register N. On the vax, all regs are 4 bytes. */
286 #define REGISTER_VIRTUAL_SIZE(N) 4
288 /* Largest value REGISTER_RAW_SIZE can have. */
290 #define MAX_REGISTER_RAW_SIZE 10
292 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
294 #define MAX_REGISTER_VIRTUAL_SIZE 4
296 /* Nonzero if register N requires conversion
297 from raw format to virtual format. */
299 #define REGISTER_CONVERTIBLE(N) \
306 /* Convert data from raw format for register REGNUM
307 to virtual format for register REGNUM. */
309 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
310 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
311 (REGNUM < 5) ? i387_to_double((FROM), (TO)) : \
312 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
313 (REGNUM < 14) ? i387_to_double((FROM), (TO)) : \
314 bcopy ((FROM), (TO), 4))
316 /* Convert data from virtual format for register REGNUM
317 to raw format for register REGNUM. */
319 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
320 ((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \
321 (REGNUM < 5) ? double_to_i387((FROM), (TO)) : \
322 (REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \
323 (REGNUM < 14) ? double_to_i387((FROM), (TO)) : \
324 bcopy ((FROM), (TO), 4))
326 /* Return the GDB type object for the "standard" data type
327 of data in register N. */
329 #define REGISTER_VIRTUAL_TYPE(N) \
330 ((N < 3) ? builtin_type_int : \
331 (N < 5) ? builtin_type_double : \
332 (N < 8) ? builtin_type_int : \
333 (N < 14) ? builtin_type_double : \
337 /* Store the address of the place in which to copy the structure the
338 subroutine will return. This is called from call_function. */
340 #define STORE_STRUCT_RETURN(ADDR, SP) \
341 { (SP) -= sizeof (ADDR); \
342 write_memory ((SP), &(ADDR), sizeof (ADDR)); \
343 write_register(0, (ADDR)); }
345 /* Extract from an array REGBUF containing the (raw) register state
346 a function return value of type TYPE, and copy that, in virtual format,
349 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
350 symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
352 /* Write into appropriate registers a function return value
353 of type TYPE, given in virtual format. */
355 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
356 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
358 /* Extract from an array REGBUF containing the (raw) register state
359 the address in which a function should return its structure value,
360 as a CORE_ADDR (or an expression that can be used as one). */
362 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
364 /* Compensate for lack of `vprintf' function. */
366 #define vprintf(format, ap) _doprnt (format, ap, stdout)
367 #endif /* not HAVE_VPRINTF */
369 /* Describe the pointer in each stack frame to the previous stack frame
372 /* FRAME_CHAIN takes a frame's nominal address
373 and produces the frame's chain-pointer.
375 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
376 and produces the nominal address of the caller frame.
378 However, if FRAME_CHAIN_VALID returns zero,
379 it means the given frame is the outermost one and has no caller.
380 In that case, FRAME_CHAIN_COMBINE is not used. */
382 /* On Symmetry, %ebp points to caller's %ebp, and the return address
383 is right on top of that.
386 #define FRAME_CHAIN(thisframe) \
387 (outside_startup_file ((thisframe)->pc) ? \
388 read_memory_integer((thisframe)->frame, 4) :\
391 #define FRAME_CHAIN_VALID(chain, thisframe) \
394 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
396 /* Define other aspects of the stack frame. */
398 /* A macro that tells us whether the function invocation represented
399 by FI does not have a frame on the stack associated with it. If it
400 does not, FRAMELESS is set to 1, else 0. */
401 #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \
402 FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS)
404 #define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4))
406 #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
408 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
410 /* Return number of args passed to a frame.
411 Can return -1, meaning no way to tell.
413 The weirdness in the "addl $imm8" case is due to gcc sometimes
414 issuing "addl $-int" after function call returns; this would
415 produce ridiculously huge arg counts. */
417 #define FRAME_NUM_ARGS(numargs, fi) \
419 int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \
421 if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \
425 else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \
427 narg = ((op >> 16) & 0xff); \
428 numargs = (narg >= 128) ? -1 : narg / 4; \
430 else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \
432 narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \
433 numargs = (narg < 0) ? -1 : narg / 4; \
441 /* Return number of bytes at start of arglist that are not really args. */
443 #define FRAME_ARGS_SKIP 8
445 /* Put here the code to store, into a struct frame_saved_regs,
446 the addresses of the saved registers of frame described by FRAME_INFO.
447 This includes special registers such as pc and fp saved in special
448 ways in the stack frame. sp is even more special:
449 the address we return for it IS the sp for the next frame. */
451 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
452 { i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
455 /* Things needed for making the inferior call functions. */
457 #define PUSH_DUMMY_FRAME \
458 { CORE_ADDR sp = read_register (SP_REGNUM); \
460 sp = push_word (sp, read_register (PC_REGNUM)); \
461 sp = push_word (sp, read_register (FP_REGNUM)); \
462 write_register (FP_REGNUM, sp); \
463 for (regnum = 0; regnum < NUM_REGS; regnum++) \
464 sp = push_word (sp, read_register (regnum)); \
465 write_register (SP_REGNUM, sp); \
470 FRAME frame = get_current_frame (); \
473 struct frame_saved_regs fsr; \
474 struct frame_info *fi; \
475 fi = get_frame_info (frame); \
477 get_frame_saved_regs (fi, &fsr); \
478 for (regnum = 0; regnum < NUM_REGS; regnum++) { \
480 adr = fsr.regs[regnum]; \
482 write_register (regnum, read_memory_integer (adr, 4)); \
484 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
485 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
486 write_register (SP_REGNUM, fp + 8); \
487 flush_cached_frames (); \
488 set_current_frame ( create_new_frame (read_register (FP_REGNUM), \
492 /* from i386-dep.c, worked better than my original... */
493 /* This sequence of words is the instructions
494 * call (32-bit offset)
499 #define CALL_DUMMY { 0x223344e8, 0xcc11 }
501 #define CALL_DUMMY_LENGTH 8
503 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
505 /* Insert the specified number of args and function address
506 into a call sequence of the above form stored at DUMMYNAME. */
508 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
510 int from, to, delta, loc; \
511 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
515 *(int *)((char *)(dummyname) + 1) = delta; \
518 /* Interface definitions for kernel debugger KDB. */
519 /* This doesn't work... */
520 /* Map machine fault codes into signal numbers.
521 First subtract 0, divide by 4, then index in a table.
522 Faults for which the entry in this table is 0
523 are not handled by KDB; the program's own trap handler
524 gets to handle then. */
526 #define FAULT_CODE_ORIGIN 0
527 #define FAULT_CODE_UNITS 4
528 #define FAULT_TABLE \
529 { 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \
530 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \
531 0, 0, 0, 0, 0, 0, 0, 0}
533 /* Start running with a stack stretching from BEG to END.
534 BEG and END should be symbols meaningful to the assembler.
535 This is used only for kdb. */
537 #define INIT_STACK(beg, end) \
538 { asm (".globl end"); \
539 asm ("movl $ end, %esp"); \
540 asm ("movl %ebp, $0"); }
542 /* Push the frame pointer register on the stack. */
543 #define PUSH_FRAME_PTR \
546 /* Copy the top-of-stack to the frame pointer register. */
547 #define POP_FRAME_PTR \
548 asm ("movl (%esp), %ebp");
550 /* After KDB is entered by a fault, push all registers
551 that GDB thinks about (all NUM_REGS of them),
552 so that they appear in order of ascending GDB register number.
553 The fault code will be on the stack beyond the last register. */
555 #define PUSH_REGISTERS \
558 { asm("pushl %eax"); \
561 asm("pushl %st(0)"); \
562 asm("pushl %st(1)"); \
566 asm("pushl %st(2)"); \
567 asm("pushl %st(3)"); \
568 asm("pushl %st(4)"); \
569 asm("pushl %st(5)"); \
570 asm("pushl %st(6)"); \
571 asm("pushl %st(7)"); \
575 asm("pushl %eflags"); \
585 asm("pushl %fp10"); \
586 asm("pushl %fp11"); \
587 asm("pushl %fp12"); \
588 asm("pushl %fp13"); \
589 asm("pushl %fp14"); \
590 asm("pushl %fp15"); \
591 asm("pushl %fp16"); \
592 asm("pushl %fp17"); \
593 asm("pushl %fp18"); \
594 asm("pushl %fp19"); \
595 asm("pushl %fp20"); \
596 asm("pushl %fp21"); \
597 asm("pushl %fp22"); \
598 asm("pushl %fp23"); \
599 asm("pushl %fp24"); \
600 asm("pushl %fp25"); \
601 asm("pushl %fp26"); \
602 asm("pushl %fp27"); \
603 asm("pushl %fp28"); \
604 asm("pushl %fp29"); \
605 asm("pushl %fp30"); \
606 asm("pushl %fp31"); \
609 /* Assuming the registers (including processor status) have been
610 pushed on the stack in order of ascending GDB register number,
611 restore them and return to the address in the saved PC register. */
613 #define POP_REGISTERS \
This page took 0.042759 seconds and 4 git commands to generate.