Annotation of XNU/bsd/sys/gmon.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
        !            23: /*-
        !            24:  * Copyright (c) 1982, 1986, 1992, 1993
        !            25:  *     The Regents of the University of California.  All rights reserved.
        !            26:  *
        !            27:  * Redistribution and use in source and binary forms, with or without
        !            28:  * modification, are permitted provided that the following conditions
        !            29:  * are met:
        !            30:  * 1. Redistributions of source code must retain the above copyright
        !            31:  *    notice, this list of conditions and the following disclaimer.
        !            32:  * 2. Redistributions in binary form must reproduce the above copyright
        !            33:  *    notice, this list of conditions and the following disclaimer in the
        !            34:  *    documentation and/or other materials provided with the distribution.
        !            35:  * 3. All advertising materials mentioning features or use of this software
        !            36:  *    must display the following acknowledgement:
        !            37:  *     This product includes software developed by the University of
        !            38:  *     California, Berkeley and its contributors.
        !            39:  * 4. Neither the name of the University nor the names of its contributors
        !            40:  *    may be used to endorse or promote products derived from this software
        !            41:  *    without specific prior written permission.
        !            42:  *
        !            43:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            44:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            45:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            46:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            47:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            48:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            49:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            50:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            51:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            52:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            53:  * SUCH DAMAGE.
        !            54:  *
        !            55:  *     @(#)gmon.h      8.2 (Berkeley) 1/4/94
        !            56:  */
        !            57: 
        !            58: #ifndef _SYS_GMON_H_
        !            59: #define _SYS_GMON_H_
        !            60: 
        !            61: /*
        !            62:  * Structure prepended to gmon.out profiling data file.
        !            63:  */
        !            64: struct gmonhdr {
        !            65:        u_long  lpc;            /* base pc address of sample buffer */
        !            66:        u_long  hpc;            /* max pc address of sampled buffer */
        !            67:        int     ncnt;           /* size of sample buffer (plus this header) */
        !            68:        int     version;        /* version number */
        !            69:        int     profrate;       /* profiling clock rate */
        !            70:        int     spare[3];       /* reserved */
        !            71: };
        !            72: #define GMONVERSION    0x00051879
        !            73: 
        !            74: /*
        !            75:  * histogram counters are unsigned shorts (according to the kernel).
        !            76:  */
        !            77: #define        HISTCOUNTER     unsigned short
        !            78: 
        !            79: /*
        !            80:  * fraction of text space to allocate for histogram counters here, 1/2
        !            81:  */
        !            82: #define        HISTFRACTION    2
        !            83: 
        !            84: /*
        !            85:  * Fraction of text space to allocate for from hash buckets.
        !            86:  * The value of HASHFRACTION is based on the minimum number of bytes
        !            87:  * of separation between two subroutine call points in the object code.
        !            88:  * Given MIN_SUBR_SEPARATION bytes of separation the value of
        !            89:  * HASHFRACTION is calculated as:
        !            90:  *
        !            91:  *     HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
        !            92:  *
        !            93:  * For example, on the VAX, the shortest two call sequence is:
        !            94:  *
        !            95:  *     calls   $0,(r0)
        !            96:  *     calls   $0,(r0)
        !            97:  *
        !            98:  * which is separated by only three bytes, thus HASHFRACTION is 
        !            99:  * calculated as:
        !           100:  *
        !           101:  *     HASHFRACTION = 3 / (2 * 2 - 1) = 1
        !           102:  *
        !           103:  * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
        !           104:  * is less than three, this algorithm will not work!
        !           105:  *
        !           106:  * In practice, however, call instructions are rarely at a minimal 
        !           107:  * distance.  Hence, we will define HASHFRACTION to be 2 across all
        !           108:  * architectures.  This saves a reasonable amount of space for 
        !           109:  * profiling data structures without (in practice) sacrificing
        !           110:  * any granularity.
        !           111:  */
        !           112: #define        HASHFRACTION    2
        !           113: 
        !           114: /*
        !           115:  * percent of text space to allocate for tostructs with a minimum.
        !           116:  */
        !           117: #define ARCDENSITY     2
        !           118: #define MINARCS                50
        !           119: #define MAXARCS                ((1 << (8 * sizeof(HISTCOUNTER))) - 2)
        !           120: 
        !           121: struct tostruct {
        !           122:        u_long  selfpc;
        !           123:        long    count;
        !           124:        u_short link;
        !           125:        u_short order;
        !           126: };
        !           127: 
        !           128: /*
        !           129:  * a raw arc, with pointers to the calling site and 
        !           130:  * the called site and a count.
        !           131:  */
        !           132: struct rawarc {
        !           133:        u_long  raw_frompc;
        !           134:        u_long  raw_selfpc;
        !           135:        long    raw_count;
        !           136: };
        !           137: 
        !           138: /*
        !           139:  * general rounding functions.
        !           140:  */
        !           141: #define ROUNDDOWN(x,y) (((x)/(y))*(y))
        !           142: #define ROUNDUP(x,y)   ((((x)+(y)-1)/(y))*(y))
        !           143: 
        !           144: /*
        !           145:  * The profiling data structures are housed in this structure.
        !           146:  */
        !           147: struct gmonparam {
        !           148:        int             state;
        !           149:        u_short         *kcount;
        !           150:        u_long          kcountsize;
        !           151:        u_short         *froms;
        !           152:        u_long          fromssize;
        !           153:        struct tostruct *tos;
        !           154:        u_long          tossize;
        !           155:        long            tolimit;
        !           156:        u_long          lowpc;
        !           157:        u_long          highpc;
        !           158:        u_long          textsize;
        !           159:        u_long          hashfraction;
        !           160: };
        !           161: extern struct gmonparam _gmonparam;
        !           162: 
        !           163: /*
        !           164:  * Possible states of profiling.
        !           165:  */
        !           166: #define        GMON_PROF_ON    0
        !           167: #define        GMON_PROF_BUSY  1
        !           168: #define        GMON_PROF_ERROR 2
        !           169: #define        GMON_PROF_OFF   3
        !           170: 
        !           171: /*
        !           172:  * Sysctl definitions for extracting profiling information from the kernel.
        !           173:  */
        !           174: #define        GPROF_STATE     0       /* int: profiling enabling variable */
        !           175: #define        GPROF_COUNT     1       /* struct: profile tick count buffer */
        !           176: #define        GPROF_FROMS     2       /* struct: from location hash bucket */
        !           177: #define        GPROF_TOS       3       /* struct: destination/count structure */
        !           178: #define        GPROF_GMONPARAM 4       /* struct: profiling parameters (see above) */
        !           179: 
        !           180: /*
        !           181:  * In order to support more information than in the original mon.out and
        !           182:  * gmon.out files there is an alternate gmon.out file format.  The alternate
        !           183:  * gmon.out file format starts with a magic number then separates the
        !           184:  * information with gmon_data structs.
        !           185:  */
        !           186: #define GMON_MAGIC 0xbeefbabe
        !           187: struct gmon_data {
        !           188:     unsigned long type; /* constant for type of data following this struct */
        !           189:     unsigned long size; /* size in bytes of the data following this struct */
        !           190: };
        !           191: 
        !           192: /*
        !           193:  * The GMONTYPE_SAMPLES gmon_data.type is for the histogram counters described
        !           194:  * above and has a struct gmonhdr followed by the counters.
        !           195:  */
        !           196: #define GMONTYPE_SAMPLES       1
        !           197: /*
        !           198:  * The GMONTYPE_RAWARCS gmon_data.type is for the raw arcs described above.
        !           199:  */
        !           200: #define GMONTYPE_RAWARCS       2
        !           201: /*
        !           202:  * The GMONTYPE_ARCS_ORDERS gmon_data.type is for the raw arcs with a call
        !           203:  * order field.  The order is the order is a sequence number for the order each
        !           204:  * call site was executed.  Raw_order values start at 1 not zero.  Other than
        !           205:  * the raw_order field this is the same information as in the struct rawarc.
        !           206:  */
        !           207: #define GMONTYPE_ARCS_ORDERS   3
        !           208: struct rawarc_order {
        !           209:     unsigned long      raw_frompc;
        !           210:     unsigned long      raw_selfpc;
        !           211:     unsigned long      raw_count;
        !           212:     unsigned long      raw_order;
        !           213: };
        !           214: /*
        !           215:  * The GMONTYPE_DYLD_STATE gmon_data.type is for the dynamic link editor state
        !           216:  * of the program.
        !           217:  * The informations starts with an unsigned long with the count of states:
        !           218:  *      image_count
        !           219:  * Then each state follows in the file.  The state is made up of 
        !           220:  *      image_header (the address where dyld loaded this image)
        !           221:  *      vmaddr_slide (the amount dyld slid this image from it's vmaddress)
        !           222:  *      name (the file name dyld loaded this image from)
        !           223:  */
        !           224: #define GMONTYPE_DYLD_STATE     4
        !           225: #endif /* !_SYS_GMON_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.