put in cache initialization in at beginning of process startup
[unix-history] / usr / src / usr.bin / pascal / pdx / breakpoint / bp.c
CommitLineData
0acacf05
ML
1/* Copyright (c) 1982 Regents of the University of California */
2
3static char sccsid[] = "@(#)bp.c 1.1 %G%";
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
18unsigned int uniqueid;
19
20/*
21 * Add a breakpoint to the list, return a pointer to it.
22 */
23
24BPINFO *newbp(addr, type, block, cond, node, line)
25ADDRESS addr;
26BPTYPE type;
27SYM *block;
28NODE *cond;
29NODE *node;
30LINENO 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
57addbp(addr, type, block, cond, node, line)
58ADDRESS addr;
59BPTYPE type;
60SYM *block;
61NODE *cond;
62NODE *node;
63LINENO 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
76delbp(id)
77unsigned 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
122bpfree()
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}