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