gmon.h (10407) | gmon.h (13107) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)gmon.h 8.2 (Berkeley) 1/4/94 | 1/*- 2 * Copyright (c) 1982, 1986, 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)gmon.h 8.2 (Berkeley) 1/4/94 |
34 * $Id: gmon.h,v 1.6 1995/05/30 08:14:22 rgrimes Exp $ | 34 * $Id: gmon.h,v 1.7 1995/08/29 03:09:14 bde Exp $ |
35 */ 36 37#ifndef _SYS_GMON_H_ 38#define _SYS_GMON_H_ 39 40#include <machine/profile.h> 41 42/* 43 * Structure prepended to gmon.out profiling data file. 44 */ 45struct gmonhdr { 46 u_long lpc; /* base pc address of sample buffer */ 47 u_long hpc; /* max pc address of sampled buffer */ 48 int ncnt; /* size of sample buffer (plus this header) */ 49 int version; /* version number */ 50 int profrate; /* profiling clock rate */ 51 int spare[3]; /* reserved */ | 35 */ 36 37#ifndef _SYS_GMON_H_ 38#define _SYS_GMON_H_ 39 40#include <machine/profile.h> 41 42/* 43 * Structure prepended to gmon.out profiling data file. 44 */ 45struct gmonhdr { 46 u_long lpc; /* base pc address of sample buffer */ 47 u_long hpc; /* max pc address of sampled buffer */ 48 int ncnt; /* size of sample buffer (plus this header) */ 49 int version; /* version number */ 50 int profrate; /* profiling clock rate */ 51 int spare[3]; /* reserved */ |
52 /* XXX should record counter size and density */ |
|
52}; 53#define GMONVERSION 0x00051879 54 55/* | 53}; 54#define GMONVERSION 0x00051879 55 56/* |
56 * histogram counters are unsigned shorts (according to the kernel). | 57 * Type of histogram counters used in the kernel. |
57 */ | 58 */ |
59#ifdef GPROF4 60#define HISTCOUNTER unsigned 61#else |
|
58#define HISTCOUNTER unsigned short | 62#define HISTCOUNTER unsigned short |
63#endif |
|
59 60/* | 64 65/* |
61 * fraction of text space to allocate for histogram counters here, 1/2 | 66 * Fraction of text space to allocate for histogram counters. 67 * We allocate counters at the same or higher density as function 68 * addresses, so that each counter belongs to a unique function. 69 * A lower density of counters would give less resolution but a 70 * higher density would be wasted. 71 * 72 * Assume that function addresses are at least 4-byte-aligned. 73 * It would be better to get the linker to align functions more 74 * strictly so that we could use smaller tables. |
62 */ | 75 */ |
63#define HISTFRACTION 2 | 76#define FUNCTION_ALIGNMENT 4 77#define HISTFRACTION (FUNCTION_ALIGNMENT / sizeof(HISTCOUNTER) == 0 \ 78 ? 1 : FUNCTION_ALIGNMENT / sizeof(HISTCOUNTER)) |
64 65/* 66 * Fraction of text space to allocate for from hash buckets. 67 * The value of HASHFRACTION is based on the minimum number of bytes 68 * of separation between two subroutine call points in the object code. 69 * Given MIN_SUBR_SEPARATION bytes of separation the value of 70 * HASHFRACTION is calculated as: 71 * --- 13 unchanged lines hidden (view full) --- 85 * is less than three, this algorithm will not work! 86 * 87 * In practice, however, call instructions are rarely at a minimal 88 * distance. Hence, we will define HASHFRACTION to be 2 across all 89 * architectures. This saves a reasonable amount of space for 90 * profiling data structures without (in practice) sacrificing 91 * any granularity. 92 */ | 79 80/* 81 * Fraction of text space to allocate for from hash buckets. 82 * The value of HASHFRACTION is based on the minimum number of bytes 83 * of separation between two subroutine call points in the object code. 84 * Given MIN_SUBR_SEPARATION bytes of separation the value of 85 * HASHFRACTION is calculated as: 86 * --- 13 unchanged lines hidden (view full) --- 100 * is less than three, this algorithm will not work! 101 * 102 * In practice, however, call instructions are rarely at a minimal 103 * distance. Hence, we will define HASHFRACTION to be 2 across all 104 * architectures. This saves a reasonable amount of space for 105 * profiling data structures without (in practice) sacrificing 106 * any granularity. 107 */ |
93#define HASHFRACTION 2 | 108/* 109 * XXX I think the above analysis completely misses the point. I think 110 * the point is that addresses in different functions must hash to 111 * different values. Since the hash is essentially division by 112 * sizeof(unsigned short), the correct formula is: 113 * 114 * HASHFRACTION = MIN_FUNCTION_ALIGNMENT / sizeof(unsigned short) 115 * 116 * Note that he unsigned short here has nothing to do with the one for 117 * HISTFRACTION. 118 * 119 * Hash collisions from a two call sequence don't matter. They get 120 * handled like collisions for calls to different addresses from the 121 * same address through a function pointer. 122 */ 123#define HASHFRACTION (FUNCTION_ALIGNMENT / sizeof(unsigned short) == 0 \ 124 ? 1 : FUNCTION_ALIGNMENT / sizeof(unsigned short)) |
94 95/* 96 * percent of text space to allocate for tostructs with a minimum. 97 */ 98#define ARCDENSITY 2 99#define MINARCS 50 100 101/* --- 25 unchanged lines hidden (view full) --- 127#define ROUNDDOWN(x,y) rounddown(x,y) 128#define ROUNDUP(x,y) roundup(x,y) 129 130/* 131 * The profiling data structures are housed in this structure. 132 */ 133struct gmonparam { 134 int state; | 125 126/* 127 * percent of text space to allocate for tostructs with a minimum. 128 */ 129#define ARCDENSITY 2 130#define MINARCS 50 131 132/* --- 25 unchanged lines hidden (view full) --- 158#define ROUNDDOWN(x,y) rounddown(x,y) 159#define ROUNDUP(x,y) roundup(x,y) 160 161/* 162 * The profiling data structures are housed in this structure. 163 */ 164struct gmonparam { 165 int state; |
135 u_short *kcount; | 166 HISTCOUNTER *kcount; |
136 u_long kcountsize; 137 u_short *froms; 138 u_long fromssize; 139 struct tostruct *tos; 140 u_long tossize; 141 long tolimit; | 167 u_long kcountsize; 168 u_short *froms; 169 u_long fromssize; 170 struct tostruct *tos; 171 u_long tossize; 172 long tolimit; |
142 u_long lowpc; 143 u_long highpc; | 173 fptrint_t lowpc; 174 fptrint_t highpc; |
144 u_long textsize; 145 u_long hashfraction; | 175 u_long textsize; 176 u_long hashfraction; |
177 u_long profrate; 178 HISTCOUNTER *cputime_count; 179 u_int cputime_overhead; 180 u_int cputime_overhead_frac; 181 u_int cputime_overhead_resid; 182 u_int cputime_overhead_sub; 183 HISTCOUNTER *mcount_count; 184 u_int mcount_overhead; 185 u_int mcount_overhead_frac; 186 u_int mcount_overhead_resid; 187 u_int mcount_overhead_sub; 188 HISTCOUNTER *mexitcount_count; 189 u_int mexitcount_overhead; 190 u_int mexitcount_overhead_frac; 191 u_int mexitcount_overhead_resid; 192 u_int mexitcount_overhead_sub; |
|
146}; 147extern struct gmonparam _gmonparam; 148 149/* 150 * Possible states of profiling. 151 */ 152#define GMON_PROF_ON 0 153#define GMON_PROF_BUSY 1 154#define GMON_PROF_ERROR 2 155#define GMON_PROF_OFF 3 | 193}; 194extern struct gmonparam _gmonparam; 195 196/* 197 * Possible states of profiling. 198 */ 199#define GMON_PROF_ON 0 200#define GMON_PROF_BUSY 1 201#define GMON_PROF_ERROR 2 202#define GMON_PROF_OFF 3 |
203#define GMON_PROF_HIRES 4 |
|
156 157/* 158 * Sysctl definitions for extracting profiling information from the kernel. 159 */ 160#define GPROF_STATE 0 /* int: profiling enabling variable */ 161#define GPROF_COUNT 1 /* struct: profile tick count buffer */ 162#define GPROF_FROMS 2 /* struct: from location hash bucket */ 163#define GPROF_TOS 3 /* struct: destination/count structure */ 164#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */ 165 166#endif /* !_SYS_GMON_H_ */ | 204 205/* 206 * Sysctl definitions for extracting profiling information from the kernel. 207 */ 208#define GPROF_STATE 0 /* int: profiling enabling variable */ 209#define GPROF_COUNT 1 /* struct: profile tick count buffer */ 210#define GPROF_FROMS 2 /* struct: from location hash bucket */ 211#define GPROF_TOS 3 /* struct: destination/count structure */ 212#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */ 213 214#endif /* !_SYS_GMON_H_ */ |