BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / pascal / pdx / breakpoint / status.c
CommitLineData
505bf312
KB
1/*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
af359dea
C
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
d8be300a 32 */
6c027037 33
d8be300a 34#ifndef lint
af359dea 35static char sccsid[] = "@(#)status.c 5.2 (Berkeley) 4/16/91";
505bf312
KB
36#endif /* not lint */
37
6c027037
ML
38/*
39 * Print out what's currently being traced by looking at
40 * the currently active breakpoints.
41 *
42 * The list is in LIFO order, we print it FIFO by going recursive.
43 */
44
45#include "defs.h"
46#include "breakpoint.h"
47#include "tree.h"
48#include "sym.h"
49#include "source.h"
50#include "object.h"
51#include "mappings.h"
52#include "bp.rep"
53
54#define printnum(id) if (!isredirected()) printf("(%d) ", id)
55
56status()
57{
58 if (bphead == NIL) {
59 if (!isredirected()) {
60 printf("no trace's or stop's active\n");
61 }
62 } else {
63 bpstatus(bphead);
64 }
65}
66
67LOCAL bpstatus(bp)
68BPINFO *bp;
69{
70 register BPINFO *p;
71 LINENO n;
72 SYM *s;
73 NODE *t;
74 char *trname, *stname;
75
76 p = bp;
77 if (p->bpnext != NIL) {
78 bpstatus(p->bpnext);
79 }
80 t = p->bpnode;
81 if (p->bpline >= 0) {
82 n = linelookup(p->bpaddr);
83 trname = "trace";
84 stname = "stop";
85 } else {
86 n = p->bpaddr;
87 trname = "tracei";
88 stname = "stopi";
89 }
90 switch(p->bptype) {
91 case INST:
92 printnum(p->bpid);
93 printf("%s %d", trname, n);
94 break;
95
96 case ALL_ON:
97 printnum(p->bpid);
98 printf("%s", trname);
99 s = p->bpblock;
100 if (s != program) {
101 printf(" in ");
102 printname(s);
103 }
104 break;
105
106 case STOP_ON:
107 printnum(p->bpid);
108 printf("%s", stname);
109 if (t != NIL) {
110 printf(" ");
111 prtree(t);
112 }
113 s = p->bpblock;
114 if (s != program) {
115 printf(" in ");
116 printname(s);
117 }
118 break;
119
120 case BLOCK_ON:
121 case TERM_ON:
122 s = p->bpblock;
123 printnum(p->bpid);
124 printf("%s ", trname);
125 prtree(t);
126 if (s != program) {
127 printf(" in ");
128 printname(s);
129 }
130 break;
131
132 case AT_BP:
133 printnum(p->bpid);
134 printf("%s ", trname);
135 prtree(t);
136 printf(" at %d", p->bpline);
137 break;
138
139 case STOP_BP:
140 printnum(p->bpid);
141 printf("%s", stname);
142 if (t != NIL) {
143 printf(" ");
144 prtree(t);
145 } else if ((s = p->bpblock) != NIL) {
146 printf(" in ");
147 printname(s);
148 } else if (p->bpline > 0) {
149 printf(" at %d", p->bpline);
150 } else {
151 printf(" at %d", p->bpaddr);
152 }
153 break;
154
155 /*
156 * Temporary breakpoints;
157 * return rather than break to avoid printing newline.
158 */
159 case ALL_OFF:
160 case CALL:
161 case RETURN:
162 case CALLPROC:
163 case STOP_OFF:
164 case BLOCK_OFF:
165 case TERM_OFF:
166 case END_BP:
167 return;
168
169 default:
170 panic("bptype %d in bplist", p->bptype);
171 }
172 if (p->bpcond != NIL) {
173 printf(" if ");
174 prtree(p->bpcond);
175 }
176 printf("\n");
177}
178
179/*
180 * Print the name of a symbol unambigously.
181 */
182
183LOCAL printname(s)
184SYM *s;
185{
186 if (isambiguous(s)) {
187 printwhich(s);
188 } else {
189 printf("%s", name(s));
190 }
191}