Blame gmon/sys/gmon.h

Packit 6c4009
/*-
Packit 6c4009
 * Copyright (c) 1982, 1986, 1992, 1993
Packit 6c4009
 *	The Regents of the University of California.  All rights reserved.
Packit 6c4009
 *
Packit 6c4009
 * Redistribution and use in source and binary forms, with or without
Packit 6c4009
 * modification, are permitted provided that the following conditions
Packit 6c4009
 * are met:
Packit 6c4009
 * 1. Redistributions of source code must retain the above copyright
Packit 6c4009
 *    notice, this list of conditions and the following disclaimer.
Packit 6c4009
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 6c4009
 *    notice, this list of conditions and the following disclaimer in the
Packit 6c4009
 *    documentation and/or other materials provided with the distribution.
Packit 6c4009
 * 4. Neither the name of the University nor the names of its contributors
Packit 6c4009
 *    may be used to endorse or promote products derived from this software
Packit 6c4009
 *    without specific prior written permission.
Packit 6c4009
 *
Packit 6c4009
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
Packit 6c4009
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 6c4009
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 6c4009
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
Packit 6c4009
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6c4009
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 6c4009
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 6c4009
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 6c4009
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 6c4009
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 6c4009
 * SUCH DAMAGE.
Packit 6c4009
 *
Packit 6c4009
 *	@(#)gmon.h	8.2 (Berkeley) 1/4/94
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#ifndef	_SYS_GMON_H
Packit 6c4009
#define	_SYS_GMON_H	1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
Packit 6c4009
#include <sys/types.h>
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * See gmon_out.h for gmon.out format.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/* structure emitted by "gcc -a".  This must match struct bb in
Packit 6c4009
   gcc/libgcc2.c.  It is OK for gcc to declare a longer structure as
Packit 6c4009
   long as the members below are present.  */
