Reverting merge from trunk
[official-gcc.git] / libgcc / config / arc / gmon / sys / gmon.h
blob0317113628194abe72ad75d617997afd076a1d23
1 /*-
2 * Copyright (c) 1982, 1986, 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (C) 2007-2013 Free Software Foundation, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 4. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
30 * @(#)gmon.h 8.2 (Berkeley) 1/4/94
33 #ifndef _SYS_GMON_H
34 #define _SYS_GMON_H 1
36 #if 0
37 #include <features.h>
38 #include <sys/types.h>
39 #else
40 #include <sys/types.h>
41 #include "machine-gmon.h"
42 #define attribute_hidden __attribute__ ((visibility("hidden")))
43 #endif
45 #include <stdint.h>
48 * See gmon_out.h for gmon.out format.
51 /* structure emitted by "gcc -a". This must match struct bb in
52 gcc/libgcc2.c. It is OK for gcc to declare a longer structure as
53 long as the members below are present. */
54 struct __bb
56 long zero_word;
57 const char *filename;
58 long *counts;
59 long ncounts;
60 struct __bb *next;
61 const unsigned long *addresses;
64 extern struct __bb *__bb_head;
67 * histogram counters are unsigned shorts (according to the kernel).
69 #define HISTCOUNTER unsigned short
72 * fraction of text space to allocate for histogram counters here, 1/2
74 #define HISTFRACTION 2
77 * Fraction of text space to allocate for from hash buckets.
78 * The value of HASHFRACTION is based on the minimum number of bytes
79 * of separation between two subroutine call points in the object code.
80 * Given MIN_SUBR_SEPARATION bytes of separation the value of
81 * HASHFRACTION is calculated as:
83 * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
85 * For example, on the VAX, the shortest two call sequence is:
87 * calls $0,(r0)
88 * calls $0,(r0)
90 * which is separated by only three bytes, thus HASHFRACTION is
91 * calculated as:
93 * HASHFRACTION = 3 / (2 * 2 - 1) = 1
95 * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
96 * is less than three, this algorithm will not work!
98 * In practice, however, call instructions are rarely at a minimal
99 * distance. Hence, we will define HASHFRACTION to be 2 across all
100 * architectures. This saves a reasonable amount of space for
101 * profiling data structures without (in practice) sacrificing
102 * any granularity.
104 #define HASHFRACTION 2
107 * Percent of text space to allocate for tostructs.
108 * This is a heuristic; we will fail with a warning when profiling programs
109 * with a very large number of very small functions, but that's
110 * normally OK.
111 * 2 is probably still a good value for normal programs.
112 * Profiling a test case with 64000 small functions will work if
113 * you raise this value to 3 and link statically (which bloats the
114 * text size, thus raising the number of arcs expected by the heuristic).
116 #define ARCDENSITY 3
119 * Always allocate at least this many tostructs. This
120 * hides the inadequacy of the ARCDENSITY heuristic, at least
121 * for small programs.
123 #define MINARCS 50
126 * The type used to represent indices into gmonparam.tos[].
128 #define ARCINDEX u_long
131 * Maximum number of arcs we want to allow.
132 * Used to be max representable value of ARCINDEX minus 2, but now
133 * that ARCINDEX is a long, that's too large; we don't really want
134 * to allow a 48 gigabyte table.
135 * The old value of 1<<16 wasn't high enough in practice for large C++
136 * programs; will 1<<20 be adequate for long? FIXME
138 #define MAXARCS (1 << 20)
140 struct tostruct {
141 u_long selfpc;
142 long count;
143 ARCINDEX link;
147 * a raw arc, with pointers to the calling site and
148 * the called site and a count.
150 struct rawarc {
151 u_long raw_frompc;
152 u_long raw_selfpc;
153 long raw_count;
157 * general rounding functions.
159 #define ROUNDDOWN(x,y) (((x)/(y))*(y))
160 #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
163 * The profiling data structures are housed in this structure.
165 struct gmonparam {
166 long int state;
167 u_short *kcount;
168 u_long kcountsize;
169 ARCINDEX *froms;
170 u_long fromssize;
171 struct tostruct *tos;
172 u_long tossize;
173 long tolimit;
174 u_long lowpc;
175 u_long highpc;
176 u_long textsize;
177 u_long hashfraction;
178 long log_hashfraction;
180 extern struct gmonparam _gmonparam;
183 * Possible states of profiling.
185 #define GMON_PROF_ON 0
186 #define GMON_PROF_BUSY 1
187 #define GMON_PROF_ERROR 2
188 #define GMON_PROF_OFF 3
191 * Sysctl definitions for extracting profiling information from the kernel.
193 #define GPROF_STATE 0 /* int: profiling enabling variable */
194 #define GPROF_COUNT 1 /* struct: profile tick count buffer */
195 #define GPROF_FROMS 2 /* struct: from location hash bucket */
196 #define GPROF_TOS 3 /* struct: destination/count structure */
197 #define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */
199 __BEGIN_DECLS
201 /* Set up data structures and start profiling. */
202 extern void __monstartup (u_long __lowpc, u_long __highpc) __THROW;
203 extern void monstartup (u_long __lowpc, u_long __highpc) __THROW;
205 /* Clean up profiling and write out gmon.out. */
206 extern void _mcleanup (void) __THROW;
208 extern void __write_profiling (void);
209 extern int attribute_hidden __profile_frequency (void);
211 extern u_long __arc_profile_desc_secstart[], __arc_profile_desc_secend[];
212 extern u_long __arc_profile_forward_secstart[], __arc_profile_forward_secend[];
213 extern u_long __arc_profile_counters_secstart[];
215 __END_DECLS
217 #endif /* sys/gmon.h */