|
|
1.1 ! root 1: /* Definitions to make GDB run on a merlin under utek 2.1 ! 2: Copyright (C) 1986, 1987 Free Software Foundation, Inc. ! 3: ! 4: GDB is distributed in the hope that it will be useful, but WITHOUT ANY ! 5: WARRANTY. No author or distributor accepts responsibility to anyone ! 6: for the consequences of using it or for whether it serves any ! 7: particular purpose or works at all, unless he says so in writing. ! 8: Refer to the GDB General Public License for full details. ! 9: ! 10: Everyone is granted permission to copy, modify and redistribute GDB, ! 11: but only under the conditions described in the GDB General Public ! 12: License. A copy of this license is supposed to have been given to you ! 13: along with GDB so you can know your rights and responsibilities. It ! 14: should be in a file named COPYING. Among other things, the copyright ! 15: notice and this notice must be preserved on all copies. ! 16: ! 17: In other words, go ahead and share GDB, but don't try to stop ! 18: anyone else from sharing it farther. Help stamp out software hoarding! ! 19: */ ! 20: ! 21: #ifndef ns16000 ! 22: #define ns16000 ! 23: #endif ! 24: ! 25: # include <machine/reg.h> ! 26: ! 27: /* Define this if the C compiler puts an underscore at the front ! 28: of external names before giving them to the linker. */ ! 29: ! 30: #define NAMES_HAVE_UNDERSCORE ! 31: ! 32: /* Debugger information will be in DBX format. */ ! 33: ! 34: #define READ_DBX_FORMAT ! 35: ! 36: /* Offset from address of function to start of its code. ! 37: Zero on most machines. */ ! 38: ! 39: #define FUNCTION_START_OFFSET 0 ! 40: ! 41: /* Advance PC across any function entry prologue instructions ! 42: to reach some "real" code. */ ! 43: ! 44: #define SKIP_PROLOGUE(pc) \ ! 45: { register int op = read_memory_integer (pc, 1); \ ! 46: if (op == 0x82) \ ! 47: { op = read_memory_integer (pc+2,1); \ ! 48: if ((op & 0x80) == 0) pc += 3; \ ! 49: else if ((op & 0xc0) == 0x80) pc += 4; \ ! 50: else pc += 6; \ ! 51: }} ! 52: ! 53: /* Immediately after a function call, return the saved pc. ! 54: Can't always go through the frames for this because on some machines ! 55: the new frame is not set up until the new function executes ! 56: some instructions. */ ! 57: ! 58: #define SAVED_PC_AFTER_CALL(frame) \ ! 59: read_memory_integer (read_register (SP_REGNUM), 4) ! 60: ! 61: /* This is the amount to subtract from u.u_ar0 ! 62: to get the offset in the core file of the register values. */ ! 63: ! 64: #define KERNEL_U_ADDR (0xfef000) ! 65: ! 66: /* Address of end of stack space. */ ! 67: ! 68: #define STACK_END_ADDR (0x800000) ! 69: ! 70: /* Stack grows downward. */ ! 71: ! 72: #define INNER_THAN < ! 73: ! 74: /* Sequence of bytes for breakpoint instruction. */ ! 75: ! 76: #define BREAKPOINT {0xf2} ! 77: ! 78: /* Amount PC must be decremented by after a breakpoint. ! 79: This is often the number of bytes in BREAKPOINT ! 80: but not always. */ ! 81: ! 82: #define DECR_PC_AFTER_BREAK 0 ! 83: ! 84: /* Nonzero if instruction at PC is a return instruction. */ ! 85: ! 86: #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12) ! 87: ! 88: /* Return 1 if P points to an invalid floating point value. */ ! 89: ! 90: #define INVALID_FLOAT(p, len) 0 ! 91: ! 92: /* Define this to say that the "svc" insn is followed by ! 93: codes in memory saying which kind of system call it is. */ ! 94: ! 95: #define NS32K_SVC_IMMED_OPERANDS ! 96: ! 97: /* Say how long (ordinary) registers are. */ ! 98: ! 99: #define REGISTER_TYPE long ! 100: ! 101: /* Number of machine registers */ ! 102: ! 103: #define NUM_REGS 25 ! 104: ! 105: #define NUM_GENERAL_REGS 8 ! 106: ! 107: /* Initializer for an array of names of registers. ! 108: There should be NUM_REGS strings in this initializer. */ ! 109: ! 110: #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ ! 111: "pc", "sp", "fp", "ps", \ ! 112: "fsr", \ ! 113: "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ ! 114: "l0", "l1", "l2", "l3", "l4", \ ! 115: } ! 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 AP_REGNUM FP_REGNUM ! 125: #define FP_REGNUM 10 /* Contains address of executing stack frame */ ! 126: #define SP_REGNUM 9 /* Contains address of top of stack */ ! 127: #define PC_REGNUM 8 /* Contains program counter */ ! 128: #define PS_REGNUM 11 /* Contains processor status */ ! 129: #define FPS_REGNUM 12 /* Floating point status register */ ! 130: #define FP0_REGNUM 13 /* Floating point register 0 */ ! 131: #define LP0_REGNUM 21 /* Double register 0 (same as FP0) */ ! 132: ! 133: #define REGISTER_U_ADDR(addr, blockend, regno) \ ! 134: { \ ! 135: switch (regno) { \ ! 136: case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \ ! 137: addr = blockend + (R0 - regno) * sizeof (int); break; \ ! 138: case PC_REGNUM: \ ! 139: addr = blockend + PC * sizeof (int); break; \ ! 140: case SP_REGNUM: \ ! 141: addr = blockend + SP * sizeof (int); break; \ ! 142: case FP_REGNUM: \ ! 143: addr = blockend + FP * sizeof (int); break; \ ! 144: case PS_REGNUM: \ ! 145: addr = blockend + 12 * sizeof (int); break; \ ! 146: case FPS_REGNUM: \ ! 147: addr = 108; break; \ ! 148: case FP0_REGNUM + 0: case FP0_REGNUM + 1: \ ! 149: case FP0_REGNUM + 2: case FP0_REGNUM + 3: \ ! 150: case FP0_REGNUM + 4: case FP0_REGNUM + 5: \ ! 151: case FP0_REGNUM + 6: case FP0_REGNUM + 7: \ ! 152: addr = 76 + (regno - FP0_REGNUM) * sizeof (float); break; \ ! 153: case LP0_REGNUM + 0: case LP0_REGNUM + 1: \ ! 154: case LP0_REGNUM + 2: case LP0_REGNUM + 3: \ ! 155: addr = 76 + (regno - LP0_REGNUM) * sizeof (double); break; \ ! 156: default: \ ! 157: printf ("bad argument to REGISTER_U_ADDR %d\n", regno); \ ! 158: abort (); \ ! 159: } \ ! 160: } ! 161: ! 162: /* Total amount of space needed to store our copies of the machine's ! 163: register state, the array `registers'. */ ! 164: #define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double)) ! 165: ! 166: /* Index within `registers' of the first byte of the space for ! 167: register N. */ ! 168: ! 169: #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \ ! 170: LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4) ! 171: ! 172: /* Number of bytes of storage in the actual machine representation ! 173: for register N. On the 32000, all regs are 4 bytes ! 174: except for the doubled floating registers. */ ! 175: ! 176: #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) ! 177: ! 178: /* Number of bytes of storage in the program's representation ! 179: for register N. On the 32000, all regs are 4 bytes ! 180: except for the doubled floating registers. */ ! 181: ! 182: #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) ! 183: ! 184: /* Largest value REGISTER_RAW_SIZE can have. */ ! 185: ! 186: #define MAX_REGISTER_RAW_SIZE 8 ! 187: ! 188: /* Largest value REGISTER_VIRTUAL_SIZE can have. */ ! 189: ! 190: #define MAX_REGISTER_VIRTUAL_SIZE 8 ! 191: ! 192: /* Nonzero if register N requires conversion ! 193: from raw format to virtual format. */ ! 194: ! 195: #define REGISTER_CONVERTIBLE(N) 0 ! 196: ! 197: /* Convert data from raw format for register REGNUM ! 198: to virtual format for register REGNUM. */ ! 199: ! 200: #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ ! 201: bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); ! 202: ! 203: /* Convert data from virtual format for register REGNUM ! 204: to raw format for register REGNUM. */ ! 205: ! 206: #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ ! 207: bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); ! 208: ! 209: /* Return the GDB type object for the "standard" data type ! 210: of data in register N. */ ! 211: ! 212: #define REGISTER_VIRTUAL_TYPE(N) \ ! 213: ((N) >= FP0_REGNUM ? \ ! 214: ((N) >= LP0_REGNUM ? \ ! 215: builtin_type_double \ ! 216: : builtin_type_float) \ ! 217: : builtin_type_int) ! 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: bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) ! 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: /* Describe the pointer in each stack frame to the previous stack frame ! 239: (its caller). */ ! 240: ! 241: /* FRAME_CHAIN takes a frame's nominal address ! 242: and produces the frame's chain-pointer. ! 243: ! 244: FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address ! 245: and produces the nominal address of the caller frame. ! 246: ! 247: However, if FRAME_CHAIN_VALID returns zero, ! 248: it means the given frame is the outermost one and has no caller. ! 249: In that case, FRAME_CHAIN_COMBINE is not used. */ ! 250: ! 251: /* In the case of the Merlin, the frame's nominal address is the FP value, ! 252: and at that address is saved previous FP value as a 4-byte word. */ ! 253: ! 254: #define FRAME_CHAIN(thisframe) (read_memory_integer (thisframe, 4)) ! 255: ! 256: #define FRAME_CHAIN_VALID(chain, thisframe) \ ! 257: (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end)) ! 258: ! 259: #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) ! 260: ! 261: /* Define other aspects of the stack frame. */ ! 262: ! 263: #define FRAME_SAVED_PC(frame) (read_memory_integer (frame + 4, 4)) ! 264: ! 265: /* compute base of arguments */ ! 266: #define FRAME_ARGS_ADDRESS(fi) ((fi).frame) ! 267: ! 268: #define FRAME_LOCALS_ADDRESS(fi) ((fi).frame) ! 269: ! 270: /* Return number of args passed to a frame. ! 271: Can return -1, meaning no way to tell. */ ! 272: ! 273: #define FRAME_NUM_ARGS(numargs, fi) \ ! 274: { CORE_ADDR pc; \ ! 275: int insn; \ ! 276: int addr_mode; \ ! 277: int width; \ ! 278: \ ! 279: pc = FRAME_SAVED_PC (fi.frame); \ ! 280: insn = read_memory_integer (pc,2); \ ! 281: addr_mode = (insn >> 11) & 0x1f; \ ! 282: insn = insn & 0x7ff; \ ! 283: if ((insn & 0x7fc) == 0x57c \ ! 284: && addr_mode == 0x14) /* immediate */ \ ! 285: { if (insn == 0x57c) /* adjspb */ \ ! 286: width = 1; \ ! 287: else if (insn == 0x57d) /* adjspw */ \ ! 288: width = 2; \ ! 289: else if (insn == 0x57f) /* adjspd */ \ ! 290: width = 4; \ ! 291: numargs = read_memory_integer (pc+2,width); \ ! 292: if (width > 1) \ ! 293: flip_bytes (&numargs, width); \ ! 294: numargs = - sign_extend (numargs, width*8) / 4; } \ ! 295: else numargs = -1; \ ! 296: } ! 297: ! 298: /* Return number of bytes at start of arglist that are not really args. */ ! 299: ! 300: #define FRAME_ARGS_SKIP 8 ! 301: ! 302: /* Put here the code to store, into a struct frame_saved_regs, ! 303: the addresses of the saved registers of frame described by FRAME_INFO. ! 304: This includes special registers such as pc and fp saved in special ! 305: ways in the stack frame. sp is even more special: ! 306: the address we return for it IS the sp for the next frame. */ ! 307: ! 308: #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ ! 309: { int regmask,regnum; \ ! 310: int localcount; \ ! 311: CORE_ADDR enter_addr; \ ! 312: CORE_ADDR next_addr; \ ! 313: \ ! 314: enter_addr = get_pc_function_start ((frame_info).pc); \ ! 315: regmask = read_memory_integer (enter_addr+1, 1); \ ! 316: localcount = ns32k_localcount (enter_addr); \ ! 317: next_addr = (frame_info).frame + localcount; \ ! 318: for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \ ! 319: (frame_saved_regs).regs[regnum] \ ! 320: = (regmask & 1) ? (next_addr -= 4) : 0; \ ! 321: (frame_saved_regs).regs[SP_REGNUM] = (frame_info).frame + 4; \ ! 322: (frame_saved_regs).regs[PC_REGNUM] = (frame_info).frame + 4; \ ! 323: (frame_saved_regs).regs[FP_REGNUM] \ ! 324: = read_memory_integer ((frame_info).frame, 4); } ! 325: ! 326: /* Compensate for lack of `vprintf' function. */ ! 327: #define vprintf(format, ap) _doprnt (format, ap, stdout) ! 328: ! 329: /* Things needed for making the inferior call functions. */ ! 330: ! 331: /* Push an empty stack frame, to record the current PC, etc. */ ! 332: ! 333: #define PUSH_DUMMY_FRAME \ ! 334: { register CORE_ADDR sp = read_register (SP_REGNUM); \ ! 335: register int regnum; \ ! 336: sp = push_word (sp, read_register (PC_REGNUM)); \ ! 337: sp = push_word (sp, read_register (FP_REGNUM)); \ ! 338: write_register (FP_REGNUM, sp); \ ! 339: for (regnum = 0; regnum < 8; regnum++) \ ! 340: sp = push_word (sp, read_register (regnum)); \ ! 341: write_register (SP_REGNUM, sp); \ ! 342: } ! 343: ! 344: /* Discard from the stack the innermost frame, restoring all registers. */ ! 345: ! 346: #define POP_FRAME \ ! 347: { register CORE_ADDR fp = read_register (FP_REGNUM); \ ! 348: register int regnum; \ ! 349: struct frame_saved_regs fsr; \ ! 350: struct frame_info fi; \ ! 351: fi = get_frame_info (fp); \ ! 352: get_frame_saved_regs (&fi, &fsr); \ ! 353: for (regnum = 0; regnum < 8; regnum++) \ ! 354: if (fsr.regs[regnum]) \ ! 355: write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ ! 356: write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ ! 357: write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ ! 358: write_register (SP_REGNUM, fp + 8); \ ! 359: } ! 360: ! 361: /* This sequence of words is the instructions ! 362: enter 0xff,0 82 ff 00 ! 363: jsr @0x00010203 7f ae c0 01 02 03 ! 364: adjspd 0x69696969 7f a5 01 02 03 04 ! 365: bpt f2 ! 366: Note this is 16 bytes. */ ! 367: ! 368: #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } ! 369: ! 370: #define CALL_DUMMY_START_OFFSET 3 ! 371: #define CALL_DUMMY_LENGTH 16 ! 372: #define CALL_DUMMY_ADDR 5 ! 373: #define CALL_DUMMY_NARGS 11 ! 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, fun, nargs) \ ! 379: { int flipped = fun | 0xc0000000; \ ! 380: flip_bytes (&flipped, 4); \ ! 381: *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ ! 382: flipped = - nargs * 4; \ ! 383: flip_bytes (&flipped, 4); \ ! 384: *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ ! 385: } ! 386: ! 387: #ifdef notdef ! 388: /* Interface definitions for kernel debugger KDB. */ ! 389: ! 390: /* Map machine fault codes into signal numbers. ! 391: First subtract 0, divide by 4, then index in a table. ! 392: Faults for which the entry in this table is 0 ! 393: are not handled by KDB; the program's own trap handler ! 394: gets to handle then. */ ! 395: ! 396: #define FAULT_CODE_ORIGIN 0 ! 397: #define FAULT_CODE_UNITS 4 ! 398: #define FAULT_TABLE \ ! 399: { 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ ! 400: 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ ! 401: 0, 0, 0, 0, 0, 0, 0, 0} ! 402: ! 403: /* Start running with a stack stretching from BEG to END. ! 404: BEG and END should be symbols meaningful to the assembler. ! 405: This is used only for kdb. */ ! 406: ! 407: #define INIT_STACK(beg, end) \ ! 408: { asm (".globl end"); \ ! 409: asm ("movl $ end, sp"); \ ! 410: asm ("clrl fp"); } ! 411: ! 412: /* Push the frame pointer register on the stack. */ ! 413: #define PUSH_FRAME_PTR \ ! 414: asm ("pushl fp"); ! 415: ! 416: /* Copy the top-of-stack to the frame pointer register. */ ! 417: #define POP_FRAME_PTR \ ! 418: asm ("movl (sp), fp"); ! 419: ! 420: /* After KDB is entered by a fault, push all registers ! 421: that GDB thinks about (all NUM_REGS of them), ! 422: so that they appear in order of ascending GDB register number. ! 423: The fault code will be on the stack beyond the last register. */ ! 424: ! 425: #define PUSH_REGISTERS \ ! 426: { asm ("pushl 8(sp)"); \ ! 427: asm ("pushl 8(sp)"); \ ! 428: asm ("pushal 0x14(sp)"); \ ! 429: asm ("pushr $037777"); } ! 430: ! 431: /* Assuming the registers (including processor status) have been ! 432: pushed on the stack in order of ascending GDB register number, ! 433: restore them and return to the address in the saved PC register. */ ! 434: ! 435: #define POP_REGISTERS \ ! 436: { asm ("popr $037777"); \ ! 437: asm ("subl2 $8,(sp)"); \ ! 438: asm ("movl (sp),sp"); \ ! 439: asm ("rei"); } ! 440: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.