ranlib: fix it
[odcctools-svp.git] / gprof / gprof.h
blob009b2c0540f46b6baed5fa796a8bb926a88b7cd5
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 /* $OpenBSD: gprof.h,v 1.4 1996/12/22 20:24:24 rahnds Exp $ */
24 /* $NetBSD: gprof.h,v 1.13 1996/04/01 21:54:06 mark Exp $ */
27 * Copyright (c) 1983, 1993
28 * The Regents of the University of California. All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by the University of
41 * California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
58 * @(#)gprof.h 8.1 (Berkeley) 6/6/93
60 #include <stdio.h>
61 #include <sys/types.h>
62 #include <sys/stat.h>
63 #include <gnu/a.out.h>
64 #ifdef __OPENSTEP__
65 #include <mach-o/rld_state.h>
66 #include <mach-o/gmon.h>
67 #else
68 #include <sys/gmon.h>
69 #endif
70 #include "stuff/bool.h"
73 * Used for comparison routine return values.
75 #define LESSTHAN -1
76 #define EQUALTO 0
77 #define GREATERTHAN 1
79 #ifdef NeXT_MOD
80 #define UNIT short /* unit of profiling */
81 #else
82 typedef short UNIT; /* unit of profiling */
83 #endif
86 * Progname for error messages.
88 extern char *progname;
91 * Ticks per second.
93 extern long hz;
95 extern char *a_outname;
96 #define A_OUTNAME "a.out"
98 extern char *gmonname;
99 #define GMONNAME "gmon.out"
100 #define GMONSUM "gmon.sum"
103 * Blurbs on the flat and graph profiles.
105 #ifdef __OPENSTEP__
106 #define FLAT_BLURB "/usr/lib/gprof.flat"
107 #define CALLG_BLURB "/usr/lib/gprof.callg"
108 #else
109 #define FLAT_BLURB "/usr/share/gprof.flat"
110 #define CALLG_BLURB "/usr/share/gprof.callg"
111 #endif
114 * a constructed arc,
115 * with pointers to the namelist entry of the parent and the child,
116 * a count of how many times this arc was traversed,
117 * and pointers to the next parent of this child and
118 * the next child of this parent.
120 struct arcstruct {
121 struct nl *arc_parentp; /* pointer to parent's nl entry */
122 struct nl *arc_childp; /* pointer to child's nl entry */
123 long arc_count; /* how calls from parent to child */
124 unsigned long arc_order; /* order called */
125 double arc_time; /* time inherited along arc */
126 double arc_childtime; /* childtime inherited along arc */
127 struct arcstruct *arc_parentlist; /* parents-of-this-child list */
128 struct arcstruct *arc_childlist; /* children-of-this-parent list */
130 typedef struct arcstruct arctype;
133 * The symbol table;
134 * for each external in the specified file we gather
135 * its address, the number of calls and compute its share of cpu time.
137 struct nl {
138 char *name; /* the name */
139 unsigned long value; /* the pc entry point */
140 unsigned long svalue; /* entry point aligned to histograms */
141 double time; /* ticks in this routine */
142 double childtime; /* cumulative ticks in children */
143 unsigned long order; /* order called */
144 long ncall; /* how many times called */
145 long selfcalls; /* how many calls to self */
146 double propfraction; /* what % of time propagates */
147 double propself; /* how much self time propagates */
148 double propchild; /* how much child time propagates */
149 enum bool printflag; /* should this be printed? */
150 int index; /* index in the graph list */
151 int toporder; /* graph call chain top-sort order */
152 int cycleno; /* internal number of cycle on */
153 struct nl *cyclehead; /* pointer to head of cycle */
154 struct nl *cnext; /* pointer to next member of cycle */
155 arctype *parents; /* list of caller arcs */
156 arctype *children; /* list of callee arcs */
158 typedef struct nl nltype;
160 extern nltype *nl; /* the whole namelist */
161 extern nltype *npe; /* the virtual end of the namelist */
162 extern unsigned long nname; /* the number of function names */
165 * The list of file names and the ranges their pc's cover used for building
166 * order files with the -S option.
168 struct file {
169 unsigned long firstpc;
170 unsigned long lastpc;
171 char *name;
172 char *what_name;
174 extern struct file *files;
175 extern unsigned long n_files;
178 * flag which marks a nl entry as topologically ``busy''
179 * flag which marks a nl entry as topologically ``not_numbered''
181 #define DFN_BUSY -1
182 #define DFN_NAN 0
185 * namelist entries for cycle headers.
186 * the number of discovered cycles.
188 extern nltype *cyclenl; /* cycle header namelist */
189 extern int ncycle; /* number of cycles discovered */
192 * The information for the pc sample sets from the gmon.out file.
194 struct sample_set {
195 unsigned long s_lowpc; /* lowpc from the profile file */
196 unsigned long s_highpc; /* highpc from the profile file */
197 unsigned lowpc; /* range profiled, in UNIT's */
198 unsigned highpc;
199 unsigned sampbytes; /* number of bytes of samples */
200 unsigned long nsamples; /* number of samples */
201 unsigned UNIT *samples; /* in core accumulated samples */
202 double scale; /* scale factor converting samples to
203 pc values: each sample covers scale
204 bytes */
205 #ifndef __OPENSTEP__
206 int version;
207 int profrate;
208 int spare[3];
209 #endif
211 extern struct sample_set *sample_sets;
212 extern unsigned long nsample_sets;
214 #ifdef __OPENSTEP__
216 * The rld loaded state from the gmon.out file.
218 struct rld_loaded_state *grld_loaded_state;
219 extern unsigned long grld_nloaded_states;
220 extern void get_rld_state_symbols(void);
221 #endif
224 * The dyld images from the gmon.out file.
226 struct dyld_image {
227 char *name;
228 unsigned long vmaddr_slide;
230 extern unsigned long image_count;
231 extern struct dyld_image *dyld_images;
232 extern void get_dyld_state_symbols(void);
234 extern unsigned char *textspace; /* text space of a.out in core */
236 extern double totime; /* total time for all routines */
237 extern double printtime; /* total of time being printed */
238 extern double actime; /* accumulated time thus far for
239 putprofline */
242 * Option flags, from a to z.
244 extern enum bool aflag; /* suppress static functions */
245 extern enum bool bflag; /* blurbs, too */
246 extern enum bool cflag; /* discovered call graph, too */
247 extern enum bool dflag; /* debugging options */
248 extern enum bool eflag; /* specific functions excluded */
249 extern enum bool Eflag; /* functions excluded with time */
250 extern enum bool fflag; /* specific functions requested */
251 extern enum bool Fflag; /* functions requested with time */
252 extern enum bool sflag; /* sum multiple gmon.out files */
253 extern enum bool Sflag; /* produce order file for scatter loading */
254 extern enum bool xflag; /* don't produce gmon.order file */
255 extern enum bool zflag; /* zero time/called functions, too */
258 * Structure for various string lists.
260 struct stringlist {
261 struct stringlist *next;
262 char *string;
264 extern struct stringlist *elist;
265 extern struct stringlist *Elist;
266 extern struct stringlist *flist;
267 extern struct stringlist *Flist;
270 * The debug value for debugging gprof.
272 extern unsigned long debug;
274 #define DFNDEBUG 1
275 #define CYCLEDEBUG 2
276 #define ARCDEBUG 4
277 #define TALLYDEBUG 8
278 #define TIMEDEBUG 16
279 #define SAMPLEDEBUG 32
280 #define AOUTDEBUG 64
281 #define CALLSDEBUG 128
282 #define LOOKUPDEBUG 256
283 #define PROPDEBUG 512
284 #define ANYDEBUG 1024
285 #define RLDDEBUG 2048
286 #define DYLDDEBUG 4096
288 struct shlib_text_range {
289 unsigned long lowpc;
290 unsigned long highpc;
292 extern struct shlib_text_range *shlib_text_ranges;
293 extern unsigned long nshlib_text_ranges;
296 * External function declarations for the functions of the gprof source.
299 /* arcs.c */
300 extern void addarc(
301 nltype *parentp,
302 nltype *childp,
303 unsigned long count,
304 unsigned long order);
306 extern nltype **doarcs(
307 void);
309 /* calls.c */
310 extern void findcalls(
311 nltype *parentp,
312 unsigned long p_lowpc,
313 unsigned long p_highpc);
315 /* dfn.c */
316 extern void dfn(
317 nltype *parentp);
319 /* getnfile.c */
320 extern void getnfile(
321 void);
323 extern void get_text_min_max(
324 unsigned long *text_min,
325 unsigned long *text_max);
327 /* hertz.c */
328 extern unsigned long hertz(
329 void);
331 /* lookup.c */
332 extern nltype *nllookup(
333 unsigned long address);
335 extern arctype *arclookup(
336 nltype *parentp,
337 nltype *childp);
339 /* printgprof.c */
340 extern void printgprof(
341 nltype **timesortnlp);
343 extern void printprof(
344 void);
346 extern void printindex(
347 void);
349 extern void printname(
350 nltype *selfp);
352 extern int totalcmp(
353 nltype **npp1,
354 nltype **npp2);
356 /* printlist.c */
357 extern void addlist(
358 struct stringlist *listp,
359 char *funcname);
361 extern enum bool onlist(
362 struct stringlist *listp,
363 char *funcname);
365 /* scatter.c */
366 extern void printscatter(
367 void);