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

1.1     ! root        1: /* Copyright (c) 1982 Regents of the University of California */
        !             2: 
        !             3: static char sccsid[] = "@(#)trcond.c 1.1 1/18/82";
        !             4: 
        !             5: /*
        !             6:  * trace condition list -- a list of conditions that are to be
        !             7:  * checked before printing out the current source line or stopping.
        !             8:  */
        !             9: 
        !            10: #include "defs.h"
        !            11: #include "breakpoint.h"
        !            12: 
        !            13: typedef struct tr_cond_list {
        !            14:        TRTYPE trtype;
        !            15:        NODE *trace_condition;
        !            16:        struct tr_cond_list *next_condition;
        !            17: } TR_COND_LIST;
        !            18: 
        !            19: LOCAL TR_COND_LIST *cond_list;
        !            20: 
        !            21: /*
        !            22:  * add a condition to be checked before giving single stepping information
        !            23:  */
        !            24: 
        !            25: addcond(trtype, p)
        !            26: TRTYPE trtype;
        !            27: NODE *p;
        !            28: {
        !            29:        register TR_COND_LIST *c;
        !            30: 
        !            31:        if (p == NIL) {
        !            32:                return;
        !            33:        }
        !            34:        c = alloc(1, TR_COND_LIST);
        !            35:        c->trtype = trtype;
        !            36:        c->trace_condition = p;
        !            37:        c->next_condition = cond_list;
        !            38:        cond_list = c;
        !            39: }
        !            40: 
        !            41: /*
        !            42:  * delete a condition from the list
        !            43:  */
        !            44: 
        !            45: delcond(trtype, p)
        !            46: TRTYPE trtype;
        !            47: NODE *p;
        !            48: {
        !            49:        register TR_COND_LIST *c, *last;
        !            50: 
        !            51:        if (p == NIL) {
        !            52:                return;
        !            53:        }
        !            54:        last = NIL;
        !            55:        for (c = cond_list; c != NIL; c = c->next_condition) {
        !            56:                if (c->trtype == trtype && c->trace_condition == p) {
        !            57:                        break;
        !            58:                }
        !            59:        }
        !            60:        if (c == NIL) {
        !            61:                panic("tried to delete non-existent condition");
        !            62:        }
        !            63:        if (last == NIL) {
        !            64:                cond_list = c->next_condition;
        !            65:        } else {
        !            66:                last->next_condition = c->next_condition;
        !            67:        }
        !            68:        free(c);
        !            69: }
        !            70: 
        !            71: /*
        !            72:  * Determine if any trace condition on the list is true.
        !            73:  * If the list is empty, return TRUE.
        !            74:  */
        !            75: 
        !            76: BOOLEAN trcond()
        !            77: {
        !            78:        register TR_COND_LIST *c;
        !            79:        BOOLEAN foundcond;
        !            80: 
        !            81:        foundcond = FALSE;
        !            82:        for (c = cond_list; c != NIL; c = c->next_condition) {
        !            83:                if (c->trtype == TRPRINT) {
        !            84:                        if (cond(c->trace_condition)) {
        !            85:                                return(TRUE);
        !            86:                        } else {
        !            87:                                foundcond = TRUE;
        !            88:                        }
        !            89:                }
        !            90:        }
        !            91:        return !foundcond;
        !            92: }
        !            93: 
        !            94: /*
        !            95:  * Determine if any stop condition on the list is true.
        !            96:  * If the list is empty, return FALSE.
        !            97:  */
        !            98: 
        !            99: BOOLEAN stopcond()
        !           100: {
        !           101:        register TR_COND_LIST *c;
        !           102: 
        !           103:        for (c = cond_list; c != NIL; c = c->next_condition) {
        !           104:                if (c->trtype == TRSTOP && cond(c->trace_condition)) {
        !           105:                        return(TRUE);
        !           106:                }
        !           107:        }
        !           108:        return FALSE;
        !           109: }
        !           110: 
        !           111: /*
        !           112:  * Free all existing breakpoints.
        !           113:  * Trace conditions have been freed elsewhere.
        !           114:  */
        !           115: 
        !           116: condfree()
        !           117: {
        !           118:        TR_COND_LIST *c, *next;
        !           119: 
        !           120:        for (c = cond_list; c != NIL; c = next) {
        !           121:                next = c->next_condition;
        !           122:                dispose(c);
        !           123:        }
        !           124:        cond_list = NIL;
        !           125: }

unix.superglobalmegacorp.com

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