1*10737Smckusick /* static char *sccsid = "@(#)0.h 1.2 (Berkeley) 02/05/83";*/ 22847Speter /* Copyright (c) 1979 Regents of the University of California */ 32847Speter /* #define DEBUG */ 42847Speter #define CHAR 52847Speter #define STATIC 62847Speter /* 72847Speter * pxp - Pascal execution profiler 82847Speter * 92847Speter * Bill Joy 102847Speter * University of California, Berkeley (UCB) 112847Speter * Version 1.1 February 1978 122847Speter */ 132847Speter 142847Speter /* 152847Speter * Option flags 162847Speter * 172847Speter * The following options are recognized on the command line by pxp. 182847Speter * Only the u, w, and z options here have effect in comments in the 192847Speter * program; the others are command line only, and unrelated 202847Speter * to the options with the same designations in comments. 212847Speter * 222847Speter * a Print all routines in a profile; normally, routines 232847Speter * which have never been executed have their bodies suppressed. 242847Speter * 252847Speter * c Extract profile data from the file core, or the file 262847Speter * named after the last argument rather than the file 'pmon.out'. 272847Speter * Must be used with z to have an effect. 282847Speter * 292847Speter * d Suppress declarations 302847Speter * 312847Speter * f Fully parenthesize expressions. 322847Speter * 332847Speter * j Left justify all procedures and functions rather than 342847Speter * indenting them. 352847Speter * 362847Speter * n Eject a new page in the listing as each 'include' file 372847Speter * is incorporated into the profile. 382847Speter * 392847Speter * o Put output prettyprint in first argument file 402847Speter * 412847Speter * p Pretty print a main program without processing 422847Speter * the include statements. 432847Speter * 442847Speter * t Print a table summarizing procedure and function call counts. 452847Speter * 462847Speter * u Card image mode; only the first 72 chars on a line count. 472847Speter * 482847Speter * w Suppress certain warning diagnostics. 492847Speter * 502847Speter * z Generate an execution profile of the program. 512847Speter * May also be followed by a list of procedure and function 522847Speter * names mixed, if desired, with include file names. 532847Speter * Only these procedures and functions, and the contents 542847Speter * of the specified include files will then be profiled. 552847Speter * 562847Speter * [23456789] Use the specified number of spaces for the basic 572847Speter * indenting unit in the program. 582847Speter * 592847Speter * _ Underline keywords in the output. 602847Speter */ 612847Speter 622847Speter char all, core, nodecl, full, justify, pmain, stripcomm, table, underline; 632847Speter char profile, onefile; 642847Speter char *firstname, *stdoutn; 652847Speter #ifdef DEBUG 662847Speter char fulltrace, errtrace, testtrace, yyunique, typetest; 672847Speter #endif 682847Speter int unit; 692847Speter 702847Speter /* 712847Speter * The flag nojunk means that header lines 722847Speter * of procedures and functions are to be suppressed 732847Speter * when the z option is off. 742847Speter * It is the default when command line z option 752847Speter * control is specified. 762847Speter * 772847Speter * The flag noinclude indicates that include statements are not 782847Speter * to be processed since we are pretty-printing the contents 792847Speter * of a single file. 802847Speter * 812847Speter * The flag bracket indicates that the source code should be 822847Speter * bracketed with lines of the form 832847Speter * program x(output); 842847Speter * and 852847Speter * begin end. 862847Speter * so that an include will pretty print without syntax errors. 872847Speter */ 882847Speter char nojunk, noinclude, bracket; 892847Speter 902847Speter /* 912847Speter * IMPORTANT NOTE 922847Speter * 932847Speter * Many of the following globals are shared by pi and pxp. 942847Speter * For more discussion of these see the available documentation 952847Speter * on the structure of pi. 962847Speter */ 972847Speter 982847Speter /* 992847Speter * Each option has a stack of 17 option values, with opts giving 1002847Speter * the current, top value, and optstk the value beneath it. 1012847Speter * One refers to option `l' as, e.g., opt('l') in the text for clarity. 1022847Speter */ 1032847Speter char opts[26]; 1042847Speter int optstk[26]; 1052847Speter 1062847Speter #define opt(c) opts[c-'a'] 1072847Speter 1082847Speter /* 1092847Speter * NOTES ON THE DYNAMIC NATURE OF THE DATA STRUCTURES 1102847Speter * 1112847Speter * Pxp uses expandable tables for its string table 1122847Speter * hash table, and parse tree space. The following 1132847Speter * definitions specify the size of the increments 1142847Speter * for these items in fundamental units so that 1152847Speter * each uses approximately 1024 bytes. 1162847Speter */ 1172847Speter 1182847Speter #define STRINC 1024 /* string space increment */ 1192847Speter #define TRINC 512 /* tree space increment */ 1202847Speter #define HASHINC 509 /* hash table size in words, each increment */ 1212847Speter 1222847Speter /* 1232847Speter * The initial sizes of the structures. 1242847Speter * These should be large enough to profile 1252847Speter * an "average" sized program so as to minimize 1262847Speter * storage requests. 1272847Speter * On a small system or and 11/34 or 11/40 1282847Speter * these numbers can be trimmed to make the 1292847Speter * profiler smaller. 1302847Speter */ 1312847Speter #define ITREE 2000 1322847Speter #define IHASH 509 1332847Speter 1342847Speter /* 1352847Speter * The following limits on hash and tree tables currently 1362847Speter * allow approximately 1200 symbols and 20k words of tree 1372847Speter * space. The fundamental limit of 64k total data space 1382847Speter * should be exceeded well before these are full. 1392847Speter */ 1402847Speter #define MAXHASH 4 1412847Speter #define MAXTREE 30 1422847Speter #define MAXDEPTH 150 1432847Speter 1442847Speter /* 1452847Speter * ERROR RELATED DEFINITIONS 1462847Speter */ 1472847Speter 1482847Speter /* 1492847Speter * Exit statuses to pexit 1502847Speter * 1512847Speter * AOK 1522847Speter * ERRS Compilation errors inhibit obj productin 1532847Speter * NOSTART Errors before we ever got started 1542847Speter * DIED We ran out of memory or some such 1552847Speter */ 1562847Speter #define AOK 0 1572847Speter #define ERRS 1 1582847Speter #define NOSTART 2 1592847Speter #define DIED 3 1602847Speter 1612847Speter char Recovery; 1622847Speter /* 1632847Speter * The flag eflg is set whenever we have a hard error. 1642847Speter * The character in errpfx will precede the next error message. 1652847Speter */ 1662847Speter int eflg; 1672847Speter char errpfx; 1682847Speter 1692847Speter #define setpfx(x) errpfx = x 1702847Speter 1712847Speter #define standard() setpfx('s') 1722847Speter #define warning() setpfx('w') 1732847Speter #define recovered() setpfx('e') 1742847Speter #define quit() setpfx('Q') 1752847Speter 1762847Speter /* 1772847Speter * SEMANTIC DEFINITIONS 1782847Speter */ 1792847Speter 1802847Speter #define NIL 0 1812847Speter 1822847Speter /* 1832847Speter * NOCON and SAWCON are flags in the tree telling whether 1842847Speter * a constant set is part of an expression. 1852847Speter */ 1862847Speter #define NOCON 0 1872847Speter #define SAWCON 1 1882847Speter 1892847Speter /* 1902847Speter * The variable cbn gives the current block number. 1912847Speter * The variable lastbn gives the block number before 1922847Speter * it last changed and is used to know that we were 1932847Speter * in a nested procedure so that we can print 1942847Speter * begin { solve } 1952847Speter * when solve has nested procedures or functions in it. 1962847Speter */ 1972847Speter int cbn, lastbn; 1982847Speter 1992847Speter /* 2002847Speter * The variable line is the current semantic 2012847Speter * line and is set in stat.c from the numbers 2022847Speter * embedded in statement type tree nodes. 2032847Speter */ 2042847Speter int line; 2052847Speter 2062847Speter /* 2072847Speter * The size of the display 2082847Speter * which defines the maximum nesting 2092847Speter * of procedures and functions allowed. 2102847Speter */ 2112847Speter #define DSPLYSZ 20 2122847Speter 2132847Speter /* 2142847Speter * Routines which need types 2152847Speter * other than "integer" to be 2162847Speter * assumed by the compiler. 2172847Speter */ 2182847Speter int *tree(); 2192847Speter int *hash(); 2202847Speter char *alloc(); 2212847Speter long cntof(); 2222847Speter long nowcnt(); 2232847Speter 2242847Speter /* 2252847Speter * Funny structures to use 2262847Speter * pointers in wild and wooly ways 2272847Speter */ 2282847Speter struct { 2292847Speter char pchar; 2302847Speter }; 2312847Speter struct { 2322847Speter int pint; 2332847Speter int pint2; 2342847Speter }; 2352847Speter struct { 2362847Speter long plong; 2372847Speter }; 2382847Speter struct { 2392847Speter double pdouble; 2402847Speter }; 2412847Speter 2422847Speter #define OCT 1 2432847Speter #define HEX 2 2442847Speter 2452847Speter /* 2462847Speter * MAIN PROGRAM GLOBALS, MISCELLANY 2472847Speter */ 2482847Speter 2492847Speter /* 2502847Speter * Variables forming a data base referencing 2512847Speter * the command line arguments with the "z" option. 2522847Speter */ 2532847Speter char **pflist; 2542847Speter int pflstc; 2552847Speter int pfcnt; 2562847Speter 2572847Speter char *filename; /* current source file name */ 2582847Speter char *lastname; /* last file name printed */ 2592847Speter long tvec; /* mod time of the source file */ 2602847Speter long ptvec; /* time profiled */ 2612847Speter char printed; /* current file has been printed */ 2622847Speter char hadsome; /* had some output */ 2632847Speter 2642847Speter /* 2652847Speter * PROFILING AND FORMATTING DEFINITIONS 2662847Speter */ 2672847Speter 2682847Speter /* 2692847Speter * The basic counter information recording structure. 2702847Speter * This is global only because people outside 2712847Speter * the cluster in pmon.c need to know its size. 2722847Speter */ 2732847Speter struct pxcnt { 2742847Speter long ntimes; /* the count this structure is all about */ 2752847Speter int counter; /* a unique counter number for us */ 2762847Speter int gos; /* global goto count when we hatched */ 2772847Speter int printed; /* are we considered to have been printed? */ 2782847Speter } pfcnts[DSPLYSZ]; 2792847Speter 2802847Speter /* 2812847Speter * The pieces we divide the output line indents into: 2822847Speter * line# PRFN label: STAT 999.---| DECL text 2832847Speter */ 2842847Speter #define STAT 0 2852847Speter #define DECL 1 2862847Speter #define PRFN 2 2872847Speter 2882847Speter /* 2892847Speter * Gocnt records the total number of goto's and 2902847Speter * cnts records the current counter for generating 2912847Speter * COUNT operators. 2922847Speter */ 2932847Speter int gocnt; 2942847Speter int cnts; 2952847Speter 2962847Speter #include <stdio.h> 2972847Speter 298*10737Smckusick typedef enum {FALSE, TRUE} bool; 299*10737Smckusick 3002847Speter #undef putchar 301