1*a9fa9459Szrj /* 2*a9fa9459Szrj * Copyright (c) 1983, 1991, 1993, 2001 3*a9fa9459Szrj * The Regents of the University of California. All rights reserved. 4*a9fa9459Szrj * 5*a9fa9459Szrj * Redistribution and use in source and binary forms, with or without 6*a9fa9459Szrj * modification, are permitted provided that the following conditions 7*a9fa9459Szrj * are met: 8*a9fa9459Szrj * 1. Redistributions of source code must retain the above copyright 9*a9fa9459Szrj * notice, this list of conditions and the following disclaimer. 10*a9fa9459Szrj * 2. Redistributions in binary form must reproduce the above copyright 11*a9fa9459Szrj * notice, this list of conditions and the following disclaimer in the 12*a9fa9459Szrj * documentation and/or other materials provided with the distribution. 13*a9fa9459Szrj * 3. Neither the name of the University nor the names of its contributors 14*a9fa9459Szrj * may be used to endorse or promote products derived from this software 15*a9fa9459Szrj * without specific prior written permission. 16*a9fa9459Szrj * 17*a9fa9459Szrj * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18*a9fa9459Szrj * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*a9fa9459Szrj * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*a9fa9459Szrj * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21*a9fa9459Szrj * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*a9fa9459Szrj * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*a9fa9459Szrj * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*a9fa9459Szrj * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*a9fa9459Szrj * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*a9fa9459Szrj * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*a9fa9459Szrj * SUCH DAMAGE. 28*a9fa9459Szrj */ 29*a9fa9459Szrj #ifndef gmon_h 30*a9fa9459Szrj #define gmon_h 31*a9fa9459Szrj 32*a9fa9459Szrj /* Size of the 4.4BSD gmon header */ 33*a9fa9459Szrj #define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4)) 34*a9fa9459Szrj #define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4)) 35*a9fa9459Szrj 36*a9fa9459Szrj /* *INDENT-OFF* */ 37*a9fa9459Szrj /* For documentation purposes only. 38*a9fa9459Szrj 39*a9fa9459Szrj struct raw_phdr 40*a9fa9459Szrj { 41*a9fa9459Szrj char low_pc[sizeof(void *)]; -- base pc address of sample buffer 42*a9fa9459Szrj char high_pc[sizeof(void *)]; -- max pc address of sampled buffer 43*a9fa9459Szrj char ncnt[4]; -- size of sample buffer (plus this 44*a9fa9459Szrj header) 45*a9fa9459Szrj 46*a9fa9459Szrj char version[4]; -- version number 47*a9fa9459Szrj char profrate[4]; -- profiling clock rate 48*a9fa9459Szrj char spare[3*4]; -- reserved 49*a9fa9459Szrj }; 50*a9fa9459Szrj */ 51*a9fa9459Szrj /* *INDENT-ON* */ 52*a9fa9459Szrj 53*a9fa9459Szrj #define GMONVERSION 0x00051879 54*a9fa9459Szrj 55*a9fa9459Szrj /* Size of the old BSD gmon header */ 56*a9fa9459Szrj #define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) 57*a9fa9459Szrj 58*a9fa9459Szrj /* FIXME: Checking host compiler defines here means that we can't 59*a9fa9459Szrj use a cross gprof alpha OSF. */ 60*a9fa9459Szrj #if defined(__alpha__) && defined (__osf__) 61*a9fa9459Szrj #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4) 62*a9fa9459Szrj #else 63*a9fa9459Szrj #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4) 64*a9fa9459Szrj #endif 65*a9fa9459Szrj 66*a9fa9459Szrj /* *INDENT-OFF* */ 67*a9fa9459Szrj /* For documentation purposes only. 68*a9fa9459Szrj 69*a9fa9459Szrj struct old_raw_phdr 70*a9fa9459Szrj { 71*a9fa9459Szrj char low_pc[sizeof(void *)]; -- base pc address of sample buffer 72*a9fa9459Szrj char high_pc[sizeof(void *)] -- max pc address of sampled buffer 73*a9fa9459Szrj char ncnt[4]; -- size of sample buffer (plus this 74*a9fa9459Szrj header) 75*a9fa9459Szrj 76*a9fa9459Szrj if defined (__alpha__) && defined (__osf__) 77*a9fa9459Szrj char pad[4]; -- DEC's OSF v3.0 uses 4 bytes of padding 78*a9fa9459Szrj -- to bring the header to a size that is a 79*a9fa9459Szrj -- multiple of 8. 80*a9fa9459Szrj endif 81*a9fa9459Szrj }; 82*a9fa9459Szrj */ 83*a9fa9459Szrj /* *INDENT-ON* */ 84*a9fa9459Szrj 85*a9fa9459Szrj /* 86*a9fa9459Szrj * Histogram counters are unsigned shorts: 87*a9fa9459Szrj */ 88*a9fa9459Szrj #define HISTCOUNTER unsigned short 89*a9fa9459Szrj 90*a9fa9459Szrj /* 91*a9fa9459Szrj * Fraction of text space to allocate for histogram counters here, 1/2: 92*a9fa9459Szrj */ 93*a9fa9459Szrj #define HISTFRACTION 2 94*a9fa9459Szrj 95*a9fa9459Szrj /* 96*a9fa9459Szrj * Fraction of text space to allocate for from hash buckets. The 97*a9fa9459Szrj * value of HASHFRACTION is based on the minimum number of bytes of 98*a9fa9459Szrj * separation between two subroutine call points in the object code. 99*a9fa9459Szrj * Given MIN_SUBR_SEPARATION bytes of separation the value of 100*a9fa9459Szrj * HASHFRACTION is calculated as: 101*a9fa9459Szrj * 102*a9fa9459Szrj * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); 103*a9fa9459Szrj * 104*a9fa9459Szrj * For the VAX, the shortest two call sequence is: 105*a9fa9459Szrj * 106*a9fa9459Szrj * calls $0,(r0) 107*a9fa9459Szrj * calls $0,(r0) 108*a9fa9459Szrj * 109*a9fa9459Szrj * which is separated by only three bytes, thus HASHFRACTION is 110*a9fa9459Szrj * calculated as: 111*a9fa9459Szrj * 112*a9fa9459Szrj * HASHFRACTION = 3 / (2 * 2 - 1) = 1 113*a9fa9459Szrj * 114*a9fa9459Szrj * Note that the division above rounds down, thus if MIN_SUBR_FRACTION 115*a9fa9459Szrj * is less than three, this algorithm will not work! 116*a9fa9459Szrj */ 117*a9fa9459Szrj #define HASHFRACTION 1 118*a9fa9459Szrj 119*a9fa9459Szrj /* 120*a9fa9459Szrj * Percent of text space to allocate for tostructs with a minimum: 121*a9fa9459Szrj */ 122*a9fa9459Szrj #define ARCDENSITY 2 123*a9fa9459Szrj #define MINARCS 50 124*a9fa9459Szrj 125*a9fa9459Szrj struct tostruct 126*a9fa9459Szrj { 127*a9fa9459Szrj char *selfpc; 128*a9fa9459Szrj int count; 129*a9fa9459Szrj unsigned short link; 130*a9fa9459Szrj }; 131*a9fa9459Szrj 132*a9fa9459Szrj /* 133*a9fa9459Szrj * A raw arc, with pointers to the calling site and the called site 134*a9fa9459Szrj * and a count. Everything is defined in terms of characters so 135*a9fa9459Szrj * as to get a packed representation (otherwise, different compilers 136*a9fa9459Szrj * might introduce different padding): 137*a9fa9459Szrj */ 138*a9fa9459Szrj 139*a9fa9459Szrj /* *INDENT-OFF* */ 140*a9fa9459Szrj /* For documentation purposes only. 141*a9fa9459Szrj 142*a9fa9459Szrj struct raw_arc 143*a9fa9459Szrj { 144*a9fa9459Szrj char from_pc[sizeof(void *)]; 145*a9fa9459Szrj char self_pc[sizeof(void *)]; 146*a9fa9459Szrj char count[sizeof(long)]; 147*a9fa9459Szrj }; 148*a9fa9459Szrj */ 149*a9fa9459Szrj /* *INDENT-ON* */ 150*a9fa9459Szrj 151*a9fa9459Szrj /* 152*a9fa9459Szrj * General rounding functions: 153*a9fa9459Szrj */ 154*a9fa9459Szrj #define ROUNDDOWN(x,y) (((x)/(y))*(y)) 155*a9fa9459Szrj #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) 156*a9fa9459Szrj 157*a9fa9459Szrj #endif /* gmon_h */ 158