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