/*- * Copyright (c) 1982, 1986, 1992 The Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% * * @(#)gmon.h 7.5 (Berkeley) 07/10/92 */ #ifndef _GMON_H_ #define _GMON_H_ #include /* * Structure prepended to gmon.out profiling data file. */ struct gmonhdr { u_long lpc; /* base pc address of sample buffer */ u_long hpc; /* max pc address of sampled buffer */ int ncnt; /* size of sample buffer (plus this header) */ int version; /* version number */ int profrate; /* profiling clock rate */ int spare[3]; /* reserved */ }; #define GMONVERSION 0x00051879 /* * histogram counters are unsigned shorts (according to the kernel). */ #define HISTCOUNTER unsigned short /* * fraction of text space to allocate for histogram counters here, 1/2 */ #define HISTFRACTION 2 /* * Fraction of text space to allocate for from hash buckets. * The value of HASHFRACTION is based on the minimum number of bytes * of separation between two subroutine call points in the object code. * Given MIN_SUBR_SEPARATION bytes of separation the value of * HASHFRACTION is calculated as: * * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); * * For example, on the VAX, the shortest two call sequence is: * * calls $0,(r0) * calls $0,(r0) * * which is separated by only three bytes, thus HASHFRACTION is * calculated as: * * HASHFRACTION = 3 / (2 * 2 - 1) = 1 * * Note that the division above rounds down, thus if MIN_SUBR_FRACTION * is less than three, this algorithm will not work! * * In practice, however, call instructions are rarely at a minimal * distance. Hence, we will define HASHFRACTION to be 2 across all * architectures. This saves a reasonable amount of space for * profiling data structures without (in practice) sacrificing * any granularity. */ #define HASHFRACTION 2 /* * percent of text space to allocate for tostructs with a minimum. */ #define ARCDENSITY 2 #define MINARCS 50 #define MAXARCS ((1 << (8 * sizeof(HISTCOUNTER))) - 2) struct tostruct { u_long selfpc; long count; u_short link; u_short pad; }; /* * a raw arc, with pointers to the calling site and * the called site and a count. */ struct rawarc { u_long raw_frompc; u_long raw_selfpc; long raw_count; }; /* * general rounding functions. */ #define ROUNDDOWN(x,y) (((x)/(y))*(y)) #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) /* * The profiling data structures are housed in this structure. */ struct gmonparam { int state; u_short *froms; struct tostruct *tos; long tolimit; u_long lowpc; u_long highpc; u_long textsize; }; extern struct gmonparam _gmonparam; /* * Possible states of profiling. */ #define GMON_PROF_ON 0 #define GMON_PROF_BUSY 1 #define GMON_PROF_ERROR 2 #define GMON_PROF_OFF 3 #endif