xref: /csrg-svn/usr.bin/pascal/pxp/0.h (revision 47061)
122247Sdist /*
222247Sdist  * Copyright (c) 1980 Regents of the University of California.
322247Sdist  * All rights reserved.  The Berkeley software License Agreement
422247Sdist  * specifies the terms and conditions for redistribution.
522247Sdist  *
6*47061Sdonn  *	@(#)0.h	5.2 (Berkeley) 03/07/91
722247Sdist  */
822247Sdist 
92847Speter /* #define DEBUG */
102847Speter #define	CHAR
112847Speter #define	STATIC
122847Speter /*
132847Speter  * pxp - Pascal execution profiler
142847Speter  *
152847Speter  * Bill Joy
162847Speter  * University of California, Berkeley (UCB)
172847Speter  * Version 1.1 February 1978
182847Speter  */
192847Speter 
202847Speter /*
212847Speter  * Option flags
222847Speter  *
232847Speter  * The following options are recognized on the command line by pxp.
242847Speter  * Only the u, w, and z options here have effect in comments in the
252847Speter  * program; the others are command line only, and unrelated
262847Speter  * to the options with the same designations in comments.
272847Speter  *
282847Speter  *	a	Print all routines in a profile; normally, routines
292847Speter  *		which have never been executed have their bodies suppressed.
302847Speter  *
312847Speter  *	c	Extract profile data from the file core, or the file
322847Speter  *		named after the last argument rather than the file 'pmon.out'.
332847Speter  *		Must be used with z to have an effect.
342847Speter  *
352847Speter  *	d	Suppress declarations
362847Speter  *
372847Speter  *	f	Fully parenthesize expressions.
382847Speter  *
392847Speter  *	j	Left justify all procedures and functions rather than
402847Speter  *		indenting them.
412847Speter  *
422847Speter  *	n	Eject a new page in the listing as each 'include' file
432847Speter  *		is incorporated into the profile.
442847Speter  *
452847Speter  *	o	Put output prettyprint in first argument file
462847Speter  *
472847Speter  *	p	Pretty print a main program without processing
482847Speter  *		the include statements.
492847Speter  *
502847Speter  *	t	Print a table summarizing procedure and function call counts.
512847Speter  *
522847Speter  *	u	Card image mode; only the first 72 chars on a line count.
532847Speter  *
542847Speter  *	w	Suppress certain warning diagnostics.
552847Speter  *
562847Speter  *	z	Generate an execution profile of the program.
572847Speter  *		May also be followed by a list of procedure and function
582847Speter  *		names mixed, if desired, with include file names.
592847Speter  *		Only these procedures and functions, and the contents
602847Speter  *		of the specified include files will then be profiled.
612847Speter  *
622847Speter  *  [23456789]	Use the specified number of spaces for the basic
632847Speter  *		indenting unit in the program.
642847Speter  *
652847Speter  *	_	Underline keywords in the output.
6612412Speter  *
6712412Speter  *	O	remove `others'.  if an `others' label is found in a
6812412Speter  *		case statement the case statement (minus the others case)
6912412Speter  *		is printed as a guarded case statement, and the others case
7012412Speter  *		is the else branch of the guard.  this transformation
7112412Speter  *		causes the case selector to be evaluated twice, a lose
7212412Speter  *		if the selector has side-effects.  this option is only
7312412Speter  *		available if pxp is compiled with RMOTHERS defined.
742847Speter  */
752847Speter 
762847Speter char	all, core, nodecl, full, justify, pmain, stripcomm, table, underline;
772847Speter char	profile, onefile;
7812412Speter #ifdef RMOTHERS
7912412Speter char	rmothers;
8012412Speter #endif RMOTHERS
81*47061Sdonn char	*firstname, stdoutn[];
822847Speter #ifdef DEBUG
832847Speter char	fulltrace, errtrace, testtrace, yyunique, typetest;
842847Speter #endif
852847Speter int	unit;
862847Speter 
872847Speter /*
882847Speter  * The flag nojunk means that header lines
892847Speter  * of procedures and functions are to be suppressed
902847Speter  * when the z option is off.
912847Speter  * It is the default when command line z option
922847Speter  * control is specified.
932847Speter  *
942847Speter  * The flag noinclude indicates that include statements are not
952847Speter  * to be processed since we are pretty-printing the contents
962847Speter  * of a single file.
972847Speter  *
982847Speter  * The flag bracket indicates that the source code should be
992847Speter  * bracketed with lines of the form
1002847Speter  *	program x(output);
1012847Speter  * and
1022847Speter  *	begin end.
1032847Speter  * so that an include will pretty print without syntax errors.
1042847Speter  */
1052847Speter char	nojunk, noinclude, bracket;
1062847Speter 
1072847Speter /*
1082847Speter  * IMPORTANT NOTE
1092847Speter  *
1102847Speter  * Many of the following globals are shared by pi and pxp.
1112847Speter  * For more discussion of these see the available documentation
1122847Speter  * on the structure of pi.
1132847Speter  */
1142847Speter 
1152847Speter /*
1162847Speter  * Each option has a stack of 17 option values, with opts giving
1172847Speter  * the current, top value, and optstk the value beneath it.
1182847Speter  * One refers to option `l' as, e.g., opt('l') in the text for clarity.
1192847Speter  */
1202847Speter char	opts[26];
1212847Speter int	optstk[26];
1222847Speter 
1232847Speter #define opt(c) opts[c-'a']
1242847Speter 
1252847Speter /*
1262847Speter  * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES
1272847Speter  *
1282847Speter  * Pxp uses expandable tables for its string table
1292847Speter  * hash table, and parse tree space.  The following
1302847Speter  * definitions specify the size of the increments
1312847Speter  * for these items in fundamental units so that
1322847Speter  * each uses approximately 1024 bytes.
1332847Speter  */
1342847Speter 
1352847Speter #define	STRINC	1024		/* string space increment */
13620194Smckusick #define	TRINC	1024		/* tree space increment */
1372847Speter #define	HASHINC	509		/* hash table size in words, each increment */
1382847Speter 
1392847Speter /*
1402847Speter  * The initial sizes of the structures.
1412847Speter  * These should be large enough to profile
1422847Speter  * an "average" sized program so as to minimize
1432847Speter  * storage requests.
1442847Speter  * On a small system or and 11/34 or 11/40
1452847Speter  * these numbers can be trimmed to make the
1462847Speter  * profiler smaller.
1472847Speter  */
1482847Speter #define	ITREE	2000
1492847Speter #define	IHASH	509
1502847Speter 
1512847Speter /*
1522847Speter  * The following limits on hash and tree tables currently
1532847Speter  * allow approximately 1200 symbols and 20k words of tree
1542847Speter  * space.  The fundamental limit of 64k total data space
1552847Speter  * should be exceeded well before these are full.
1562847Speter  */
15712853Speter /*
15812853Speter  * TABLE_MULTIPLIER is for uniformly increasing the sizes of the tables
15912853Speter  */
16012853Speter #ifdef ADDR32
16112853Speter #define TABLE_MULTIPLIER	8
16212853Speter #endif ADDR32
16312853Speter #ifdef ADDR16
16412853Speter #define TABLE_MULTIPLIER	1
16512853Speter #endif ADDR16
16612853Speter #define	MAXHASH	(4 * TABLE_MULTIPLIER)
16720194Smckusick #define	MAXTREE	(40 * TABLE_MULTIPLIER)
16812853Speter /*
16912853Speter  * MAXDEPTH is the depth of the parse stack.
17012853Speter  * STACK_MULTIPLIER is for increasing its size.
17112853Speter  */
17212853Speter #ifdef ADDR32
17312853Speter #define	STACK_MULTIPLIER	8
17412853Speter #endif ADDR32
17512853Speter #ifdef ADDR16
17612853Speter #define	STACK_MULTIPLIER	1
17712853Speter #endif ADDR16
17812853Speter #define	MAXDEPTH ( 150 * STACK_MULTIPLIER )
1792847Speter 
1802847Speter /*
1812847Speter  * ERROR RELATED DEFINITIONS
1822847Speter  */
1832847Speter 
1842847Speter /*
1852847Speter  * Exit statuses to pexit
1862847Speter  *
1872847Speter  * AOK
1882847Speter  * ERRS		Compilation errors inhibit obj productin
1892847Speter  * NOSTART	Errors before we ever got started
1902847Speter  * DIED		We ran out of memory or some such
1912847Speter  */
1922847Speter #define	AOK	0
1932847Speter #define	ERRS	1
1942847Speter #define	NOSTART	2
1952847Speter #define	DIED	3
1962847Speter 
1972847Speter char	Recovery;
1982847Speter /*
1992847Speter  * The flag eflg is set whenever we have a hard error.
2002847Speter  * The character in errpfx will precede the next error message.
2012847Speter  */
2022847Speter int	eflg;
2032847Speter char	errpfx;
2042847Speter 
2052847Speter #define	setpfx(x)	errpfx = x
2062847Speter 
2072847Speter #define	standard()	setpfx('s')
2082847Speter #define	warning()	setpfx('w')
2092847Speter #define	recovered()	setpfx('e')
2102847Speter #define	quit()		setpfx('Q')
21110739Smckusick #define	continuation()	setpfx(' ')
2122847Speter 
2132847Speter /*
2142847Speter  * SEMANTIC DEFINITIONS
2152847Speter  */
2162847Speter 
2172847Speter #define	NIL	0
2182847Speter 
2192847Speter /*
2202847Speter  * NOCON and SAWCON are flags in the tree telling whether
2212847Speter  * a constant set is part of an expression.
2222847Speter  */
2232847Speter #define	NOCON	0
2242847Speter #define	SAWCON	1
2252847Speter 
2262847Speter /*
2272847Speter  * The variable cbn gives the current block number.
2282847Speter  * The variable lastbn gives the block number before
2292847Speter  * it last changed and is used to know that we were
2302847Speter  * in a nested procedure so that we can print
2312847Speter  *	begin { solve }
2322847Speter  * when solve has nested procedures or functions in it.
2332847Speter  */
2342847Speter int	cbn, lastbn;
2352847Speter 
2362847Speter /*
2372847Speter  * The variable line is the current semantic
2382847Speter  * line and is set in stat.c from the numbers
2392847Speter  * embedded in statement type tree nodes.
2402847Speter  */
2412847Speter int	line;
2422847Speter 
2432847Speter /*
2442847Speter  * The size of the display
2452847Speter  * which defines the maximum nesting
2462847Speter  * of procedures and functions allowed.
2472847Speter  */
2482847Speter #define	DSPLYSZ 20
2492847Speter 
2502847Speter /*
2512847Speter  * Routines which need types
2522847Speter  * other than "integer" to be
2532847Speter  * assumed by the compiler.
2542847Speter  */
25517686Smckusick struct tnode	*tree();
25617686Smckusick char		*skipbl();
2572847Speter int	*hash();
2582847Speter char	*alloc();
2592847Speter long	cntof();
2602847Speter long	nowcnt();
2612847Speter 
2622847Speter /*
26317686Smckusick  *	type cast nils to keep lint happy.
26417686Smckusick  */
26517686Smckusick #define	TR_NIL	((struct tnode *) NIL)
26617686Smckusick 
26717686Smckusick /*
2682847Speter  * Funny structures to use
2692847Speter  * pointers in wild and wooly ways
2702847Speter  */
27117686Smckusick struct cstruct {
2722847Speter 	char	pchar;
2732847Speter };
2742847Speter struct {
2752847Speter 	int	pint;
2762847Speter 	int	pint2;
2772847Speter };
2782847Speter struct {
2792847Speter 	long	plong;
2802847Speter };
2812847Speter struct {
2822847Speter 	double	pdouble;
2832847Speter };
2842847Speter 
2852847Speter #define	OCT	1
2862847Speter #define	HEX	2
2872847Speter 
2882847Speter /*
2892847Speter  * MAIN PROGRAM GLOBALS, MISCELLANY
2902847Speter  */
2912847Speter 
2922847Speter /*
2932847Speter  * Variables forming a data base referencing
2942847Speter  * the command line arguments with the "z" option.
2952847Speter  */
2962847Speter char	**pflist;
2972847Speter int	pflstc;
2982847Speter int	pfcnt;
2992847Speter 
3002847Speter char	*filename;		/* current source file name */
3012847Speter char	*lastname;		/* last file name printed */
3022847Speter long	tvec;			/* mod time of the source file */
3032847Speter long	ptvec;			/* time profiled */
3042847Speter char	printed;		/* current file has been printed */
3052847Speter char	hadsome;		/* had some output */
3062847Speter 
3072847Speter /*
3082847Speter  * PROFILING AND FORMATTING DEFINITIONS
3092847Speter  */
3102847Speter 
3112847Speter /*
3122847Speter  * The basic counter information recording structure.
3132847Speter  * This is global only because people outside
3142847Speter  * the cluster in pmon.c need to know its size.
3152847Speter  */
3162847Speter struct pxcnt {
3172847Speter 	long	ntimes;		/* the count this structure is all about */
3182847Speter 	int	counter;	/* a unique counter number for us */
3192847Speter 	int	gos;		/* global goto count when we hatched */
3202847Speter 	int	printed;	/* are we considered to have been printed? */
3212847Speter } pfcnts[DSPLYSZ];
3222847Speter 
3232847Speter /*
3242847Speter  * The pieces we divide the output line indents into:
3252847Speter  *	line#  PRFN  label:   STAT  999.---|  DECL   text
3262847Speter  */
3272847Speter #define	STAT	0
3282847Speter #define	DECL	1
3292847Speter #define	PRFN	2
3302847Speter 
3312847Speter /*
3322847Speter  * Gocnt records the total number of goto's and
3332847Speter  * cnts records the current counter for generating
3342847Speter  * COUNT operators.
3352847Speter  */
3362847Speter int	gocnt;
3372847Speter int	cnts;
3382847Speter 
3392847Speter #include <stdio.h>
340*47061Sdonn #include <string.h>
34117686Smckusick #include <sys/types.h>
3422847Speter 
34310737Smckusick typedef enum {FALSE, TRUE} bool;
34410737Smckusick 
3452847Speter #undef putchar
346