Annotation of 42BSD/ucb/pascal/pdx/breakpoint/bp.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1982 Regents of the University of California */
        !             2: 
        !             3: static char sccsid[] = "@(#)bp.c 1.1 1/18/82";
        !             4: 
        !             5: /*
        !             6:  * Direct management of bpinfo structures.
        !             7:  */
        !             8: 
        !             9: #include "defs.h"
        !            10: #include "breakpoint.h"
        !            11: #include "tree.h"
        !            12: #include "sym.h"
        !            13: #include "main.h"
        !            14: #include "source.h"
        !            15: #include "object.h"
        !            16: #include "bp.rep"
        !            17: 
        !            18: unsigned int uniqueid;
        !            19: 
        !            20: /*
        !            21:  * Add a breakpoint to the list, return a pointer to it.
        !            22:  */
        !            23: 
        !            24: BPINFO *newbp(addr, type, block, cond, node, line)
        !            25: ADDRESS addr;
        !            26: BPTYPE type;
        !            27: SYM *block;
        !            28: NODE *cond;
        !            29: NODE *node;
        !            30: LINENO line;
        !            31: {
        !            32:        register BPINFO *p;
        !            33: 
        !            34:        p = alloc(1, BPINFO);
        !            35:        p->bpid = ++uniqueid;
        !            36:        p->bpaddr = addr;
        !            37:        p->bptype = type;
        !            38:        p->bpblock = block;
        !            39:        p->bpcond = cond;
        !            40:        p->bpnode = node;
        !            41:        p->bpline = line;
        !            42:        p->bpnext = bphead;
        !            43:        if (option('b')) {
        !            44:                printf("new bp (%d) at %d, type %d\n", p->bpid, p->bpaddr, p->bptype);
        !            45:                fflush(stdout);
        !            46:        }
        !            47:        bphead = p;
        !            48:        return(p);
        !            49: }
        !            50: 
        !            51: /*
        !            52:  * Add a breakpoint, but don't return anything.
        !            53:  * Just for folks outside of "breakpoint" who don't know that
        !            54:  * a BPINFO exists.
        !            55:  */
        !            56: 
        !            57: addbp(addr, type, block, cond, node, line)
        !            58: ADDRESS addr;
        !            59: BPTYPE type;
        !            60: SYM *block;
        !            61: NODE *cond;
        !            62: NODE *node;
        !            63: LINENO line;
        !            64: {
        !            65:        BPINFO *p;
        !            66: 
        !            67:        p = newbp(addr, type, block, cond, node, line);
        !            68: }
        !            69: 
        !            70: /*
        !            71:  * Delete a breakpoint.
        !            72:  *
        !            73:  * Print out a cryptic error message if it can't be found.
        !            74:  */
        !            75: 
        !            76: delbp(id)
        !            77: unsigned int id;
        !            78: {
        !            79:        register BPINFO *p, *last;
        !            80: 
        !            81:        last = NIL;
        !            82:        for (p = bphead; p != NIL; p = p->bpnext) {
        !            83:                if (p->bpid == id) {
        !            84:                        break;
        !            85:                }
        !            86:                last = p;
        !            87:        }
        !            88:        if (p == NIL) {
        !            89:                error("%d unknown", id);
        !            90:        }
        !            91:        switch (p->bptype) {
        !            92:                case ALL_ON:
        !            93:                        if (p->bpline >= 0) {
        !            94:                                tracing--;
        !            95:                        } else {
        !            96:                                inst_tracing--;
        !            97:                        }
        !            98:                        break;
        !            99: 
        !           100:                case STOP_ON:
        !           101:                        var_tracing--;
        !           102:                        break;
        !           103:                
        !           104:                default:
        !           105:                        /* do nothing */
        !           106:                        break;
        !           107:        }
        !           108:        if (last == NIL) {
        !           109:                bphead = p->bpnext;
        !           110:        } else {
        !           111:                last->bpnext = p->bpnext;
        !           112:        }
        !           113:        tfree(p->bpcond);
        !           114:        tfree(p->bpnode);
        !           115:        dispose(p);
        !           116: }
        !           117: 
        !           118: /*
        !           119:  * Free all storage in the breakpoint table.
        !           120:  */
        !           121: 
        !           122: bpfree()
        !           123: {
        !           124:        register BPINFO *p, *next;
        !           125: 
        !           126:        fixbps();
        !           127:        for (p = bphead; p != NIL; p = next) {
        !           128:                next = p->bpnext;
        !           129:                tfree(p->bpcond);
        !           130:                tfree(p->bpnode);
        !           131:                dispose(p);
        !           132:        }
        !           133:        bphead = NIL;
        !           134: }

unix.superglobalmegacorp.com

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