date and time created 82/01/18 19:19:53 by linton
authorMark Linton <linton@ucbvax.Berkeley.EDU>
Tue, 19 Jan 1982 11:19:53 +0000 (03:19 -0800)
committerMark Linton <linton@ucbvax.Berkeley.EDU>
Tue, 19 Jan 1982 11:19:53 +0000 (03:19 -0800)
SCCS-vsn: usr.bin/pascal/pdx/breakpoint/bp.c 1.1

usr/src/usr.bin/pascal/pdx/breakpoint/bp.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/pascal/pdx/breakpoint/bp.c b/usr/src/usr.bin/pascal/pdx/breakpoint/bp.c
new file mode 100644 (file)
index 0000000..ac193f5
--- /dev/null
@@ -0,0 +1,134 @@
+/* Copyright (c) 1982 Regents of the University of California */
+
+static char sccsid[] = "@(#)bp.c 1.1 %G%";
+
+/*
+ * Direct management of bpinfo structures.
+ */
+
+#include "defs.h"
+#include "breakpoint.h"
+#include "tree.h"
+#include "sym.h"
+#include "main.h"
+#include "source.h"
+#include "object.h"
+#include "bp.rep"
+
+unsigned int uniqueid;
+
+/*
+ * Add a breakpoint to the list, return a pointer to it.
+ */
+
+BPINFO *newbp(addr, type, block, cond, node, line)
+ADDRESS addr;
+BPTYPE type;
+SYM *block;
+NODE *cond;
+NODE *node;
+LINENO line;
+{
+       register BPINFO *p;
+
+       p = alloc(1, BPINFO);
+       p->bpid = ++uniqueid;
+       p->bpaddr = addr;
+       p->bptype = type;
+       p->bpblock = block;
+       p->bpcond = cond;
+       p->bpnode = node;
+       p->bpline = line;
+       p->bpnext = bphead;
+       if (option('b')) {
+               printf("new bp (%d) at %d, type %d\n", p->bpid, p->bpaddr, p->bptype);
+               fflush(stdout);
+       }
+       bphead = p;
+       return(p);
+}
+
+/*
+ * Add a breakpoint, but don't return anything.
+ * Just for folks outside of "breakpoint" who don't know that
+ * a BPINFO exists.
+ */
+
+addbp(addr, type, block, cond, node, line)
+ADDRESS addr;
+BPTYPE type;
+SYM *block;
+NODE *cond;
+NODE *node;
+LINENO line;
+{
+       BPINFO *p;
+
+       p = newbp(addr, type, block, cond, node, line);
+}
+
+/*
+ * Delete a breakpoint.
+ *
+ * Print out a cryptic error message if it can't be found.
+ */
+
+delbp(id)
+unsigned int id;
+{
+       register BPINFO *p, *last;
+
+       last = NIL;
+       for (p = bphead; p != NIL; p = p->bpnext) {
+               if (p->bpid == id) {
+                       break;
+               }
+               last = p;
+       }
+       if (p == NIL) {
+               error("%d unknown", id);
+       }
+       switch (p->bptype) {
+               case ALL_ON:
+                       if (p->bpline >= 0) {
+                               tracing--;
+                       } else {
+                               inst_tracing--;
+                       }
+                       break;
+
+               case STOP_ON:
+                       var_tracing--;
+                       break;
+               
+               default:
+                       /* do nothing */
+                       break;
+       }
+       if (last == NIL) {
+               bphead = p->bpnext;
+       } else {
+               last->bpnext = p->bpnext;
+       }
+       tfree(p->bpcond);
+       tfree(p->bpnode);
+       dispose(p);
+}
+
+/*
+ * Free all storage in the breakpoint table.
+ */
+
+bpfree()
+{
+       register BPINFO *p, *next;
+
+       fixbps();
+       for (p = bphead; p != NIL; p = next) {
+               next = p->bpnext;
+               tfree(p->bpcond);
+               tfree(p->bpnode);
+               dispose(p);
+       }
+       bphead = NIL;
+}