The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/sys/gmon.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: e04e603837248c3fecd3e1a9b9bfd3ca


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.