rlm@1: /* rlm@1: * Copyright (c) 1983, 1991, 1993, 2001 rlm@1: * The Regents of the University of California. All rights reserved. rlm@1: * rlm@1: * Redistribution and use in source and binary forms, with or without rlm@1: * modification, are permitted provided that the following conditions rlm@1: * are met: rlm@1: * 1. Redistributions of source code must retain the above copyright rlm@1: * notice, this list of conditions and the following disclaimer. rlm@1: * 2. Redistributions in binary form must reproduce the above copyright rlm@1: * notice, this list of conditions and the following disclaimer in the rlm@1: * documentation and/or other materials provided with the distribution. rlm@1: * 3. Neither the name of the University nor the names of its contributors rlm@1: * may be used to endorse or promote products derived from this software rlm@1: * without specific prior written permission. rlm@1: * rlm@1: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND rlm@1: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE rlm@1: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE rlm@1: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE rlm@1: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL rlm@1: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS rlm@1: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) rlm@1: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT rlm@1: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY rlm@1: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF rlm@1: * SUCH DAMAGE. rlm@1: */ rlm@1: #ifndef gmon_h rlm@1: #define gmon_h rlm@1: rlm@1: #include rlm@1: typedef uint32_t u32; rlm@1: rlm@1: /* Size of the 4.4BSD gmon header */ rlm@1: #define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4)) rlm@1: #define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4)) rlm@1: rlm@1: #if 0 /* For documentation purposes only. */ rlm@1: struct raw_phdr rlm@1: { rlm@1: char low_pc[sizeof(void *)]; /* base pc address of sample buffer */ rlm@1: char high_pc[sizeof(void *)];/* max pc address of sampled buffer */ rlm@1: char ncnt[4]; /* size of sample buffer (plus this rlm@1: header) */ rlm@1: rlm@1: char version[4]; /* version number */ rlm@1: char profrate[4]; /* profiling clock rate */ rlm@1: char spare[3*4]; /* reserved */ rlm@1: }; rlm@1: #endif rlm@1: rlm@1: #define GMONVERSION 0x00051879 rlm@1: rlm@1: /* Size of the old BSD gmon header */ rlm@1: #define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) rlm@1: rlm@1: /* FIXME: Checking host compiler defines here means that we can't rlm@1: use a cross gprof alpha OSF. */ rlm@1: #if defined(__alpha__) && defined (__osf__) rlm@1: #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4) rlm@1: #else rlm@1: #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4) rlm@1: #endif rlm@1: rlm@1: #if 0 /* For documentation purposes only. */ rlm@1: struct old_raw_phdr rlm@1: { rlm@1: char low_pc[sizeof(void *)]; /* base pc address of sample buffer */ rlm@1: char high_pc[sizeof(void *)];/* max pc address of sampled buffer */ rlm@1: char ncnt[4]; /* size of sample buffer (plus this rlm@1: header) */ rlm@1: #if defined (__alpha__) && defined (__osf__) rlm@1: /* rlm@1: * DEC's OSF v3.0 uses 4 bytes of padding to bring the header to rlm@1: * a size that is a multiple of 8. rlm@1: */ rlm@1: char pad[4]; rlm@1: #endif rlm@1: }; rlm@1: #endif rlm@1: rlm@1: /* rlm@1: * Histogram counters are unsigned shorts: rlm@1: */ rlm@1: #define HISTCOUNTER unsigned short rlm@1: rlm@1: /* rlm@1: * Fraction of text space to allocate for histogram counters here, 1/2: rlm@1: */ rlm@1: #define HISTFRACTION 2 rlm@1: rlm@1: /* rlm@1: * Fraction of text space to allocate for from hash buckets. The rlm@1: * value of HASHFRACTION is based on the minimum number of bytes of rlm@1: * separation between two subroutine call points in the object code. rlm@1: * Given MIN_SUBR_SEPARATION bytes of separation the value of rlm@1: * HASHFRACTION is calculated as: rlm@1: * rlm@1: * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); rlm@1: * rlm@1: * For the VAX, the shortest two call sequence is: rlm@1: * rlm@1: * calls $0,(r0) rlm@1: * calls $0,(r0) rlm@1: * rlm@1: * which is separated by only three bytes, thus HASHFRACTION is rlm@1: * calculated as: rlm@1: * rlm@1: * HASHFRACTION = 3 / (2 * 2 - 1) = 1 rlm@1: * rlm@1: * Note that the division above rounds down, thus if MIN_SUBR_FRACTION rlm@1: * is less than three, this algorithm will not work! rlm@1: */ rlm@1: #define HASHFRACTION 1 rlm@1: rlm@1: /* rlm@1: * Percent of text space to allocate for tostructs with a minimum: rlm@1: */ rlm@1: #define ARCDENSITY 2 rlm@1: #define MINARCS 50 rlm@1: rlm@1: struct tostruct rlm@1: { rlm@1: u32 selfpc; rlm@1: int count; rlm@1: unsigned short link; rlm@1: }; rlm@1: rlm@1: /* rlm@1: * A raw arc, with pointers to the calling site and the called site rlm@1: * and a count. Everything is defined in terms of characters so rlm@1: * as to get a packed representation (otherwise, different compilers rlm@1: * might introduce different padding): rlm@1: */ rlm@1: #if 0 /* For documentation purposes only. */ rlm@1: struct raw_arc rlm@1: { rlm@1: char from_pc[sizeof(void *)]; rlm@1: char self_pc[sizeof(void *)]; rlm@1: char count[sizeof(long)]; rlm@1: }; rlm@1: #endif rlm@1: rlm@1: /* rlm@1: * General rounding functions: rlm@1: */ rlm@1: #define ROUNDDOWN(x,y) (((x)/(y))*(y)) rlm@1: #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) rlm@1: rlm@1: #endif /* gmon_h */