BSD 4_3_Net_2 development
[unix-history] / usr / src / usr.bin / gdb / config / m-symmetry.h
CommitLineData
c70a4827
C
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#include <machine/reg.h>
24
25#define SYMMETRY
26
27/* This machine doesn't have the siginterrupt call. */
28#define NO_SIGINTERRUPT
29
30#define HAVE_WAIT_STRUCT
31
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 */
36
37/* Define SFILE_FN_FLAGGED if the source file is flagged with an N_FN
38 symbol instead of an N_TEXT symbol. */
39
40#define OFILE_FN_FLAGGED
41
42/* Get rid of any system-imposed stack limit if possible. */
43
44#define SET_STACK_LIMIT_HUGE
45
46/* Define this if the C compiler puts an underscore at the front
47 of external names before giving them to the linker. */
48
49#define NAMES_HAVE_UNDERSCORE
50
51/* Debugger information will be in DBX format. */
52
53#define READ_DBX_FORMAT
54
55/* Offset from address of function to start of its code.
56 Zero on most machines. */
57
58#define FUNCTION_START_OFFSET 0
59
60/* Advance PC across any function entry prologue instructions
61 to reach some "real" code. From m-i386.h */
62
63#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));}
64
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
68 some instructions. */
69
70#define SAVED_PC_AFTER_CALL(frame) \
71 read_memory_integer(read_register(SP_REGNUM), 4)
72
73/* This is the amount to subtract from u.u_ar0
74 to get the offset in the core file of the register values. */
75
76#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG))
77
78/* Address of end of stack space. */
79
80#define STACK_END_ADDR (0x40000000 - (UPAGES * NBPG))
81
82/* Stack grows downward. */
83
84#define INNER_THAN <
85
86/* Sequence of bytes for breakpoint instruction. */
87
88#define BREAKPOINT {0xcc}
89
90/* Amount PC must be decremented by after a breakpoint.
91 This is often the number of bytes in BREAKPOINT
92 but not always. */
93
94#define DECR_PC_AFTER_BREAK 0
95
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 */
99
100#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9)
101
102/* Return 1 if P points to an invalid floating point value.
103*/
104
105#define INVALID_FLOAT(p, len) (0)
106
107/* code for 80387 fpu. Functions are from i386-dep.c, copied into
108 * symm-dep.c.
109 */
110#define FLOAT_INFO { i386_float_info(); }
111
112/* largest int type */
113#define LONGEST long
114
115#define BUILTIN_TYPE_LONGEST builtin_type_long
116
117
118/* Say how long (ordinary) registers are. */
119
120#define REGISTER_TYPE long
121
122/* Number of machine registers */
123#define NUM_REGS 49
124
125/* Initializer for an array of names of registers.
126 There should be NUM_REGS strings in this initializer. */
127
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
132 st0...st7. */
133
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" }
144
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. */
151
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 */
157
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>).
163 */
164
165#define REGISTER_U_ADDR(addr, blockend, regno) \
166{ struct user foo; /* needed for finding fpu regs */ \
167switch (regno) { \
168 case 0: \
169 addr = blockend + EAX * sizeof(int); break; \
170 case 1: \
171 addr = blockend + EDX * sizeof(int); break; \
172 case 2: \
173 addr = blockend + ECX * sizeof(int); break; \
174 case 3: /* st(0) */ \
175 addr = blockend - \
176 ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \
177 break; \
178 case 4: /* st(1) */ \
179 addr = blockend - \
180 ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \
181 break; \
182 case 5: \
183 addr = blockend + EBX * sizeof(int); break; \
184 case 6: \
185 addr = blockend + ESI * sizeof(int); break; \
186 case 7: \
187 addr = blockend + EDI * sizeof(int); break; \
188 case 8: /* st(2) */ \
189 addr = blockend - \
190 ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \
191 break; \
192 case 9: /* st(3) */ \
193 addr = blockend - \
194 ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \
195 break; \
196 case 10: /* st(4) */ \
197 addr = blockend - \
198 ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \
199 break; \
200 case 11: /* st(5) */ \
201 addr = blockend - \
202 ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \
203 break; \
204 case 12: /* st(6) */ \
205 addr = blockend - \
206 ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \
207 break; \
208 case 13: /* st(7) */ \
209 addr = blockend - \
210 ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \
211 break; \
212 case 14: \
213 addr = blockend + ESP * sizeof(int); break; \
214 case 15: \
215 addr = blockend + EBP * sizeof(int); break; \
216 case 16: \
217 addr = blockend + EIP * sizeof(int); break; \
218 case 17: \
219 addr = blockend + FLAGS * sizeof(int); break; \
220 case 18: /* fp1 */ \
221 case 19: /* fp2 */ \
222 case 20: /* fp3 */ \
223 case 21: /* fp4 */ \
224 case 22: /* fp5 */ \
225 case 23: /* fp6 */ \
226 case 24: /* fp7 */ \
227 case 25: /* fp8 */ \
228 case 26: /* fp9 */ \
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 */ \
251 addr = blockend - \
252 ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \
253 } \
254}
255
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))
260
261/* Index within `registers' of the first byte of the space for
262 register N. */
263
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))
270
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.
274 */
275
276#define REGISTER_RAW_SIZE(N) \
277((N < 3) ? 4 : \
278(N < 5) ? 10 : \
279(N < 8) ? 4 : \
280(N < 14) ? 10 : \
281 4)
282
283/* Number of bytes of storage in the program's representation
284 for register N. On the vax, all regs are 4 bytes. */
285
286#define REGISTER_VIRTUAL_SIZE(N) 4
287
288/* Largest value REGISTER_RAW_SIZE can have. */
289
290#define MAX_REGISTER_RAW_SIZE 10
291
292/* Largest value REGISTER_VIRTUAL_SIZE can have. */
293
294#define MAX_REGISTER_VIRTUAL_SIZE 4
295
296/* Nonzero if register N requires conversion
297 from raw format to virtual format. */
298
299#define REGISTER_CONVERTIBLE(N) \
300((N < 3) ? 0 : \
301(N < 5) ? 1 : \
302(N < 8) ? 0 : \
303(N < 14) ? 1 : \
304 0)
305
306/* Convert data from raw format for register REGNUM
307 to virtual format for register REGNUM. */
308
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))
315
316/* Convert data from virtual format for register REGNUM
317 to raw format for register REGNUM. */
318
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))
325
326/* Return the GDB type object for the "standard" data type
327 of data in register N. */
328
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 : \
334 builtin_type_int)
335
336/* from m-i386.h */
337/* Store the address of the place in which to copy the structure the
338 subroutine will return. This is called from call_function. */
339
340#define STORE_STRUCT_RETURN(ADDR, SP) \
341 { (SP) -= sizeof (ADDR); \
342 write_memory ((SP), &(ADDR), sizeof (ADDR)); \
343 write_register(0, (ADDR)); }
344
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,
347 into VALBUF. */
348
349#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
350 symmetry_extract_return_value(TYPE, REGBUF, VALBUF)
351
352/* Write into appropriate registers a function return value
353 of type TYPE, given in virtual format. */
354
355#define STORE_RETURN_VALUE(TYPE,VALBUF) \
356 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
357
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). */
361
362#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
363
364/* Compensate for lack of `vprintf' function. */
365#ifndef HAVE_VPRINTF
366#define vprintf(format, ap) _doprnt (format, ap, stdout)
367#endif /* not HAVE_VPRINTF */
368\f
369/* Describe the pointer in each stack frame to the previous stack frame
370 (its caller). */
371
372/* FRAME_CHAIN takes a frame's nominal address
373 and produces the frame's chain-pointer.
374
375 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
376 and produces the nominal address of the caller frame.
377
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. */
381
382/* On Symmetry, %ebp points to caller's %ebp, and the return address
383 is right on top of that.
384*/
385
386#define FRAME_CHAIN(thisframe) \
387 (outside_startup_file ((thisframe)->pc) ? \
388 read_memory_integer((thisframe)->frame, 4) :\
389 0)
390
391#define FRAME_CHAIN_VALID(chain, thisframe) \
392 (chain != 0)
393
394#define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
395
396/* Define other aspects of the stack frame. */
397
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)
403
404#define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4))
405
406#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
407
408#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
409
410/* Return number of args passed to a frame.
411 Can return -1, meaning no way to tell.
412
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. */
416
417#define FRAME_NUM_ARGS(numargs, fi) \
418{ \
419 int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \
420 int narg; \
421 if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \
422 { \
423 numargs = 1; \
424 } \
425 else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \
426 { \
427 narg = ((op >> 16) & 0xff); \
428 numargs = (narg >= 128) ? -1 : narg / 4; \
429 } \
430 else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \
431 { \
432 narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \
433 numargs = (narg < 0) ? -1 : narg / 4; \
434 } \
435 else \
436 { \
437 numargs = -1; \
438 } \
439}
440
441/* Return number of bytes at start of arglist that are not really args. */
442
443#define FRAME_ARGS_SKIP 8
444
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. */
450
451#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
452{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); }
453
454\f
455/* Things needed for making the inferior call functions. */
456
457#define PUSH_DUMMY_FRAME \
458{ CORE_ADDR sp = read_register (SP_REGNUM); \
459 int 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); \
466}
467
468#define POP_FRAME \
469{ \
470 FRAME frame = get_current_frame (); \
471 CORE_ADDR fp; \
472 int regnum; \
473 struct frame_saved_regs fsr; \
474 struct frame_info *fi; \
475 fi = get_frame_info (frame); \
476 fp = fi->frame; \
477 get_frame_saved_regs (fi, &fsr); \
478 for (regnum = 0; regnum < NUM_REGS; regnum++) { \
479 CORE_ADDR adr; \
480 adr = fsr.regs[regnum]; \
481 if (adr) \
482 write_register (regnum, read_memory_integer (adr, 4)); \
483 } \
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), \
489 read_pc ())); \
490}
491
492/* from i386-dep.c, worked better than my original... */
493/* This sequence of words is the instructions
494 * call (32-bit offset)
495 * int 3
496 * This is 6 bytes.
497 */
498
499#define CALL_DUMMY { 0x223344e8, 0xcc11 }
500
501#define CALL_DUMMY_LENGTH 8
502
503#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
504
505/* Insert the specified number of args and function address
506 into a call sequence of the above form stored at DUMMYNAME. */
507
508#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
509{ \
510 int from, to, delta, loc; \
511 loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \
512 from = loc + 5; \
513 to = (int)(fun); \
514 delta = to - from; \
515 *(int *)((char *)(dummyname) + 1) = delta; \
516}
517\f
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. */
525
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}
532
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. */
536
537#define INIT_STACK(beg, end) \
538{ asm (".globl end"); \
539 asm ("movl $ end, %esp"); \
540 asm ("movl %ebp, $0"); }
541
542/* Push the frame pointer register on the stack. */
543#define PUSH_FRAME_PTR \
544 asm ("pushl %ebp");
545
546/* Copy the top-of-stack to the frame pointer register. */
547#define POP_FRAME_PTR \
548 asm ("movl (%esp), %ebp");
549
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. */
554
555#define PUSH_REGISTERS \
556{ asm("pushad"); }
557/*
558{ asm("pushl %eax"); \
559 asm("pushl %edx"); \
560 asm("pushl %ecx"); \
561 asm("pushl %st(0)"); \
562 asm("pushl %st(1)"); \
563 asm("pushl %ebx"); \
564 asm("pushl %esi"); \
565 asm("pushl %edi"); \
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)"); \
572 asm("pushl %esp"); \
573 asm("pushl %ebp"); \
574 asm("pushl %eip"); \
575 asm("pushl %eflags"); \
576 asm("pushl %fp1"); \
577 asm("pushl %fp2"); \
578 asm("pushl %fp3"); \
579 asm("pushl %fp4"); \
580 asm("pushl %fp5"); \
581 asm("pushl %fp6"); \
582 asm("pushl %fp7"); \
583 asm("pushl %fp8"); \
584 asm("pushl %fp9"); \
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"); \
607}
608*/
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. */
612
613#define POP_REGISTERS \
614{ asm ("popad"); }