BSD 4_3_Net_2 development
[unix-history] / .ref-8c8a5b54e79564c14fc7a2823a21a8f048449bcf / 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 *
5 * %sccs.include.redist.c%
d8be300a 6 */
6c027037 7
d8be300a 8#ifndef lint
505bf312
KB
9static char sccsid[] = "@(#)status.c 5.2 (Berkeley) %G%";
10#endif /* not lint */
11
6c027037
ML
12/*
13 * Print out what's currently being traced by looking at
14 * the currently active breakpoints.
15 *
16 * The list is in LIFO order, we print it FIFO by going recursive.
17 */
18
19#include "defs.h"
20#include "breakpoint.h"
21#include "tree.h"
22#include "sym.h"
23#include "source.h"
24#include "object.h"
25#include "mappings.h"
26#include "bp.rep"
27
28#define printnum(id) if (!isredirected()) printf("(%d) ", id)
29
30status()
31{
32 if (bphead == NIL) {
33 if (!isredirected()) {
34 printf("no trace's or stop's active\n");
35 }
36 } else {
37 bpstatus(bphead);
38 }
39}
40
41LOCAL bpstatus(bp)
42BPINFO *bp;
43{
44 register BPINFO *p;
45 LINENO n;
46 SYM *s;
47 NODE *t;
48 char *trname, *stname;
49
50 p = bp;
51 if (p->bpnext != NIL) {
52 bpstatus(p->bpnext);
53 }
54 t = p->bpnode;
55 if (p->bpline >= 0) {
56 n = linelookup(p->bpaddr);
57 trname = "trace";
58 stname = "stop";
59 } else {
60 n = p->bpaddr;
61 trname = "tracei";
62 stname = "stopi";
63 }
64 switch(p->bptype) {
65 case INST:
66 printnum(p->bpid);
67 printf("%s %d", trname, n);
68 break;
69
70 case ALL_ON:
71 printnum(p->bpid);
72 printf("%s", trname);
73 s = p->bpblock;
74 if (s != program) {
75 printf(" in ");
76 printname(s);
77 }
78 break;
79
80 case STOP_ON:
81 printnum(p->bpid);
82 printf("%s", stname);
83 if (t != NIL) {
84 printf(" ");
85 prtree(t);
86 }
87 s = p->bpblock;
88 if (s != program) {
89 printf(" in ");
90 printname(s);
91 }
92 break;
93
94 case BLOCK_ON:
95 case TERM_ON:
96 s = p->bpblock;
97 printnum(p->bpid);
98 printf("%s ", trname);
99 prtree(t);
100 if (s != program) {
101 printf(" in ");
102 printname(s);
103 }
104 break;
105
106 case AT_BP:
107 printnum(p->bpid);
108 printf("%s ", trname);
109 prtree(t);
110 printf(" at %d", p->bpline);
111 break;
112
113 case STOP_BP:
114 printnum(p->bpid);
115 printf("%s", stname);
116 if (t != NIL) {
117 printf(" ");
118 prtree(t);
119 } else if ((s = p->bpblock) != NIL) {
120 printf(" in ");
121 printname(s);
122 } else if (p->bpline > 0) {
123 printf(" at %d", p->bpline);
124 } else {
125 printf(" at %d", p->bpaddr);
126 }
127 break;
128
129 /*
130 * Temporary breakpoints;
131 * return rather than break to avoid printing newline.
132 */
133 case ALL_OFF:
134 case CALL:
135 case RETURN:
136 case CALLPROC:
137 case STOP_OFF:
138 case BLOCK_OFF:
139 case TERM_OFF:
140 case END_BP:
141 return;
142
143 default:
144 panic("bptype %d in bplist", p->bptype);
145 }
146 if (p->bpcond != NIL) {
147 printf(" if ");
148 prtree(p->bpcond);
149 }
150 printf("\n");
151}
152
153/*
154 * Print the name of a symbol unambigously.
155 */
156
157LOCAL printname(s)
158SYM *s;
159{
160 if (isambiguous(s)) {
161 printwhich(s);
162 } else {
163 printf("%s", name(s));
164 }
165}