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