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

Defined functions

addbp defined in line 63; used 5 times
bpfree defined in line 128; never used
delbp defined in line 82; used 2 times
newbp defined in line 30; used 2 times

Defined variables

sccsid defined in line 8; never used
uniqueid defined in line 24; used 1 times
  • in line 41
Last modified: 1985-06-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2254
Valid CSS Valid XHTML 1.0 Strict