|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: * ! 19: * @(#)gprof.h 5.9 (Berkeley) 6/1/90 ! 20: */ ! 21: ! 22: #include <sys/types.h> ! 23: #include <sys/stat.h> ! 24: #include <a.out.h> ! 25: #include <stdio.h> ! 26: #include "gmon.h" ! 27: ! 28: #if vax ! 29: # include "vax.h" ! 30: #endif ! 31: #if sun ! 32: # include "sun.h" ! 33: #endif ! 34: #if tahoe ! 35: # include "tahoe.h" ! 36: #endif ! 37: ! 38: ! 39: /* ! 40: * who am i, for error messages. ! 41: */ ! 42: char *whoami; ! 43: ! 44: /* ! 45: * booleans ! 46: */ ! 47: typedef int bool; ! 48: #define FALSE 0 ! 49: #define TRUE 1 ! 50: ! 51: /* ! 52: * ticks per second ! 53: */ ! 54: long hz; ! 55: ! 56: typedef u_short UNIT; /* unit of profiling */ ! 57: char *a_outname; ! 58: #define A_OUTNAME "a.out" ! 59: ! 60: char *gmonname; ! 61: #define GMONNAME "gmon.out" ! 62: #define GMONSUM "gmon.sum" ! 63: ! 64: /* ! 65: * a constructed arc, ! 66: * with pointers to the namelist entry of the parent and the child, ! 67: * a count of how many times this arc was traversed, ! 68: * and pointers to the next parent of this child and ! 69: * the next child of this parent. ! 70: */ ! 71: struct arcstruct { ! 72: struct nl *arc_parentp; /* pointer to parent's nl entry */ ! 73: struct nl *arc_childp; /* pointer to child's nl entry */ ! 74: long arc_count; /* how calls from parent to child */ ! 75: double arc_time; /* time inherited along arc */ ! 76: double arc_childtime; /* childtime inherited along arc */ ! 77: struct arcstruct *arc_parentlist; /* parents-of-this-child list */ ! 78: struct arcstruct *arc_childlist; /* children-of-this-parent list */ ! 79: }; ! 80: typedef struct arcstruct arctype; ! 81: ! 82: /* ! 83: * The symbol table; ! 84: * for each external in the specified file we gather ! 85: * its address, the number of calls and compute its share of cpu time. ! 86: */ ! 87: struct nl { ! 88: char *name; /* the name */ ! 89: unsigned long value; /* the pc entry point */ ! 90: unsigned long svalue; /* entry point aligned to histograms */ ! 91: double time; /* ticks in this routine */ ! 92: double childtime; /* cumulative ticks in children */ ! 93: long ncall; /* how many times called */ ! 94: long selfcalls; /* how many calls to self */ ! 95: double propfraction; /* what % of time propagates */ ! 96: double propself; /* how much self time propagates */ ! 97: double propchild; /* how much child time propagates */ ! 98: bool printflag; /* should this be printed? */ ! 99: int index; /* index in the graph list */ ! 100: int toporder; /* graph call chain top-sort order */ ! 101: int cycleno; /* internal number of cycle on */ ! 102: struct nl *cyclehead; /* pointer to head of cycle */ ! 103: struct nl *cnext; /* pointer to next member of cycle */ ! 104: arctype *parents; /* list of caller arcs */ ! 105: arctype *children; /* list of callee arcs */ ! 106: }; ! 107: typedef struct nl nltype; ! 108: ! 109: nltype *nl; /* the whole namelist */ ! 110: nltype *npe; /* the virtual end of the namelist */ ! 111: int nname; /* the number of function names */ ! 112: ! 113: /* ! 114: * flag which marks a nl entry as topologically ``busy'' ! 115: * flag which marks a nl entry as topologically ``not_numbered'' ! 116: */ ! 117: #define DFN_BUSY -1 ! 118: #define DFN_NAN 0 ! 119: ! 120: /* ! 121: * namelist entries for cycle headers. ! 122: * the number of discovered cycles. ! 123: */ ! 124: nltype *cyclenl; /* cycle header namelist */ ! 125: int ncycle; /* number of cycles discovered */ ! 126: ! 127: /* ! 128: * The header on the gmon.out file. ! 129: * gmon.out consists of one of these headers, ! 130: * and then an array of ncnt samples ! 131: * representing the discretized program counter values. ! 132: * this should be a struct phdr, but since everything is done ! 133: * as UNITs, this is in UNITs too. ! 134: */ ! 135: struct hdr { ! 136: UNIT *lowpc; ! 137: UNIT *highpc; ! 138: int ncnt; ! 139: }; ! 140: ! 141: struct hdr h; ! 142: ! 143: int debug; ! 144: ! 145: /* ! 146: * Each discretized pc sample has ! 147: * a count of the number of samples in its range ! 148: */ ! 149: UNIT *samples; ! 150: ! 151: unsigned long s_lowpc; /* lowpc from the profile file */ ! 152: unsigned long s_highpc; /* highpc from the profile file */ ! 153: unsigned lowpc, highpc; /* range profiled, in UNIT's */ ! 154: unsigned sampbytes; /* number of bytes of samples */ ! 155: int nsamples; /* number of samples */ ! 156: double actime; /* accumulated time thus far for putprofline */ ! 157: double totime; /* total time for all routines */ ! 158: double printtime; /* total of time being printed */ ! 159: double scale; /* scale factor converting samples to pc ! 160: values: each sample covers scale bytes */ ! 161: char *strtab; /* string table in core */ ! 162: off_t ssiz; /* size of the string table */ ! 163: struct exec xbuf; /* exec header of a.out */ ! 164: unsigned char *textspace; /* text space of a.out in core */ ! 165: ! 166: /* ! 167: * option flags, from a to z. ! 168: */ ! 169: bool aflag; /* suppress static functions */ ! 170: bool bflag; /* blurbs, too */ ! 171: bool cflag; /* discovered call graph, too */ ! 172: bool dflag; /* debugging options */ ! 173: bool eflag; /* specific functions excluded */ ! 174: bool Eflag; /* functions excluded with time */ ! 175: bool fflag; /* specific functions requested */ ! 176: bool Fflag; /* functions requested with time */ ! 177: bool kflag; /* arcs to be deleted */ ! 178: bool sflag; /* sum multiple gmon.out files */ ! 179: bool zflag; /* zero time/called functions, too */ ! 180: ! 181: /* ! 182: * structure for various string lists ! 183: */ ! 184: struct stringlist { ! 185: struct stringlist *next; ! 186: char *string; ! 187: }; ! 188: struct stringlist *elist; ! 189: struct stringlist *Elist; ! 190: struct stringlist *flist; ! 191: struct stringlist *Flist; ! 192: struct stringlist *kfromlist; ! 193: struct stringlist *ktolist; ! 194: ! 195: /* ! 196: * function declarations ! 197: */ ! 198: /* ! 199: addarc(); ! 200: */ ! 201: int arccmp(); ! 202: arctype *arclookup(); ! 203: /* ! 204: asgnsamples(); ! 205: printblurb(); ! 206: cyclelink(); ! 207: dfn(); ! 208: */ ! 209: bool dfn_busy(); ! 210: /* ! 211: dfn_findcycle(); ! 212: */ ! 213: bool dfn_numbered(); ! 214: /* ! 215: dfn_post_visit(); ! 216: dfn_pre_visit(); ! 217: dfn_self_cycle(); ! 218: */ ! 219: nltype **doarcs(); ! 220: /* ! 221: done(); ! 222: findcalls(); ! 223: flatprofheader(); ! 224: flatprofline(); ! 225: */ ! 226: bool funcsymbol(); ! 227: /* ! 228: getnfile(); ! 229: getpfile(); ! 230: getstrtab(); ! 231: getsymtab(); ! 232: gettextspace(); ! 233: gprofheader(); ! 234: gprofline(); ! 235: main(); ! 236: */ ! 237: unsigned long max(); ! 238: int membercmp(); ! 239: unsigned long min(); ! 240: nltype *nllookup(); ! 241: FILE *openpfile(); ! 242: long operandlength(); ! 243: operandenum operandmode(); ! 244: char *operandname(); ! 245: /* ! 246: printchildren(); ! 247: printcycle(); ! 248: printgprof(); ! 249: printmembers(); ! 250: printname(); ! 251: printparents(); ! 252: printprof(); ! 253: readsamples(); ! 254: */ ! 255: unsigned long reladdr(); ! 256: /* ! 257: sortchildren(); ! 258: sortmembers(); ! 259: sortparents(); ! 260: tally(); ! 261: timecmp(); ! 262: topcmp(); ! 263: */ ! 264: int totalcmp(); ! 265: /* ! 266: valcmp(); ! 267: */ ! 268: ! 269: #define LESSTHAN -1 ! 270: #define EQUALTO 0 ! 271: #define GREATERTHAN 1 ! 272: ! 273: #define DFNDEBUG 1 ! 274: #define CYCLEDEBUG 2 ! 275: #define ARCDEBUG 4 ! 276: #define TALLYDEBUG 8 ! 277: #define TIMEDEBUG 16 ! 278: #define SAMPLEDEBUG 32 ! 279: #define AOUTDEBUG 64 ! 280: #define CALLDEBUG 128 ! 281: #define LOOKUPDEBUG 256 ! 282: #define PROPDEBUG 512 ! 283: #define ANYDEBUG 1024
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.