2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)gprof.h 8.1 (Berkeley) 6/6/93
36 #include <sys/types.h>
81 typedef u_short UNIT; /* unit of profiling */
84 #define A_OUTNAME "a.out"
87 #define GMONSUM "gmon.sum"
91 * with pointers to the namelist entry of the parent and the child,
92 * a count of how many times this arc was traversed,
93 * and pointers to the next parent of this child and
94 * the next child of this parent.
97 struct nl *arc_parentp; /* pointer to parent's nl entry */
98 struct nl *arc_childp; /* pointer to child's nl entry */
99 long arc_count; /* num calls from parent to child */
100 double arc_time; /* time inherited along arc */
101 double arc_childtime; /* childtime inherited along arc */
102 struct arcstruct *arc_parentlist; /* parents-of-this-child list */
103 struct arcstruct *arc_childlist; /* children-of-this-parent list */
104 struct arcstruct *arc_next; /* list of arcs on cycle */
105 unsigned short arc_cyclecnt; /* num cycles involved in */
106 unsigned short arc_flags; /* see below */
108 typedef struct arcstruct arctype;
113 #define DEADARC 0x01 /* time should not propagate across the arc */
114 #define ONLIST 0x02 /* arc is on list of arcs in cycles */
118 * for each external in the specified file we gather
119 * its address, the number of calls and compute its share of cpu time.
122 const char *name; /* the name */
123 unsigned long value; /* the pc entry point */
124 unsigned long svalue; /* entry point aligned to histograms */
125 double time; /* ticks in this routine */
126 double childtime; /* cumulative ticks in children */
127 long ncall; /* how many times called */
128 long npropcall; /* times called by live arcs */
129 long selfcalls; /* how many calls to self */
130 double propfraction; /* what % of time propagates */
131 double propself; /* how much self time propagates */
132 double propchild; /* how much child time propagates */
133 short printflag; /* should this be printed? */
134 short flags; /* see below */
135 int index; /* index in the graph list */
136 int toporder; /* graph call chain top-sort order */
137 int cycleno; /* internal number of cycle on */
138 int parentcnt; /* number of live parent arcs */
139 struct nl *cyclehead; /* pointer to head of cycle */
140 struct nl *cnext; /* pointer to next member of cycle */
141 arctype *parents; /* list of caller arcs */
142 arctype *children; /* list of callee arcs */
144 typedef struct nl nltype;
146 nltype *nl; /* the whole namelist */
147 nltype *npe; /* the virtual end of the namelist */
148 int nname; /* the number of function names */
150 #define HASCYCLEXIT 0x08 /* node has arc exiting from cycle */
151 #define CYCLEHEAD 0x10 /* node marked as head of a cycle */
152 #define VISITED 0x20 /* node visited during a cycle */
156 * for each subcycle within an identified cycle, we gather
157 * its size and the list of included arcs.
160 int size; /* length of cycle */
161 struct cl *next; /* next member of list */
162 arctype *list[1]; /* list of arcs in cycle */
163 /* actually longer */
165 typedef struct cl cltype;
167 arctype *archead; /* the head of arcs in current cycle list */
168 cltype *cyclehead; /* the head of the list */
169 int cyclecnt; /* the number of cycles found */
170 #define CYCLEMAX 100 /* maximum cycles before cutting one of them */
173 * flag which marks a nl entry as topologically ``busy''
174 * flag which marks a nl entry as topologically ``not_numbered''
180 * namelist entries for cycle headers.
181 * the number of discovered cycles.
183 nltype *cyclenl; /* cycle header namelist */
184 int ncycle; /* number of cycles discovered */
187 * The header on the gmon.out file.
188 * gmon.out consists of a struct phdr (defined in gmon.h)
189 * and then an array of ncnt samples representing the
190 * discretized program counter values.
192 * Backward compatible old style header
203 * Each discretized pc sample has
204 * a count of the number of samples in its range
208 unsigned long s_lowpc; /* lowpc from the profile file */
209 unsigned long s_highpc; /* highpc from the profile file */
210 unsigned lowpc, highpc; /* range profiled, in UNIT's */
211 unsigned sampbytes; /* number of bytes of samples */
212 int nsamples; /* number of samples */
213 double actime; /* accumulated time thus far for putprofline */
214 double totime; /* total time for all routines */
215 double printtime; /* total of time being printed */
216 double scale; /* scale factor converting samples to pc
217 values: each sample covers scale bytes */
218 unsigned char *textspace; /* text space of a.out in core */
219 int cyclethreshold; /* with -C, minimum cycle size to ignore */
222 * option flags, from a to z.
224 bool aflag; /* suppress static functions */
225 bool bflag; /* blurbs, too */
226 bool cflag; /* discovered call graph, too */
227 bool Cflag; /* find cut-set to eliminate cycles */
228 bool dflag; /* debugging options */
229 bool eflag; /* specific functions excluded */
230 bool Eflag; /* functions excluded with time */
231 bool fflag; /* specific functions requested */
232 bool Fflag; /* functions requested with time */
233 bool kflag; /* arcs to be deleted */
234 bool sflag; /* sum multiple gmon.out files */
235 bool uflag; /* suppress symbols hidden from C */
236 bool zflag; /* zero time/called functions, too */
239 * structure for various string lists
242 struct stringlist *next;
245 struct stringlist *elist;
246 struct stringlist *Elist;
247 struct stringlist *flist;
248 struct stringlist *Flist;
249 struct stringlist *kfromlist;
250 struct stringlist *ktolist;
253 * function declarations
258 int aout_getnfile(const char *, char ***);
260 arctype *arclookup();
281 int elf_getnfile(const char *, char ***);
298 long operandlength();
299 operandenum operandmode();
311 unsigned long reladdr();
327 #define GREATERTHAN 1
334 #define SAMPLEDEBUG 32
336 #define CALLDEBUG 128
337 #define LOOKUPDEBUG 256
338 #define PROPDEBUG 512
339 #define BREAKCYCLE 1024
340 #define SUBCYCLELIST 2048
341 #define ANYDEBUG 4096