|
|
1.1 root 1: /* static char *sccsid = "@(#)0.h 1.5 (Berkeley) 5/31/83";*/
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: * O remove `others'. if an `others' label is found in a
62: * case statement the case statement (minus the others case)
63: * is printed as a guarded case statement, and the others case
64: * is the else branch of the guard. this transformation
65: * causes the case selector to be evaluated twice, a lose
66: * if the selector has side-effects. this option is only
67: * available if pxp is compiled with RMOTHERS defined.
68: */
69:
70: char all, core, nodecl, full, justify, pmain, stripcomm, table, underline;
71: char profile, onefile;
72: #ifdef RMOTHERS
73: char rmothers;
74: #endif RMOTHERS
75: char *firstname, *stdoutn;
76: #ifdef DEBUG
77: char fulltrace, errtrace, testtrace, yyunique, typetest;
78: #endif
79: int unit;
80:
81: /*
82: * The flag nojunk means that header lines
83: * of procedures and functions are to be suppressed
84: * when the z option is off.
85: * It is the default when command line z option
86: * control is specified.
87: *
88: * The flag noinclude indicates that include statements are not
89: * to be processed since we are pretty-printing the contents
90: * of a single file.
91: *
92: * The flag bracket indicates that the source code should be
93: * bracketed with lines of the form
94: * program x(output);
95: * and
96: * begin end.
97: * so that an include will pretty print without syntax errors.
98: */
99: char nojunk, noinclude, bracket;
100:
101: /*
102: * IMPORTANT NOTE
103: *
104: * Many of the following globals are shared by pi and pxp.
105: * For more discussion of these see the available documentation
106: * on the structure of pi.
107: */
108:
109: /*
110: * Each option has a stack of 17 option values, with opts giving
111: * the current, top value, and optstk the value beneath it.
112: * One refers to option `l' as, e.g., opt('l') in the text for clarity.
113: */
114: char opts[26];
115: int optstk[26];
116:
117: #define opt(c) opts[c-'a']
118:
119: /*
120: * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
121: *
122: * Pxp uses expandable tables for its string table
123: * hash table, and parse tree space. The following
124: * definitions specify the size of the increments
125: * for these items in fundamental units so that
126: * each uses approximately 1024 bytes.
127: */
128:
129: #define STRINC 1024 /* string space increment */
130: #define TRINC 512 /* tree space increment */
131: #define HASHINC 509 /* hash table size in words, each increment */
132:
133: /*
134: * The initial sizes of the structures.
135: * These should be large enough to profile
136: * an "average" sized program so as to minimize
137: * storage requests.
138: * On a small system or and 11/34 or 11/40
139: * these numbers can be trimmed to make the
140: * profiler smaller.
141: */
142: #define ITREE 2000
143: #define IHASH 509
144:
145: /*
146: * The following limits on hash and tree tables currently
147: * allow approximately 1200 symbols and 20k words of tree
148: * space. The fundamental limit of 64k total data space
149: * should be exceeded well before these are full.
150: */
151: /*
152: * TABLE_MULTIPLIER is for uniformly increasing the sizes of the tables
153: */
154: #ifdef ADDR32
155: #define TABLE_MULTIPLIER 8
156: #endif ADDR32
157: #ifdef ADDR16
158: #define TABLE_MULTIPLIER 1
159: #endif ADDR16
160: #define MAXHASH (4 * TABLE_MULTIPLIER)
161: #define MAXTREE (30 * TABLE_MULTIPLIER)
162: /*
163: * MAXDEPTH is the depth of the parse stack.
164: * STACK_MULTIPLIER is for increasing its size.
165: */
166: #ifdef ADDR32
167: #define STACK_MULTIPLIER 8
168: #endif ADDR32
169: #ifdef ADDR16
170: #define STACK_MULTIPLIER 1
171: #endif ADDR16
172: #define MAXDEPTH ( 150 * STACK_MULTIPLIER )
173:
174: /*
175: * ERROR RELATED DEFINITIONS
176: */
177:
178: /*
179: * Exit statuses to pexit
180: *
181: * AOK
182: * ERRS Compilation errors inhibit obj productin
183: * NOSTART Errors before we ever got started
184: * DIED We ran out of memory or some such
185: */
186: #define AOK 0
187: #define ERRS 1
188: #define NOSTART 2
189: #define DIED 3
190:
191: char Recovery;
192: /*
193: * The flag eflg is set whenever we have a hard error.
194: * The character in errpfx will precede the next error message.
195: */
196: int eflg;
197: char errpfx;
198:
199: #define setpfx(x) errpfx = x
200:
201: #define standard() setpfx('s')
202: #define warning() setpfx('w')
203: #define recovered() setpfx('e')
204: #define quit() setpfx('Q')
205: #define continuation() setpfx(' ')
206:
207: /*
208: * SEMANTIC DEFINITIONS
209: */
210:
211: #define NIL 0
212:
213: /*
214: * NOCON and SAWCON are flags in the tree telling whether
215: * a constant set is part of an expression.
216: */
217: #define NOCON 0
218: #define SAWCON 1
219:
220: /*
221: * The variable cbn gives the current block number.
222: * The variable lastbn gives the block number before
223: * it last changed and is used to know that we were
224: * in a nested procedure so that we can print
225: * begin { solve }
226: * when solve has nested procedures or functions in it.
227: */
228: int cbn, lastbn;
229:
230: /*
231: * The variable line is the current semantic
232: * line and is set in stat.c from the numbers
233: * embedded in statement type tree nodes.
234: */
235: int line;
236:
237: /*
238: * The size of the display
239: * which defines the maximum nesting
240: * of procedures and functions allowed.
241: */
242: #define DSPLYSZ 20
243:
244: /*
245: * Routines which need types
246: * other than "integer" to be
247: * assumed by the compiler.
248: */
249: int *tree();
250: int *hash();
251: char *alloc();
252: long cntof();
253: long nowcnt();
254:
255: /*
256: * Funny structures to use
257: * pointers in wild and wooly ways
258: */
259: struct {
260: char pchar;
261: };
262: struct {
263: int pint;
264: int pint2;
265: };
266: struct {
267: long plong;
268: };
269: struct {
270: double pdouble;
271: };
272:
273: #define OCT 1
274: #define HEX 2
275:
276: /*
277: * MAIN PROGRAM GLOBALS, MISCELLANY
278: */
279:
280: /*
281: * Variables forming a data base referencing
282: * the command line arguments with the "z" option.
283: */
284: char **pflist;
285: int pflstc;
286: int pfcnt;
287:
288: char *filename; /* current source file name */
289: char *lastname; /* last file name printed */
290: long tvec; /* mod time of the source file */
291: long ptvec; /* time profiled */
292: char printed; /* current file has been printed */
293: char hadsome; /* had some output */
294:
295: /*
296: * PROFILING AND FORMATTING DEFINITIONS
297: */
298:
299: /*
300: * The basic counter information recording structure.
301: * This is global only because people outside
302: * the cluster in pmon.c need to know its size.
303: */
304: struct pxcnt {
305: long ntimes; /* the count this structure is all about */
306: int counter; /* a unique counter number for us */
307: int gos; /* global goto count when we hatched */
308: int printed; /* are we considered to have been printed? */
309: } pfcnts[DSPLYSZ];
310:
311: /*
312: * The pieces we divide the output line indents into:
313: * line# PRFN label: STAT 999.---| DECL text
314: */
315: #define STAT 0
316: #define DECL 1
317: #define PRFN 2
318:
319: /*
320: * Gocnt records the total number of goto's and
321: * cnts records the current counter for generating
322: * COUNT operators.
323: */
324: int gocnt;
325: int cnts;
326:
327: #include <stdio.h>
328:
329: typedef enum {FALSE, TRUE} bool;
330:
331: #undef putchar
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.