2 * Copyright (c) 1983 Regents of the University of California.
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.
19 * @(#)gprof.h 5.9 (Berkeley) 6/1/90
26 #include <sys/types.h>
47 * who am i, for error messages.
63 typedef u_short UNIT; /* unit of profiling */
65 #define A_OUTNAME "a.out"
68 #define GMONNAME "gmon.out"
69 #define GMONSUM "gmon.sum"
73 * with pointers to the namelist entry of the parent and the child,
74 * a count of how many times this arc was traversed,
75 * and pointers to the next parent of this child and
76 * the next child of this parent.
79 struct nl *arc_parentp; /* pointer to parent's nl entry */
80 struct nl *arc_childp; /* pointer to child's nl entry */
81 long arc_count; /* how calls from parent to child */
82 double arc_time; /* time inherited along arc */
83 double arc_childtime; /* childtime inherited along arc */
84 struct arcstruct *arc_parentlist; /* parents-of-this-child list */
85 struct arcstruct *arc_childlist; /* children-of-this-parent list */
87 typedef struct arcstruct arctype;
91 * for each external in the specified file we gather
92 * its address, the number of calls and compute its share of cpu time.
95 char *name; /* the name */
96 unsigned long value; /* the pc entry point */
97 unsigned long svalue; /* entry point aligned to histograms */
98 double time; /* ticks in this routine */
99 double childtime; /* cumulative ticks in children */
100 long ncall; /* how many times called */
101 long selfcalls; /* how many calls to self */
102 double propfraction; /* what % of time propagates */
103 double propself; /* how much self time propagates */
104 double propchild; /* how much child time propagates */
105 bool printflag; /* should this be printed? */
106 int index; /* index in the graph list */
107 int toporder; /* graph call chain top-sort order */
108 int cycleno; /* internal number of cycle on */
109 struct nl *cyclehead; /* pointer to head of cycle */
110 struct nl *cnext; /* pointer to next member of cycle */
111 arctype *parents; /* list of caller arcs */
112 arctype *children; /* list of callee arcs */
114 typedef struct nl nltype;
116 nltype *nl; /* the whole namelist */
117 nltype *npe; /* the virtual end of the namelist */
118 int nname; /* the number of function names */
121 * flag which marks a nl entry as topologically ``busy''
122 * flag which marks a nl entry as topologically ``not_numbered''
128 * namelist entries for cycle headers.
129 * the number of discovered cycles.
131 nltype *cyclenl; /* cycle header namelist */
132 int ncycle; /* number of cycles discovered */
135 * The header on the gmon.out file.
136 * gmon.out consists of one of these headers,
137 * and then an array of ncnt samples
138 * representing the discretized program counter values.
139 * this should be a struct phdr, but since everything is done
140 * as UNITs, this is in UNITs too.
153 * Each discretized pc sample has
154 * a count of the number of samples in its range
158 unsigned long s_lowpc; /* lowpc from the profile file */
159 unsigned long s_highpc; /* highpc from the profile file */
160 unsigned lowpc, highpc; /* range profiled, in UNIT's */
161 unsigned sampbytes; /* number of bytes of samples */
162 int nsamples; /* number of samples */
163 double actime; /* accumulated time thus far for putprofline */
164 double totime; /* total time for all routines */
165 double printtime; /* total of time being printed */
166 double scale; /* scale factor converting samples to pc
167 values: each sample covers scale bytes */
168 char *strtab; /* string table in core */
169 off_t ssiz; /* size of the string table */
170 unsigned char *textspace; /* text space of a.out in core */
173 * option flags, from a to z.
175 bool aflag; /* suppress static functions */
176 bool bflag; /* blurbs, too */
177 bool cflag; /* discovered call graph, too */
178 bool dflag; /* debugging options */
179 bool eflag; /* specific functions excluded */
180 bool Eflag; /* functions excluded with time */
181 bool fflag; /* specific functions requested */
182 bool Fflag; /* functions requested with time */
183 bool kflag; /* arcs to be deleted */
184 bool sflag; /* sum multiple gmon.out files */
185 bool zflag; /* zero time/called functions, too */
188 * structure for various string lists
191 struct stringlist *next;
194 struct stringlist *elist;
195 struct stringlist *Elist;
196 struct stringlist *flist;
197 struct stringlist *Flist;
198 struct stringlist *kfromlist;
199 struct stringlist *ktolist;
202 * function declarations
208 arctype *arclookup();
258 unsigned long reladdr();
274 #define GREATERTHAN 1
281 #define SAMPLEDEBUG 32
283 #define CALLDEBUG 128
284 #define LOOKUPDEBUG 256
285 #define PROPDEBUG 512
286 #define ANYDEBUG 1024