xref: /titanic_41/usr/src/cmd/sgs/include/profile.h (revision e0ddff35438f277370a2eae5c6718cd5ba0fe3ab)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*e0ddff35Sab196087  *	Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  *	Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_PROFILE_H
287c478bd9Sstevel@tonic-gate #define	_PROFILE_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifndef	_ASM
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <synch.h>
407c478bd9Sstevel@tonic-gate #include <link.h>
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * The profile buffer created by ld.so.1 consists of 3 sections; the header,
447c478bd9Sstevel@tonic-gate  * the profil(2) buffer, and an array of call graph arc structures.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate typedef struct l_hdr {			/* Linker profile buffer header */
487c478bd9Sstevel@tonic-gate 	unsigned int	hd_magic;	/* identifier for file */
497c478bd9Sstevel@tonic-gate 	unsigned int	hd_version;	/* version for rtld prof file */
507c478bd9Sstevel@tonic-gate 	lwp_mutex_t	hd_mutex;	/* Provides for process locking */
517c478bd9Sstevel@tonic-gate 	caddr_t		hd_hpc;		/* Relative high pc address */
527c478bd9Sstevel@tonic-gate 	unsigned int	hd_psize;	/* Size of profil(2) buffer */
537c478bd9Sstevel@tonic-gate 	unsigned int	hd_fsize;	/* Size of file */
547c478bd9Sstevel@tonic-gate 	unsigned int	hd_ncndx;	/* Next (and last) index into */
557c478bd9Sstevel@tonic-gate 	unsigned int	hd_lcndx;	/*	call graph arc structure */
567c478bd9Sstevel@tonic-gate } L_hdr;
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * The *64 structs are for gprof, as a 32-bit program,
617c478bd9Sstevel@tonic-gate  * to read 64-bit profiles correctly.
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate typedef struct l_hdr64 {		/* Linker profile buffer header */
657c478bd9Sstevel@tonic-gate 	unsigned int	hd_magic;	/* identifier for file */
667c478bd9Sstevel@tonic-gate 	unsigned int	hd_version;	/* version for rtld prof file */
677c478bd9Sstevel@tonic-gate 	lwp_mutex_t	hd_mutex;	/* Provides for process locking */
687c478bd9Sstevel@tonic-gate 	u_longlong_t	hd_hpc;		/* Relative high pc address */
697c478bd9Sstevel@tonic-gate 	unsigned int	hd_psize;	/* Size of profil(2) buffer */
707c478bd9Sstevel@tonic-gate 	unsigned int	hd_fsize;	/* Size of file */
717c478bd9Sstevel@tonic-gate 	unsigned int	hd_ncndx;	/* Next (and last) index into */
727c478bd9Sstevel@tonic-gate 	unsigned int	hd_lcndx;	/*	call graph arc structure */
737c478bd9Sstevel@tonic-gate } L_hdr64;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate typedef struct l_cgarc {		/* Linker call graph arc entry */
787c478bd9Sstevel@tonic-gate 	caddr_t		cg_from;	/* Source of call */
797c478bd9Sstevel@tonic-gate 	caddr_t		cg_to;		/* Destination of call */
807c478bd9Sstevel@tonic-gate 	unsigned int	cg_count;	/* Instance count */
817c478bd9Sstevel@tonic-gate 	unsigned int	cg_next;	/* Link index for multiple sources */
827c478bd9Sstevel@tonic-gate } L_cgarc;
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate typedef struct l_cgarc64 {		/* Linker call graph arc entry */
867c478bd9Sstevel@tonic-gate 	u_longlong_t	cg_from;	/* Source of call */
877c478bd9Sstevel@tonic-gate 	u_longlong_t	cg_to;		/* Destination of call */
887c478bd9Sstevel@tonic-gate 	unsigned int	cg_count;	/* Instance count */
897c478bd9Sstevel@tonic-gate 	unsigned int	cg_next;	/* Link index for multiple sources */
907c478bd9Sstevel@tonic-gate } L_cgarc64;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /*
957c478bd9Sstevel@tonic-gate  * Generic defines for creating profiled output buffer.
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #define	PRF_BARSIZE	2		/* No. of program bytes that */
997c478bd9Sstevel@tonic-gate 					/* correspond to each histogram */
1007c478bd9Sstevel@tonic-gate 					/* bar in the profil(2) buffer */
1017c478bd9Sstevel@tonic-gate #define	PRF_SCALE	0x8000		/* Scale to provide above */
1027c478bd9Sstevel@tonic-gate 					/* histogram correspondence */
1037c478bd9Sstevel@tonic-gate #define	PRF_CGNUMB	256		/* Size of call graph extension */
1047c478bd9Sstevel@tonic-gate #define	PRF_CGINIT	2		/* Initial symbol blocks to allocate */
1057c478bd9Sstevel@tonic-gate 					/*	for the call graph structure */
1067c478bd9Sstevel@tonic-gate #define	PRF_OUTADDR	(caddr_t)-1	/* Function addresses outside of */
1077c478bd9Sstevel@tonic-gate 					/*	the range being monitored */
1087c478bd9Sstevel@tonic-gate #define	PRF_OUTADDR64	(u_longlong_t)-1	/* Function addresses outside */
1097c478bd9Sstevel@tonic-gate 					/*	of the range being monitored */
1107c478bd9Sstevel@tonic-gate #define	PRF_UNKNOWN	(caddr_t)-2	/* Unknown function address */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #define	PRF_ROUNDUP(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
1137c478bd9Sstevel@tonic-gate #define	PRF_ROUNDWN(x, a) ((x) & ~((a) - 1))
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	PRF_MAGIC	0xffffffff	/* unique number to differentiate */
1167c478bd9Sstevel@tonic-gate 					/* profiled file from gmon.out for */
1177c478bd9Sstevel@tonic-gate 					/* gprof */
1187c478bd9Sstevel@tonic-gate #define	PRF_VERSION	0x1		/* current PROF file version */
1197c478bd9Sstevel@tonic-gate #define	PRF_VERSION_64	0x2		/* 64-bit current PROF file version */
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * Related data and function definitions.
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate extern	int		profile_rtld;		/* Rtld is being profiled */
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate extern	uintptr_t (*	p_cg_interp)(int, caddr_t, caddr_t);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #endif
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate #endif
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #endif /* _PROFILE_H */
137