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