| 1 | /* Definitions to make GDB run on a Sequent Symmetry under dynix 3.0, |
| 2 | with Weitek 1167 and i387 support. |
| 3 | Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GDB. |
| 6 | |
| 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. |
| 11 | |
| 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. |
| 16 | |
| 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 20 | |
| 21 | /* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */ |
| 22 | |
| 23 | /* This machine doesn't have the siginterrupt call. */ |
| 24 | #define NO_SIGINTERRUPT |
| 25 | |
| 26 | #define HAVE_WAIT_STRUCT |
| 27 | |
| 28 | /* XPT_DEBUG doesn't work yet under Dynix 3.0.12, but UNDEBUG does... */ |
| 29 | /* #define PTRACE_ATTACH XPT_DEBUG |
| 30 | #define PTRACE_DETACH XPT_UNDEBUG |
| 31 | #define ATTACH_DETACH */ |
| 32 | |
| 33 | #define HOST_BYTE_ORDER LITTLE_ENDIAN |
| 34 | |
| 35 | /* Get rid of any system-imposed stack limit if possible. */ |
| 36 | |
| 37 | #define SET_STACK_LIMIT_HUGE |
| 38 | |
| 39 | /* This is the amount to subtract from u.u_ar0 |
| 40 | to get the offset in the core file of the register values. */ |
| 41 | |
| 42 | #define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) |
| 43 | |
| 44 | /* The magic numbers below are offsets into u_ar0 in the user struct. |
| 45 | They live in <machine/reg.h>. Gdb calls this macro with blockend |
| 46 | holding u.u_ar0 - KERNEL_U_ADDR. Only the registers listed are |
| 47 | saved in the u area (along with a few others that aren't useful |
| 48 | here. See <machine/reg.h>). */ |
| 49 | |
| 50 | #define REGISTER_U_ADDR(addr, blockend, regno) \ |
| 51 | { struct user foo; /* needed for finding fpu regs */ \ |
| 52 | switch (regno) { \ |
| 53 | case 0: \ |
| 54 | addr = blockend + EAX * sizeof(int); break; \ |
| 55 | case 1: \ |
| 56 | addr = blockend + EDX * sizeof(int); break; \ |
| 57 | case 2: \ |
| 58 | addr = blockend + ECX * sizeof(int); break; \ |
| 59 | case 3: /* st(0) */ \ |
| 60 | addr = blockend - \ |
| 61 | ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \ |
| 62 | break; \ |
| 63 | case 4: /* st(1) */ \ |
| 64 | addr = blockend - \ |
| 65 | ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \ |
| 66 | break; \ |
| 67 | case 5: \ |
| 68 | addr = blockend + EBX * sizeof(int); break; \ |
| 69 | case 6: \ |
| 70 | addr = blockend + ESI * sizeof(int); break; \ |
| 71 | case 7: \ |
| 72 | addr = blockend + EDI * sizeof(int); break; \ |
| 73 | case 8: /* st(2) */ \ |
| 74 | addr = blockend - \ |
| 75 | ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \ |
| 76 | break; \ |
| 77 | case 9: /* st(3) */ \ |
| 78 | addr = blockend - \ |
| 79 | ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \ |
| 80 | break; \ |
| 81 | case 10: /* st(4) */ \ |
| 82 | addr = blockend - \ |
| 83 | ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \ |
| 84 | break; \ |
| 85 | case 11: /* st(5) */ \ |
| 86 | addr = blockend - \ |
| 87 | ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \ |
| 88 | break; \ |
| 89 | case 12: /* st(6) */ \ |
| 90 | addr = blockend - \ |
| 91 | ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \ |
| 92 | break; \ |
| 93 | case 13: /* st(7) */ \ |
| 94 | addr = blockend - \ |
| 95 | ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \ |
| 96 | break; \ |
| 97 | case 14: \ |
| 98 | addr = blockend + ESP * sizeof(int); break; \ |
| 99 | case 15: \ |
| 100 | addr = blockend + EBP * sizeof(int); break; \ |
| 101 | case 16: \ |
| 102 | addr = blockend + EIP * sizeof(int); break; \ |
| 103 | case 17: \ |
| 104 | addr = blockend + FLAGS * sizeof(int); break; \ |
| 105 | case 18: /* fp1 */ \ |
| 106 | case 19: /* fp2 */ \ |
| 107 | case 20: /* fp3 */ \ |
| 108 | case 21: /* fp4 */ \ |
| 109 | case 22: /* fp5 */ \ |
| 110 | case 23: /* fp6 */ \ |
| 111 | case 24: /* fp7 */ \ |
| 112 | case 25: /* fp8 */ \ |
| 113 | case 26: /* fp9 */ \ |
| 114 | case 27: /* fp10 */ \ |
| 115 | case 28: /* fp11 */ \ |
| 116 | case 29: /* fp12 */ \ |
| 117 | case 30: /* fp13 */ \ |
| 118 | case 31: /* fp14 */ \ |
| 119 | case 32: /* fp15 */ \ |
| 120 | case 33: /* fp16 */ \ |
| 121 | case 34: /* fp17 */ \ |
| 122 | case 35: /* fp18 */ \ |
| 123 | case 36: /* fp19 */ \ |
| 124 | case 37: /* fp20 */ \ |
| 125 | case 38: /* fp21 */ \ |
| 126 | case 39: /* fp22 */ \ |
| 127 | case 40: /* fp23 */ \ |
| 128 | case 41: /* fp24 */ \ |
| 129 | case 42: /* fp25 */ \ |
| 130 | case 43: /* fp26 */ \ |
| 131 | case 44: /* fp27 */ \ |
| 132 | case 45: /* fp28 */ \ |
| 133 | case 46: /* fp29 */ \ |
| 134 | case 47: /* fp30 */ \ |
| 135 | case 48: /* fp31 */ \ |
| 136 | addr = blockend - \ |
| 137 | ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \ |
| 138 | } \ |
| 139 | } |
| 140 | |
| 141 | /* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ |
| 142 | |
| 143 | #define FETCH_INFERIOR_REGISTERS |
| 144 | |
| 145 | /* We must fetch all the regs before storing, since we store all at once. */ |
| 146 | |
| 147 | #define CHILD_PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES) |
| 148 | \f |
| 149 | /* Interface definitions for kernel debugger KDB. */ |
| 150 | /* This doesn't work... */ |
| 151 | /* Map machine fault codes into signal numbers. |
| 152 | First subtract 0, divide by 4, then index in a table. |
| 153 | Faults for which the entry in this table is 0 |
| 154 | are not handled by KDB; the program's own trap handler |
| 155 | gets to handle then. */ |
| 156 | |
| 157 | #define FAULT_CODE_ORIGIN 0 |
| 158 | #define FAULT_CODE_UNITS 4 |
| 159 | #define FAULT_TABLE \ |
| 160 | { 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ |
| 161 | 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ |
| 162 | 0, 0, 0, 0, 0, 0, 0, 0} |
| 163 | |
| 164 | /* Start running with a stack stretching from BEG to END. |
| 165 | BEG and END should be symbols meaningful to the assembler. |
| 166 | This is used only for kdb. */ |
| 167 | |
| 168 | #define INIT_STACK(beg, end) \ |
| 169 | { asm (".globl end"); \ |
| 170 | asm ("movl $ end, %esp"); \ |
| 171 | asm ("movl %ebp, $0"); } |
| 172 | |
| 173 | /* Push the frame pointer register on the stack. */ |
| 174 | #define PUSH_FRAME_PTR \ |
| 175 | asm ("pushl %ebp"); |
| 176 | |
| 177 | /* Copy the top-of-stack to the frame pointer register. */ |
| 178 | #define POP_FRAME_PTR \ |
| 179 | asm ("movl (%esp), %ebp"); |
| 180 | |
| 181 | /* After KDB is entered by a fault, push all registers |
| 182 | that GDB thinks about (all NUM_REGS of them), |
| 183 | so that they appear in order of ascending GDB register number. |
| 184 | The fault code will be on the stack beyond the last register. */ |
| 185 | |
| 186 | #define PUSH_REGISTERS \ |
| 187 | { asm("pushad"); } |
| 188 | /* |
| 189 | { asm("pushl %eax"); \ |
| 190 | asm("pushl %edx"); \ |
| 191 | asm("pushl %ecx"); \ |
| 192 | asm("pushl %st(0)"); \ |
| 193 | asm("pushl %st(1)"); \ |
| 194 | asm("pushl %ebx"); \ |
| 195 | asm("pushl %esi"); \ |
| 196 | asm("pushl %edi"); \ |
| 197 | asm("pushl %st(2)"); \ |
| 198 | asm("pushl %st(3)"); \ |
| 199 | asm("pushl %st(4)"); \ |
| 200 | asm("pushl %st(5)"); \ |
| 201 | asm("pushl %st(6)"); \ |
| 202 | asm("pushl %st(7)"); \ |
| 203 | asm("pushl %esp"); \ |
| 204 | asm("pushl %ebp"); \ |
| 205 | asm("pushl %eip"); \ |
| 206 | asm("pushl %eflags"); \ |
| 207 | asm("pushl %fp1"); \ |
| 208 | asm("pushl %fp2"); \ |
| 209 | asm("pushl %fp3"); \ |
| 210 | asm("pushl %fp4"); \ |
| 211 | asm("pushl %fp5"); \ |
| 212 | asm("pushl %fp6"); \ |
| 213 | asm("pushl %fp7"); \ |
| 214 | asm("pushl %fp8"); \ |
| 215 | asm("pushl %fp9"); \ |
| 216 | asm("pushl %fp10"); \ |
| 217 | asm("pushl %fp11"); \ |
| 218 | asm("pushl %fp12"); \ |
| 219 | asm("pushl %fp13"); \ |
| 220 | asm("pushl %fp14"); \ |
| 221 | asm("pushl %fp15"); \ |
| 222 | asm("pushl %fp16"); \ |
| 223 | asm("pushl %fp17"); \ |
| 224 | asm("pushl %fp18"); \ |
| 225 | asm("pushl %fp19"); \ |
| 226 | asm("pushl %fp20"); \ |
| 227 | asm("pushl %fp21"); \ |
| 228 | asm("pushl %fp22"); \ |
| 229 | asm("pushl %fp23"); \ |
| 230 | asm("pushl %fp24"); \ |
| 231 | asm("pushl %fp25"); \ |
| 232 | asm("pushl %fp26"); \ |
| 233 | asm("pushl %fp27"); \ |
| 234 | asm("pushl %fp28"); \ |
| 235 | asm("pushl %fp29"); \ |
| 236 | asm("pushl %fp30"); \ |
| 237 | asm("pushl %fp31"); \ |
| 238 | } |
| 239 | */ |
| 240 | /* Assuming the registers (including processor status) have been |
| 241 | pushed on the stack in order of ascending GDB register number, |
| 242 | restore them and return to the address in the saved PC register. */ |
| 243 | |
| 244 | #define POP_REGISTERS \ |
| 245 | { asm ("popad"); } |