16e421504Sfgsch /* 2*c074d1c9Sdrahn * Copyright (c) 1983, 1991, 1993, 2001 36e421504Sfgsch * The Regents of the University of California. All rights reserved. 42159047fSniklas * 52159047fSniklas * Redistribution and use in source and binary forms, with or without 62159047fSniklas * modification, are permitted provided that the following conditions 72159047fSniklas * are met: 82159047fSniklas * 1. Redistributions of source code must retain the above copyright 92159047fSniklas * notice, this list of conditions and the following disclaimer. 102159047fSniklas * 2. Redistributions in binary form must reproduce the above copyright 112159047fSniklas * notice, this list of conditions and the following disclaimer in the 122159047fSniklas * documentation and/or other materials provided with the distribution. 136e421504Sfgsch * 3. Neither the name of the University nor the names of its contributors 142159047fSniklas * may be used to endorse or promote products derived from this software 152159047fSniklas * without specific prior written permission. 162159047fSniklas * 172159047fSniklas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 182159047fSniklas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 192159047fSniklas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 202159047fSniklas * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 212159047fSniklas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 222159047fSniklas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 232159047fSniklas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 242159047fSniklas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 252159047fSniklas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 262159047fSniklas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 272159047fSniklas * SUCH DAMAGE. 282159047fSniklas */ 292159047fSniklas #ifndef gmon_h 302159047fSniklas #define gmon_h 312159047fSniklas 32*c074d1c9Sdrahn /* Size of the 4.4BSD gmon header */ 33*c074d1c9Sdrahn #define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4)) 34*c074d1c9Sdrahn #define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4)) 35*c074d1c9Sdrahn 36*c074d1c9Sdrahn #if 0 /* For documentation purposes only. */ 372159047fSniklas struct raw_phdr 382159047fSniklas { 39*c074d1c9Sdrahn char low_pc[sizeof(void *)]; /* base pc address of sample buffer */ 40*c074d1c9Sdrahn char high_pc[sizeof(void *)];/* max pc address of sampled buffer */ 41*c074d1c9Sdrahn char ncnt[4]; /* size of sample buffer (plus this 42*c074d1c9Sdrahn header) */ 43191aa565Sniklas 44b305b0f1Sespie char version[4]; /* version number */ 45b305b0f1Sespie char profrate[4]; /* profiling clock rate */ 46b305b0f1Sespie char spare[3*4]; /* reserved */ 47b305b0f1Sespie }; 48*c074d1c9Sdrahn #endif 49b305b0f1Sespie 50b305b0f1Sespie #define GMONVERSION 0x00051879 51b305b0f1Sespie 52*c074d1c9Sdrahn /* Size of the old BSD gmon header */ 53*c074d1c9Sdrahn #define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4) 54b305b0f1Sespie 55b305b0f1Sespie /* FIXME: Checking host compiler defines here means that we can't 56b305b0f1Sespie use a cross gprof alpha OSF. */ 57191aa565Sniklas #if defined(__alpha__) && defined (__osf__) 58*c074d1c9Sdrahn #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4) 59*c074d1c9Sdrahn #else 60*c074d1c9Sdrahn #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4) 61*c074d1c9Sdrahn #endif 62*c074d1c9Sdrahn 63*c074d1c9Sdrahn #if 0 /* For documentation purposes only. */ 64*c074d1c9Sdrahn struct old_raw_phdr 65*c074d1c9Sdrahn { 66*c074d1c9Sdrahn char low_pc[sizeof(void *)]; /* base pc address of sample buffer */ 67*c074d1c9Sdrahn char high_pc[sizeof(void *)];/* max pc address of sampled buffer */ 68*c074d1c9Sdrahn char ncnt[4]; /* size of sample buffer (plus this 69*c074d1c9Sdrahn header) */ 70*c074d1c9Sdrahn #if defined (__alpha__) && defined (__osf__) 712159047fSniklas /* 722159047fSniklas * DEC's OSF v3.0 uses 4 bytes of padding to bring the header to 732159047fSniklas * a size that is a multiple of 8. 742159047fSniklas */ 752159047fSniklas char pad[4]; 760c6d0228Sniklas #endif 772159047fSniklas }; 78*c074d1c9Sdrahn #endif 792159047fSniklas 802159047fSniklas /* 812159047fSniklas * Histogram counters are unsigned shorts: 822159047fSniklas */ 832159047fSniklas #define HISTCOUNTER unsigned short 842159047fSniklas 852159047fSniklas /* 862159047fSniklas * Fraction of text space to allocate for histogram counters here, 1/2: 872159047fSniklas */ 882159047fSniklas #define HISTFRACTION 2 892159047fSniklas 902159047fSniklas /* 912159047fSniklas * Fraction of text space to allocate for from hash buckets. The 922159047fSniklas * value of HASHFRACTION is based on the minimum number of bytes of 932159047fSniklas * separation between two subroutine call points in the object code. 942159047fSniklas * Given MIN_SUBR_SEPARATION bytes of separation the value of 952159047fSniklas * HASHFRACTION is calculated as: 962159047fSniklas * 972159047fSniklas * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); 982159047fSniklas * 992159047fSniklas * For the VAX, the shortest two call sequence is: 1002159047fSniklas * 1012159047fSniklas * calls $0,(r0) 1022159047fSniklas * calls $0,(r0) 1032159047fSniklas * 1042159047fSniklas * which is separated by only three bytes, thus HASHFRACTION is 1052159047fSniklas * calculated as: 1062159047fSniklas * 1072159047fSniklas * HASHFRACTION = 3 / (2 * 2 - 1) = 1 1082159047fSniklas * 1092159047fSniklas * Note that the division above rounds down, thus if MIN_SUBR_FRACTION 1102159047fSniklas * is less than three, this algorithm will not work! 1112159047fSniklas */ 1122159047fSniklas #define HASHFRACTION 1 1132159047fSniklas 1142159047fSniklas /* 1152159047fSniklas * Percent of text space to allocate for tostructs with a minimum: 1162159047fSniklas */ 1172159047fSniklas #define ARCDENSITY 2 1182159047fSniklas #define MINARCS 50 1192159047fSniklas 1202159047fSniklas struct tostruct 1212159047fSniklas { 1222159047fSniklas char *selfpc; 1232159047fSniklas int count; 1242159047fSniklas unsigned short link; 1252159047fSniklas }; 1262159047fSniklas 1272159047fSniklas /* 1282159047fSniklas * A raw arc, with pointers to the calling site and the called site 1292159047fSniklas * and a count. Everything is defined in terms of characters so 1302159047fSniklas * as to get a packed representation (otherwise, different compilers 1312159047fSniklas * might introduce different padding): 1322159047fSniklas */ 133*c074d1c9Sdrahn #if 0 /* For documentation purposes only. */ 1342159047fSniklas struct raw_arc 1352159047fSniklas { 136*c074d1c9Sdrahn char from_pc[sizeof(void *)]; 137*c074d1c9Sdrahn char self_pc[sizeof(void *)]; 138*c074d1c9Sdrahn char count[sizeof(long)]; 1392159047fSniklas }; 140*c074d1c9Sdrahn #endif 1412159047fSniklas 1422159047fSniklas /* 1432159047fSniklas * General rounding functions: 1442159047fSniklas */ 1452159047fSniklas #define ROUNDDOWN(x,y) (((x)/(y))*(y)) 1462159047fSniklas #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) 1472159047fSniklas 1482159047fSniklas #endif /* gmon_h */ 149