Annotation of 42BSD/ucb/pascal/pdx/runtime/entry.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1982 Regents of the University of California */
        !             2: 
        !             3: static char sccsid[] = "@(#)entry.c 1.1 1/18/82";
        !             4: 
        !             5: /*
        !             6:  * routines to deal with the entry addresses of blocks
        !             7:  */
        !             8: 
        !             9: #include "defs.h"
        !            10: #include "runtime.h"
        !            11: #include "frame.rep"
        !            12: #include "machine.h"
        !            13: #include "process.h"
        !            14: #include "sym.h"
        !            15: #include "source.h"
        !            16: #include "object.h"
        !            17: #include "process/pxinfo.h"
        !            18: #include "process/process.rep"
        !            19: 
        !            20: /*
        !            21:  * Return the address of the beginning of the procedure/function
        !            22:  * associated with the given frame.
        !            23:  */
        !            24: 
        !            25: ADDRESS entry(frp)
        !            26: register FRAME *frp;
        !            27: {
        !            28:        return(frp->blockp - 2 - ENDOFF);
        !            29: }
        !            30: 
        !            31: /*
        !            32:  * Find the entry address of the caller of the current block.
        !            33:  * This is only called in connection with breakpoints.
        !            34:  *
        !            35:  * This routine assumes it is at the very beginning of the block.
        !            36:  */
        !            37: 
        !            38: ADDRESS caller_addr()
        !            39: {
        !            40:        FRAME *frp;
        !            41: 
        !            42:        if ((frp = curframe()) == NIL) {
        !            43:                panic("caller_addr(main program)");
        !            44:        }
        !            45:        frp = nextframe(frp);
        !            46:        if (frp == NIL) {
        !            47:                return(codeloc(program));
        !            48:        } else {
        !            49:                return(entry(frp));
        !            50:        }
        !            51: }
        !            52: 
        !            53: /*
        !            54:  * Find the return address of the current procedure/function.
        !            55:  *
        !            56:  * There are two special cases:
        !            57:  *
        !            58:  *     we're right at the beginning of the main program
        !            59:  *     we're right at the beginning of some procedure or function
        !            60:  *
        !            61:  * The first one is handled by returning the last instruction in
        !            62:  * the object code.  In the second case, we get the return address
        !            63:  * directly from the process' stack.
        !            64:  */
        !            65: 
        !            66: ADDRESS return_addr()
        !            67: {
        !            68:        ADDRESS addr;
        !            69:        FRAME *frp, frame;
        !            70: 
        !            71:        if (pc == codeloc(program)) {
        !            72:                addr = lastaddr();
        !            73:        } else {
        !            74:                frp = curframe();
        !            75:                if (frp == NIL) {
        !            76:                        dread(&frame, (ADDRESS) process->sp, sizeof(FRAME));
        !            77:                        addr = frame.save_pc - ENDOFF;
        !            78:                } else {
        !            79:                        addr = frp->save_pc;
        !            80:                }
        !            81:        }
        !            82:        return addr;
        !            83: }
        !            84: 
        !            85: /*
        !            86:  * Calculate the entry address for a procedure or function parameter,
        !            87:  * given the address of the descriptor.
        !            88:  */
        !            89: 
        !            90: ADDRESS fparamaddr(a)
        !            91: ADDRESS a;
        !            92: {
        !            93:        ADDRESS r;
        !            94: 
        !            95:        dread(&r, a, sizeof(r));
        !            96:        return (r - ENDOFF);
        !            97: }

unix.superglobalmegacorp.com

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