... and make it return the *right* value when it goes out of bounds.
[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
71 /*
72 * a constructed arc,
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.
77 */
78struct arcstruct {
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 */
86};
87typedef struct arcstruct arctype;
88
89 /*
90 * The symbol table;
91 * for each external in the specified file we gather
92 * its address, the number of calls and compute its share of cpu time.
93 */
94struct nl {
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 */
113};
114typedef struct nl nltype;
115
116nltype *nl; /* the whole namelist */
117nltype *npe; /* the virtual end of the namelist */
118int nname; /* the number of function names */
119
120 /*
121 * flag which marks a nl entry as topologically ``busy''
122 * flag which marks a nl entry as topologically ``not_numbered''
123 */
124#define DFN_BUSY -1
125#define DFN_NAN 0
126
127 /*
128 * namelist entries for cycle headers.
129 * the number of discovered cycles.
130 */
131nltype *cyclenl; /* cycle header namelist */
132int ncycle; /* number of cycles discovered */
133
134 /*
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.
141 */
142struct hdr {
143 UNIT *lowpc;
144 UNIT *highpc;
145 int ncnt;
146};
147
148struct hdr h;
149
150int debug;
151
152 /*
153 * Each discretized pc sample has
154 * a count of the number of samples in its range
155 */
156UNIT *samples;
157
158unsigned long s_lowpc; /* lowpc from the profile file */
159unsigned long s_highpc; /* highpc from the profile file */
160unsigned lowpc, highpc; /* range profiled, in UNIT's */
161unsigned sampbytes; /* number of bytes of samples */
162int nsamples; /* number of samples */
163double actime; /* accumulated time thus far for putprofline */
164double totime; /* total time for all routines */
165double printtime; /* total of time being printed */
166double scale; /* scale factor converting samples to pc
167 values: each sample covers scale bytes */
168char *strtab; /* string table in core */
169off_t ssiz; /* size of the string table */
3d6c6501
SEF
170unsigned char *textspace; /* text space of a.out in core */
171
172 /*
173 * option flags, from a to z.
174 */
175bool aflag; /* suppress static functions */
176bool bflag; /* blurbs, too */
177bool cflag; /* discovered call graph, too */
178bool dflag; /* debugging options */
179bool eflag; /* specific functions excluded */
180bool Eflag; /* functions excluded with time */
181bool fflag; /* specific functions requested */
182bool Fflag; /* functions requested with time */
183bool kflag; /* arcs to be deleted */
184bool sflag; /* sum multiple gmon.out files */
185bool zflag; /* zero time/called functions, too */
186
187 /*
188 * structure for various string lists
189 */
190struct stringlist {
191 struct stringlist *next;
192 char *string;
193};
194struct stringlist *elist;
195struct stringlist *Elist;
196struct stringlist *flist;
197struct stringlist *Flist;
198struct stringlist *kfromlist;
199struct stringlist *ktolist;
200
201 /*
202 * function declarations
203 */
204/*
205 addarc();
206*/
207int arccmp();
208arctype *arclookup();
209/*
210 asgnsamples();
211 printblurb();
212 cyclelink();
213 dfn();
214*/
215bool dfn_busy();
216/*
217 dfn_findcycle();
218*/
219bool dfn_numbered();
220/*
221 dfn_post_visit();
222 dfn_pre_visit();
223 dfn_self_cycle();
224*/
225nltype **doarcs();
226/*
227 done();
228 findcalls();
229 flatprofheader();
230 flatprofline();
231*/
232bool funcsymbol();
233/*
234 getnfile();
235 getpfile();
236 getstrtab();
237 getsymtab();
238 gettextspace();
239 gprofheader();
240 gprofline();
241 main();
242*/
243unsigned long max();
244int membercmp();
245unsigned long min();
246nltype *nllookup();
247FILE *openpfile();
248/*
249 printchildren();
250 printcycle();
251 printgprof();
252 printmembers();
253 printname();
254 printparents();
255 printprof();
256 readsamples();
257*/
258unsigned long reladdr();
259/*
260 sortchildren();
261 sortmembers();
262 sortparents();
263 tally();
264 timecmp();
265 topcmp();
266*/
267int totalcmp();
268/*
269 valcmp();
270*/
271
272#define LESSTHAN -1
273#define EQUALTO 0
274#define GREATERTHAN 1
275
276#define DFNDEBUG 1
277#define CYCLEDEBUG 2
278#define ARCDEBUG 4
279#define TALLYDEBUG 8
280#define TIMEDEBUG 16
281#define SAMPLEDEBUG 32
282#define AOUTDEBUG 64
283#define CALLDEBUG 128
284#define LOOKUPDEBUG 256
285#define PROPDEBUG 512
286#define ANYDEBUG 1024
This page took 0.051223 seconds and 4 git commands to generate.