Annotation of 43BSDTahoe/ucb/gprof/gprof.h, revision 1.1.1.1

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