Annotation of 43BSDReno/contrib/emacs-18.55/gdb/m-umax.h, revision 1.1

1.1     ! root        1: /* Definitions to make GDB run on an encore under umax 4.2
        !             2:    Copyright (C) 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: #define HAVE_WAIT_STRUCT
        !            26: 
        !            27: /* Encore's modifications to ptrace format */
        !            28: 
        !            29: #define UMAX_PTRACE
        !            30: 
        !            31: /* Encore's modifications to core-file format */
        !            32: 
        !            33: #define UMAX_CORE
        !            34: 
        !            35: /* Do implement the attach and detach commands.  */
        !            36: 
        !            37: #define ATTACH_DETACH
        !            38: 
        !            39: /* Define this if the C compiler puts an underscore at the front
        !            40:    of external names before giving them to the linker.  */
        !            41: 
        !            42: #define NAMES_HAVE_UNDERSCORE
        !            43: 
        !            44: /* Exec files and symbol tables are in COFF format */
        !            45: 
        !            46: #define COFF_FORMAT
        !            47: 
        !            48: /* Offset from address of function to start of its code.
        !            49:    Zero on most machines.  */
        !            50: 
        !            51: #define FUNCTION_START_OFFSET 0
        !            52: 
        !            53: /* Advance PC across any function entry prologue instructions
        !            54:    to reach some "real" code.  */
        !            55: 
        !            56: #define SKIP_PROLOGUE(pc)                              \
        !            57: { register unsigned char op = read_memory_integer (pc, 1);     \
        !            58:   if (op == 0x82) { op = read_memory_integer (pc+2,1);  \
        !            59:                    if ((op & 0x80) == 0) pc += 3;      \
        !            60:                    else if ((op & 0xc0) == 0x80) pc += 4;      \
        !            61:                    else pc += 6;                       \
        !            62:                   }                                    \
        !            63: }
        !            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: /* Address of end of stack space.  */
        !            74: 
        !            75: #define STACK_END_ADDR (0xfffff000)
        !            76: 
        !            77: /* Stack grows downward.  */
        !            78: 
        !            79: #define INNER_THAN <
        !            80: 
        !            81: /* Sequence of bytes for breakpoint instruction.  */
        !            82: 
        !            83: #define BREAKPOINT {0xf2}
        !            84: 
        !            85: /* Amount PC must be decremented by after a breakpoint.
        !            86:    This is often the number of bytes in BREAKPOINT
        !            87:    but not always.  */
        !            88: 
        !            89: #define DECR_PC_AFTER_BREAK 0
        !            90: 
        !            91: /* Nonzero if instruction at PC is a return instruction.  */
        !            92: 
        !            93: #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12)
        !            94: 
        !            95: #ifndef NaN
        !            96: #include <nan.h>
        !            97: #endif NaN
        !            98: 
        !            99: /* Return 1 if P points to an invalid floating point value.  */
        !           100: 
        !           101: #define INVALID_FLOAT(p, s) \
        !           102:         ((s == sizeof (float))?        \
        !           103:                NaF (*(float *) p) :    \
        !           104:                NaD (*(double *) p))
        !           105: 
        !           106: /* Say how long (ordinary) registers are.  */
        !           107: 
        !           108: #define REGISTER_TYPE long
        !           109: 
        !           110: /* Number of machine registers */
        !           111: 
        !           112: #define NUM_REGS               25
        !           113: 
        !           114: #define NUM_GENERAL_REGS       8
        !           115: 
        !           116: /* Initializer for an array of names of registers.
        !           117:    There should be NUM_REGS strings in this initializer.  */
        !           118: 
        !           119: #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",        \
        !           120:                        "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \
        !           121:                        "sp", "fp", "pc", "ps",                         \
        !           122:                        "fsr",                                          \
        !           123:                        "l0", "l1", "l2", "l3", "xx",                   \
        !           124:                        }
        !           125: 
        !           126: /* Register numbers of various important registers.
        !           127:    Note that some of these values are "real" register numbers,
        !           128:    and correspond to the general registers of the machine,
        !           129:    and some are "phony" register numbers which are too large
        !           130:    to be actual register numbers as far as the user is concerned
        !           131:    but do serve to get the desired values when passed to read_register.  */
        !           132: 
        !           133: #define FP0_REGNUM 8           /* Floating point register 0 */
        !           134: #define SP_REGNUM 16           /* Contains address of top of stack */
        !           135: #define AP_REGNUM FP_REGNUM
        !           136: #define FP_REGNUM 17           /* Contains address of executing stack frame */
        !           137: #define PC_REGNUM 18           /* Contains program counter */
        !           138: #define PS_REGNUM 19           /* Contains processor status */
        !           139: #define FPS_REGNUM 20          /* Floating point status register */
        !           140: #define LP0_REGNUM 21          /* Double register 0 (same as FP0) */
        !           141: 
        !           142: /* called from register_addr() -- blockend not used for now */
        !           143: #define REGISTER_U_ADDR(addr, blockend, regno) \
        !           144: {                                                                      \
        !           145:   switch (regno) {                                                     \
        !           146:   case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:      \
        !           147:        addr = PU_R0 - (regno * sizeof (int)); break;                   \
        !           148:   case SP_REGNUM:                                                      \
        !           149:        addr = PU_SP; break;                                            \
        !           150:   case PC_REGNUM:                                                      \
        !           151:        addr = PU_PC; break;                                            \
        !           152:   case FP_REGNUM:                                                      \
        !           153:        addr = PU_FP; break;                                            \
        !           154:   case PS_REGNUM:                                                      \
        !           155:        addr = PU_PSL; break;                                           \
        !           156:   case FPS_REGNUM:                                                     \
        !           157:        addr = PU_FSR; break;                                           \
        !           158:   case FP0_REGNUM + 0: case FP0_REGNUM + 1:                            \
        !           159:   case FP0_REGNUM + 2: case FP0_REGNUM + 3:                            \
        !           160:   case FP0_REGNUM + 4: case FP0_REGNUM + 5:                            \
        !           161:   case FP0_REGNUM + 6: case FP0_REGNUM + 7:                            \
        !           162:        addr = PU_F0 + (regno - FP0_REGNUM) * sizeof (float); break;    \
        !           163:   case LP0_REGNUM + 0: case LP0_REGNUM + 1:                            \
        !           164:   case LP0_REGNUM + 2: case LP0_REGNUM + 3:                            \
        !           165:        addr = PU_F0 + (regno - LP0_REGNUM) * sizeof (double); break;   \
        !           166:   default:                                                             \
        !           167:        printf ("bad argument to REGISTER_U_ADDR %d\n", regno);         \
        !           168:        abort ();                                                       \
        !           169:   }                                                                    \
        !           170: }
        !           171: 
        !           172: /* Total amount of space needed to store our copies of the machine's
        !           173:    register state, the array `registers'.  */
        !           174: #define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double))
        !           175: 
        !           176: /* Index within `registers' of the first byte of the space for
        !           177:    register N.  */
        !           178: 
        !           179: #define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \
        !           180:        LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4)
        !           181: 
        !           182: /* Number of bytes of storage in the actual machine representation
        !           183:    for register N.  On the 32000, all regs are 4 bytes
        !           184:    except for the doubled floating registers. */
        !           185: 
        !           186: #define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
        !           187: 
        !           188: /* Number of bytes of storage in the program's representation
        !           189:    for register N.  On the 32000, all regs are 4 bytes
        !           190:    except for the doubled floating registers. */
        !           191: 
        !           192: #define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4)
        !           193: 
        !           194: /* Largest value REGISTER_RAW_SIZE can have.  */
        !           195: 
        !           196: #define MAX_REGISTER_RAW_SIZE 8
        !           197: 
        !           198: /* Largest value REGISTER_VIRTUAL_SIZE can have.  */
        !           199: 
        !           200: #define MAX_REGISTER_VIRTUAL_SIZE 8
        !           201: 
        !           202: /* Nonzero if register N requires conversion
        !           203:    from raw format to virtual format.  */
        !           204: 
        !           205: #define REGISTER_CONVERTIBLE(N) 0
        !           206: 
        !           207: /* Convert data from raw format for register REGNUM
        !           208:    to virtual format for register REGNUM.  */
        !           209: 
        !           210: #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO)    \
        !           211:   bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
        !           212: 
        !           213: /* Convert data from virtual format for register REGNUM
        !           214:    to raw format for register REGNUM.  */
        !           215: 
        !           216: #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO)        \
        !           217:   bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
        !           218: 
        !           219: /* Return the GDB type object for the "standard" data type
        !           220:    of data in register N.  */
        !           221: 
        !           222: #define REGISTER_VIRTUAL_TYPE(N) \
        !           223:        (((N) < FP0_REGNUM) ?                           \
        !           224:                builtin_type_int :                      \
        !           225:                ((N) < FP0_REGNUM + 8) ?                \
        !           226:                        builtin_type_float :            \
        !           227:                        ((N) < LP0_REGNUM) ?            \
        !           228:                                builtin_type_int :      \
        !           229:                                builtin_type_double)
        !           230: 
        !           231: /* Extract from an array REGBUF containing the (raw) register state
        !           232:    a function return value of type TYPE, and copy that, in virtual format,
        !           233:    into VALBUF.  */
        !           234: 
        !           235: #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
        !           236:   bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
        !           237: 
        !           238: /* Write into appropriate registers a function return value
        !           239:    of type TYPE, given in virtual format.  */
        !           240: 
        !           241: #define STORE_RETURN_VALUE(TYPE,VALBUF) \
        !           242:   write_register_bytes (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, TYPE_LENGTH (TYPE))
        !           243: 
        !           244: /* Extract from an array REGBUF containing the (raw) register state
        !           245:    the address in which a function should return its structure value,
        !           246:    as a CORE_ADDR (or an expression that can be used as one).  */
        !           247: 
        !           248: #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
        !           249: 
        !           250: /* Describe the pointer in each stack frame to the previous stack frame
        !           251:    (its caller).  */
        !           252: 
        !           253: /* FRAME_CHAIN takes a frame's nominal address
        !           254:    and produces the frame's chain-pointer.
        !           255: 
        !           256:    FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
        !           257:    and produces the nominal address of the caller frame.
        !           258: 
        !           259:    However, if FRAME_CHAIN_VALID returns zero,
        !           260:    it means the given frame is the outermost one and has no caller.
        !           261:    In that case, FRAME_CHAIN_COMBINE is not used.  */
        !           262: 
        !           263: /* In the case of the ns32000 series, the frame's nominal address is the FP
        !           264:    value, and at that address is saved previous FP value as a 4-byte word.  */
        !           265: 
        !           266: #define FRAME_CHAIN(thisframe)  (read_memory_integer (thisframe, 4))
        !           267: 
        !           268: #define FRAME_CHAIN_VALID(chain, thisframe) \
        !           269:   (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end))
        !           270: 
        !           271: #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
        !           272: 
        !           273: /* Define other aspects of the stack frame.  */
        !           274: 
        !           275: #define FRAME_SAVED_PC(frame) (read_memory_integer (frame + 4, 4))
        !           276: 
        !           277: /* Compute base of arguments. */
        !           278: 
        !           279: #define FRAME_ARGS_ADDRESS(fi) \
        !           280:   ((ns32k_get_enter_addr (fi.pc) > 1) ? \
        !           281:        ((fi).frame) : (read_register (SP_REGNUM) - 4))
        !           282: 
        !           283: #define FRAME_LOCALS_ADDRESS(fi) ((fi).frame)
        !           284: 
        !           285: /* Get the address of the enter opcode for this function, if it is active.
        !           286:    Returns positive address > 1 if pc is between enter/exit,
        !           287:    1 if pc before enter or after exit, 0 otherwise. */
        !           288: 
        !           289: #ifndef CORE_ADDR
        !           290: #include "defs.h"   /* Make sure CORE_ADDR is defined.  */
        !           291: #endif
        !           292: 
        !           293: extern CORE_ADDR ns32k_get_enter_addr ();
        !           294: 
        !           295: /* Return number of args passed to a frame.
        !           296:    Can return -1, meaning no way to tell.
        !           297:    Encore's C compiler often reuses same area on stack for args,
        !           298:    so this will often not work properly.  If the arg names
        !           299:    are known, it's likely most of them will be printed. */
        !           300: 
        !           301: #define FRAME_NUM_ARGS(numargs, fi)                    \
        !           302: { CORE_ADDR    pc;                                     \
        !           303:   CORE_ADDR    enter_addr;                             \
        !           304:   unsigned int insn;                                   \
        !           305:   unsigned int addr_mode;                              \
        !           306:   int width;                                           \
        !           307:                                                        \
        !           308:   numargs = -1;                                                \
        !           309:   enter_addr = ns32k_get_enter_addr (fi.pc);           \
        !           310:   if (enter_addr > 0)                                  \
        !           311:     {                                                  \
        !           312:       pc = (enter_addr == 1) ?                         \
        !           313:        SAVED_PC_AFTER_CALL () :                        \
        !           314:        FRAME_SAVED_PC (fi.frame);                      \
        !           315:       insn = read_memory_integer (pc,2);               \
        !           316:       addr_mode = (insn >> 11) & 0x1f;                 \
        !           317:       insn = insn & 0x7ff;                             \
        !           318:       if ((insn & 0x7fc) == 0x57c &&                   \
        !           319:                addr_mode == 0x14) /* immediate */      \
        !           320:        {                                               \
        !           321:          if (insn == 0x57c) /* adjspb */               \
        !           322:                width = 1;                              \
        !           323:          else if (insn == 0x57d) /* adjspw */          \
        !           324:                width = 2;                              \
        !           325:          else if (insn == 0x57f) /* adjspd */          \
        !           326:                width = 4;                              \
        !           327:          numargs = read_memory_integer (pc+2,width);   \
        !           328:          if (width > 1)                                \
        !           329:            flip_bytes (&numargs, width);               \
        !           330:          numargs = - sign_extend (numargs, width*8) / 4;\
        !           331:        }                                               \
        !           332:     }                                                  \
        !           333: }
        !           334: 
        !           335: /* Return number of bytes at start of arglist that are not really args.  */
        !           336: 
        !           337: #define FRAME_ARGS_SKIP 8
        !           338: 
        !           339: /* Put here the code to store, into a struct frame_saved_regs,
        !           340:    the addresses of the saved registers of frame described by FRAME_INFO.
        !           341:    This includes special registers such as pc and fp saved in special
        !           342:    ways in the stack frame.  sp is even more special:
        !           343:    the address we return for it IS the sp for the next frame.  */
        !           344: 
        !           345: #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs)    \
        !           346: {                                                              \
        !           347:   register int regmask, regnum;                                \
        !           348:   int          localcount;                                     \
        !           349:   register CORE_ADDR   enter_addr;                             \
        !           350:   register CORE_ADDR   next_addr;                              \
        !           351:                                                                \
        !           352:   bzero (&(frame_saved_regs), sizeof (frame_saved_regs));      \
        !           353:   enter_addr = ns32k_get_enter_addr ((frame_info).pc);         \
        !           354:   if (enter_addr > 1)                                          \
        !           355:     {                                                          \
        !           356:       regmask = read_memory_integer (enter_addr+1, 1) & 0xff;  \
        !           357:       localcount = ns32k_localcount (enter_addr);              \
        !           358:       next_addr = (frame_info).frame + localcount;             \
        !           359:       for (regnum = 0; regnum < 8; regnum++, regmask >>= 1)    \
        !           360:        (frame_saved_regs).regs[regnum] = (regmask & 1) ?       \
        !           361:                                          (next_addr -= 4) : 0; \
        !           362:       (frame_saved_regs).regs[SP_REGNUM] = (frame_info).frame + 4;\
        !           363:       (frame_saved_regs).regs[PC_REGNUM] = (frame_info).frame + 4;\
        !           364:       (frame_saved_regs).regs[FP_REGNUM] =                     \
        !           365:                  (read_memory_integer ((frame_info).frame, 4));\
        !           366:     }                                                          \
        !           367:   else if (enter_addr == 1)                                    \
        !           368:     {                                                          \
        !           369:       CORE_ADDR sp = read_register (SP_REGNUM);                        \
        !           370:       (frame_saved_regs).regs[PC_REGNUM] = sp;                 \
        !           371:       (frame_saved_regs).regs[SP_REGNUM] = sp + 4;             \
        !           372:     }                                                          \
        !           373: }
        !           374: 
        !           375: /* Compensate for lack of `vprintf' function.  */ 
        !           376: #define vprintf(format, ap) _doprnt (format, ap, stdout) 
        !           377: 
        !           378: /* Things needed for making the inferior call functions.  */
        !           379: 
        !           380: /* Push an empty stack frame, to record the current PC, etc.  */
        !           381: 
        !           382: #define PUSH_DUMMY_FRAME \
        !           383: { register CORE_ADDR sp = read_register (SP_REGNUM);\
        !           384:   register int regnum;                             \
        !           385:   sp = push_word (sp, read_register (PC_REGNUM));   \
        !           386:   sp = push_word (sp, read_register (FP_REGNUM));   \
        !           387:   write_register (FP_REGNUM, sp);                  \
        !           388:   for (regnum = 0; regnum < 8; regnum++)  \
        !           389:     sp = push_word (sp, read_register (regnum));    \
        !           390:   write_register (SP_REGNUM, sp);                      \
        !           391: }
        !           392: 
        !           393: /* Discard from the stack the innermost frame, restoring all registers.  */
        !           394: 
        !           395: #define POP_FRAME  \
        !           396: { register CORE_ADDR fp = read_register (FP_REGNUM);            \
        !           397:   register int regnum;                                          \
        !           398:   struct frame_saved_regs fsr;                                  \
        !           399:   struct frame_info fi;                                                 \
        !           400:   fi = get_frame_info (fp);                                     \
        !           401:   get_frame_saved_regs (&fi, &fsr);                             \
        !           402:   for (regnum = 0; regnum < 8; regnum++)                        \
        !           403:     if (fsr.regs[regnum])                                       \
        !           404:       write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
        !           405:   write_register (FP_REGNUM, read_memory_integer (fp, 4));      \
        !           406:   write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));   \
        !           407:   write_register (SP_REGNUM, fp + 8);                           \
        !           408: }
        !           409: 
        !           410: /* This sequence of words is the instructions
        !           411:      enter     0xff,0          82 ff 00
        !           412:      jsr       @0x00010203     7f ae c0 01 02 03
        !           413:      adjspd    0x69696969      7f a5 01 02 03 04
        !           414:      bpt                       f2
        !           415:    Note this is 16 bytes.  */
        !           416: 
        !           417: #define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 }
        !           418: 
        !           419: #define CALL_DUMMY_START_OFFSET        3
        !           420: #define CALL_DUMMY_LENGTH      16
        !           421: #define CALL_DUMMY_ADDR                5
        !           422: #define CALL_DUMMY_NARGS       11
        !           423: 
        !           424: /* Insert the specified number of args and function address
        !           425:    into a call sequence of the above form stored at DUMMYNAME.  */
        !           426: 
        !           427: #define FIX_CALL_DUMMY(dummyname, fun, nargs)                  \
        !           428: {                                                              \
        !           429:        int     flipped;                                        \
        !           430:        flipped = fun | 0xc0000000;                             \
        !           431:        flip_bytes (&flipped, 4);                               \
        !           432:        *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped;    \
        !           433:        flipped = - nargs * 4;                                  \
        !           434:        flip_bytes (&flipped, 4);                               \
        !           435:        *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped;   \
        !           436: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.