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
22 #include <sys/types.h>
44 * who am i, for error messages.
60 typedef u_short UNIT; /* unit of profiling */
62 #define A_OUTNAME "a.out"
65 #define GMONNAME "gmon.out"
66 #define GMONSUM "gmon.sum"
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.
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 */
84 typedef struct arcstruct arctype;
88 * for each external in the specified file we gather
89 * its address, the number of calls and compute its share of cpu time.
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 */
111 typedef struct nl nltype;
113 nltype *nl; /* the whole namelist */
114 nltype *npe; /* the virtual end of the namelist */
115 int nname; /* the number of function names */
118 * flag which marks a nl entry as topologically ``busy''
119 * flag which marks a nl entry as topologically ``not_numbered''
125 * namelist entries for cycle headers.
126 * the number of discovered cycles.
128 nltype *cyclenl; /* cycle header namelist */
129 int ncycle; /* number of cycles discovered */
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.
150 * Each discretized pc sample has
151 * a count of the number of samples in its range
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 */
171 * option flags, from a to z.
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 */
186 * structure for various string lists
189 struct stringlist *next;
192 struct stringlist *elist;
193 struct stringlist *Elist;
194 struct stringlist *flist;
195 struct stringlist *Flist;
196 struct stringlist *kfromlist;
197 struct stringlist *ktolist;
200 * function declarations
206 arctype *arclookup();
256 unsigned long reladdr();
272 #define GREATERTHAN 1
279 #define SAMPLEDEBUG 32
281 #define CALLDEBUG 128
282 #define LOOKUPDEBUG 256
283 #define PROPDEBUG 512
284 #define ANYDEBUG 1024