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

Defined functions

addcond defined in line 31; used 2 times
condfree defined in line 122; used 1 times
trcond defined in line 82; used 1 times

Defined variables

cond_list defined in line 25; used 8 times
sccsid defined in line 8; never used

Defined struct's

tr_cond_list defined in line 19; used 2 times
  • in line 22(2)

Defined typedef's

TR_COND_LIST defined in line 23; used 7 times
Last modified: 1985-06-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2780
Valid CSS Valid XHTML 1.0 Strict