Packit 6c4009
struct __bb
Packit 6c4009
{
Packit 6c4009
  long			zero_word;
Packit 6c4009
  const char		*filename;
Packit 6c4009
  long			*counts;
Packit 6c4009
  long			ncounts;
Packit 6c4009
  struct __bb		*next;
Packit 6c4009
  const unsigned long	*addresses;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
extern struct __bb *__bb_head;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * histogram counters are unsigned shorts (according to the kernel).
Packit 6c4009
 */
Packit 6c4009
#define	HISTCOUNTER	unsigned short
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * fraction of text space to allocate for histogram counters here, 1/2
Packit 6c4009
 */
Packit 6c4009
#define	HISTFRACTION	2
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Fraction of text space to allocate for from hash buckets.
Packit 6c4009
 * The value of HASHFRACTION is based on the minimum number of bytes
Packit 6c4009
 * of separation between two subroutine call points in the object code.
Packit 6c4009
 * Given MIN_SUBR_SEPARATION bytes of separation the value of
Packit 6c4009
 * HASHFRACTION is calculated as:
Packit 6c4009
 *
Packit 6c4009
 *	HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
Packit 6c4009
 *
Packit 6c4009
 * For example, on the VAX, the shortest two call sequence is:
Packit 6c4009
 *
Packit 6c4009
 *	calls	$0,(r0)
Packit 6c4009
 *	calls	$0,(r0)
Packit 6c4009
 *
Packit 6c4009
 * which is separated by only three bytes, thus HASHFRACTION is
Packit 6c4009
 * calculated as:
Packit 6c4009
 *
Packit 6c4009
 *	HASHFRACTION = 3 / (2 * 2 - 1) = 1
Packit 6c4009
 *
Packit 6c4009
 * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
Packit 6c4009
 * is less than three, this algorithm will not work!
Packit 6c4009
 *
Packit 6c4009
 * In practice, however, call instructions are rarely at a minimal
Packit 6c4009
 * distance.  Hence, we will define HASHFRACTION to be 2 across all
Packit 6c4009
 * architectures.  This saves a reasonable amount of space for
Packit 6c4009
 * profiling data structures without (in practice) sacrificing
Packit 6c4009
 * any granularity.
Packit 6c4009
 */
Packit 6c4009
#define	HASHFRACTION	2
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Percent of text space to allocate for tostructs.
Packit 6c4009
 * This is a heuristic; we will fail with a warning when profiling programs
Packit 6c4009
 * with a very large number of very small functions, but that's
Packit 6c4009
 * normally OK.
Packit 6c4009
 * 2 is probably still a good value for normal programs.
Packit 6c4009
 * Profiling a test case with 64000 small functions will work if
Packit 6c4009
 * you raise this value to 3 and link statically (which bloats the
Packit 6c4009
 * text size, thus raising the number of arcs expected by the heuristic).
Packit 6c4009
 */
Packit 6c4009
#define ARCDENSITY	3
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Always allocate at least this many tostructs.  This
Packit 6c4009
 * hides the inadequacy of the ARCDENSITY heuristic, at least
Packit 6c4009
 * for small programs.
Packit 6c4009
 */
Packit 6c4009
#define MINARCS		50
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * The type used to represent indices into gmonparam.tos[].
Packit 6c4009
 */
Packit 6c4009
#define	ARCINDEX	unsigned long
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Maximum number of arcs we want to allow.
Packit 6c4009
 * Used to be max representable value of ARCINDEX minus 2, but now
Packit 6c4009
 * that ARCINDEX is a long, that's too large; we don't really want
Packit 6c4009
 * to allow a 48 gigabyte table.
Packit 6c4009
 * The old value of 1<<16 wasn't high enough in practice for large C++
Packit 6c4009
 * programs; will 1<<20 be adequate for long?  FIXME
Packit 6c4009
 */
Packit 6c4009
#define MAXARCS		(1 << 20)
Packit 6c4009
Packit 6c4009
struct tostruct {
Packit 6c4009
	unsigned long	selfpc;
Packit 6c4009
	long		count;
Packit 6c4009
	ARCINDEX	link;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * a raw arc, with pointers to the calling site and
Packit 6c4009
 * the called site and a count.
Packit 6c4009
 */
Packit 6c4009
struct rawarc {
Packit 6c4009
	unsigned long	raw_frompc;
Packit 6c4009
	unsigned long	raw_selfpc;
Packit 6c4009
	long		raw_count;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * general rounding functions.
Packit 6c4009
 */
Packit 6c4009
#define ROUNDDOWN(x,y)	(((x)/(y))*(y))
Packit 6c4009
#define ROUNDUP(x,y)	((((x)+(y)-1)/(y))*(y))
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * The profiling data structures are housed in this structure.
Packit 6c4009
 */
Packit 6c4009
struct gmonparam {
Packit 6c4009
	long int	state;
Packit 6c4009
	unsigned short	*kcount;
Packit 6c4009
	unsigned long	kcountsize;
Packit 6c4009
	ARCINDEX	*froms;
Packit 6c4009
	unsigned long	fromssize;
Packit 6c4009
	struct tostruct	*tos;
Packit 6c4009
	unsigned long	tossize;
Packit 6c4009
	long		tolimit;
Packit 6c4009
	unsigned long	lowpc;
Packit 6c4009
	unsigned long	highpc;
Packit 6c4009
	unsigned long	textsize;
Packit 6c4009
	unsigned long	hashfraction;
Packit 6c4009
	long		log_hashfraction;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Possible states of profiling.
Packit 6c4009
 */
Packit 6c4009
#define	GMON_PROF_ON	0
Packit 6c4009
#define	GMON_PROF_BUSY	1
Packit 6c4009
#define	GMON_PROF_ERROR	2
Packit 6c4009
#define	GMON_PROF_OFF	3
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Sysctl definitions for extracting profiling information from the kernel.
Packit 6c4009
 */
Packit 6c4009
#define	GPROF_STATE	0	/* int: profiling enabling variable */
Packit 6c4009
#define	GPROF_COUNT	1	/* struct: profile tick count buffer */
Packit 6c4009
#define	GPROF_FROMS	2	/* struct: from location hash bucket */
Packit 6c4009
#define	GPROF_TOS	3	/* struct: destination/count structure */
Packit 6c4009
#define	GPROF_GMONPARAM	4	/* struct: profiling parameters (see above) */
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Set up data structures and start profiling.  */
Packit 6c4009
extern void __monstartup (unsigned long __lowpc, unsigned long __highpc) __THROW;
Packit 6c4009
extern void monstartup (unsigned long __lowpc, unsigned long __highpc) __THROW;
Packit 6c4009
Packit 6c4009
/* Clean up profiling and write out gmon.out.  */
Packit 6c4009
extern void _mcleanup (void) __THROW;
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* sys/gmon.h */