Annotation of cci/usr/src/ucb/gprof/gprof.h, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.