mods to FCALL protocol
[unix-history] / usr / src / usr.bin / pascal / pxp / 0.h
CommitLineData
5912a8dc
PK
1/* static char *sccsid = "@(#)0.h 1.1 (Berkeley) %G%";*/
2/* Copyright (c) 1979 Regents of the University of California */
3/* #define DEBUG */
4#define CHAR
5#define STATIC
6/*
7 * pxp - Pascal execution profiler
8 *
9 * Bill Joy
10 * University of California, Berkeley (UCB)
11 * Version 1.1 February 1978
12 */
13
14/*
15 * Option flags
16 *
17 * The following options are recognized on the command line by pxp.
18 * Only the u, w, and z options here have effect in comments in the
19 * program; the others are command line only, and unrelated
20 * to the options with the same designations in comments.
21 *
22 * a Print all routines in a profile; normally, routines
23 * which have never been executed have their bodies suppressed.
24 *
25 * c Extract profile data from the file core, or the file
26 * named after the last argument rather than the file 'pmon.out'.
27 * Must be used with z to have an effect.
28 *
29 * d Suppress declarations
30 *
31 * f Fully parenthesize expressions.
32 *
33 * j Left justify all procedures and functions rather than
34 * indenting them.
35 *
36 * n Eject a new page in the listing as each 'include' file
37 * is incorporated into the profile.
38 *
39 * o Put output prettyprint in first argument file
40 *
41 * p Pretty print a main program without processing
42 * the include statements.
43 *
44 * t Print a table summarizing procedure and function call counts.
45 *
46 * u Card image mode; only the first 72 chars on a line count.
47 *
48 * w Suppress certain warning diagnostics.
49 *
50 * z Generate an execution profile of the program.
51 * May also be followed by a list of procedure and function
52 * names mixed, if desired, with include file names.
53 * Only these procedures and functions, and the contents
54 * of the specified include files will then be profiled.
55 *
56 * [23456789] Use the specified number of spaces for the basic
57 * indenting unit in the program.
58 *
59 * _ Underline keywords in the output.
60 */
61
62char all, core, nodecl, full, justify, pmain, stripcomm, table, underline;
63char profile, onefile;
64char *firstname, *stdoutn;
65#ifdef DEBUG
66char fulltrace, errtrace, testtrace, yyunique, typetest;
67#endif
68int unit;
69
70/*
71 * The flag nojunk means that header lines
72 * of procedures and functions are to be suppressed
73 * when the z option is off.
74 * It is the default when command line z option
75 * control is specified.
76 *
77 * The flag noinclude indicates that include statements are not
78 * to be processed since we are pretty-printing the contents
79 * of a single file.
80 *
81 * The flag bracket indicates that the source code should be
82 * bracketed with lines of the form
83 * program x(output);
84 * and
85 * begin end.
86 * so that an include will pretty print without syntax errors.
87 */
88char nojunk, noinclude, bracket;
89
90/*
91 * IMPORTANT NOTE
92 *
93 * Many of the following globals are shared by pi and pxp.
94 * For more discussion of these see the available documentation
95 * on the structure of pi.
96 */
97
98/*
99 * Each option has a stack of 17 option values, with opts giving
100 * the current, top value, and optstk the value beneath it.
101 * One refers to option `l' as, e.g., opt('l') in the text for clarity.
102 */
103char opts[26];
104int optstk[26];
105
106#define opt(c) opts[c-'a']
107\f
108/*
109 * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
110 *
111 * Pxp uses expandable tables for its string table
112 * hash table, and parse tree space. The following
113 * definitions specify the size of the increments
114 * for these items in fundamental units so that
115 * each uses approximately 1024 bytes.
116 */
117
118#define STRINC 1024 /* string space increment */
119#define TRINC 512 /* tree space increment */
120#define HASHINC 509 /* hash table size in words, each increment */
121
122/*
123 * The initial sizes of the structures.
124 * These should be large enough to profile
125 * an "average" sized program so as to minimize
126 * storage requests.
127 * On a small system or and 11/34 or 11/40
128 * these numbers can be trimmed to make the
129 * profiler smaller.
130 */
131#define ITREE 2000
132#define IHASH 509
133
134/*
135 * The following limits on hash and tree tables currently
136 * allow approximately 1200 symbols and 20k words of tree
137 * space. The fundamental limit of 64k total data space
138 * should be exceeded well before these are full.
139 */
140#define MAXHASH 4
141#define MAXTREE 30
142#define MAXDEPTH 150
143\f
144/*
145 * ERROR RELATED DEFINITIONS
146 */
147
148/*
149 * Exit statuses to pexit
150 *
151 * AOK
152 * ERRS Compilation errors inhibit obj productin
153 * NOSTART Errors before we ever got started
154 * DIED We ran out of memory or some such
155 */
156#define AOK 0
157#define ERRS 1
158#define NOSTART 2
159#define DIED 3
160
161char Recovery;
162/*
163 * The flag eflg is set whenever we have a hard error.
164 * The character in errpfx will precede the next error message.
165 */
166int eflg;
167char errpfx;
168
169#define setpfx(x) errpfx = x
170
171#define standard() setpfx('s')
172#define warning() setpfx('w')
173#define recovered() setpfx('e')
174#define quit() setpfx('Q')
175\f
176/*
177 * SEMANTIC DEFINITIONS
178 */
179
180#define NIL 0
181
182/*
183 * NOCON and SAWCON are flags in the tree telling whether
184 * a constant set is part of an expression.
185 */
186#define NOCON 0
187#define SAWCON 1
188
189/*
190 * The variable cbn gives the current block number.
191 * The variable lastbn gives the block number before
192 * it last changed and is used to know that we were
193 * in a nested procedure so that we can print
194 * begin { solve }
195 * when solve has nested procedures or functions in it.
196 */
197int cbn, lastbn;
198
199/*
200 * The variable line is the current semantic
201 * line and is set in stat.c from the numbers
202 * embedded in statement type tree nodes.
203 */
204int line;
205
206/*
207 * The size of the display
208 * which defines the maximum nesting
209 * of procedures and functions allowed.
210 */
211#define DSPLYSZ 20
212\f
213/*
214 * Routines which need types
215 * other than "integer" to be
216 * assumed by the compiler.
217 */
218int *tree();
219int *hash();
220char *alloc();
221long cntof();
222long nowcnt();
223
224/*
225 * Funny structures to use
226 * pointers in wild and wooly ways
227 */
228struct {
229 char pchar;
230};
231struct {
232 int pint;
233 int pint2;
234};
235struct {
236 long plong;
237};
238struct {
239 double pdouble;
240};
241
242#define OCT 1
243#define HEX 2
244\f
245/*
246 * MAIN PROGRAM GLOBALS, MISCELLANY
247 */
248
249/*
250 * Variables forming a data base referencing
251 * the command line arguments with the "z" option.
252 */
253char **pflist;
254int pflstc;
255int pfcnt;
256
257char *filename; /* current source file name */
258char *lastname; /* last file name printed */
259long tvec; /* mod time of the source file */
260long ptvec; /* time profiled */
261char printed; /* current file has been printed */
262char hadsome; /* had some output */
263\f
264/*
265 * PROFILING AND FORMATTING DEFINITIONS
266 */
267
268/*
269 * The basic counter information recording structure.
270 * This is global only because people outside
271 * the cluster in pmon.c need to know its size.
272 */
273struct pxcnt {
274 long ntimes; /* the count this structure is all about */
275 int counter; /* a unique counter number for us */
276 int gos; /* global goto count when we hatched */
277 int printed; /* are we considered to have been printed? */
278} pfcnts[DSPLYSZ];
279
280/*
281 * The pieces we divide the output line indents into:
282 * line# PRFN label: STAT 999.---| DECL text
283 */
284#define STAT 0
285#define DECL 1
286#define PRFN 2
287
288/*
289 * Gocnt records the total number of goto's and
290 * cnts records the current counter for generating
291 * COUNT operators.
292 */
293int gocnt;
294int cnts;
295
296#include <stdio.h>
297
298#undef putchar