10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*1319Sab196087 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _PROFILE_H 280Sstevel@tonic-gate #define _PROFILE_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #ifndef _ASM 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <sys/types.h> 390Sstevel@tonic-gate #include <synch.h> 400Sstevel@tonic-gate #include <link.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * The profile buffer created by ld.so.1 consists of 3 sections; the header, 440Sstevel@tonic-gate * the profil(2) buffer, and an array of call graph arc structures. 450Sstevel@tonic-gate */ 460Sstevel@tonic-gate 470Sstevel@tonic-gate typedef struct l_hdr { /* Linker profile buffer header */ 480Sstevel@tonic-gate unsigned int hd_magic; /* identifier for file */ 490Sstevel@tonic-gate unsigned int hd_version; /* version for rtld prof file */ 500Sstevel@tonic-gate lwp_mutex_t hd_mutex; /* Provides for process locking */ 510Sstevel@tonic-gate caddr_t hd_hpc; /* Relative high pc address */ 520Sstevel@tonic-gate unsigned int hd_psize; /* Size of profil(2) buffer */ 530Sstevel@tonic-gate unsigned int hd_fsize; /* Size of file */ 540Sstevel@tonic-gate unsigned int hd_ncndx; /* Next (and last) index into */ 550Sstevel@tonic-gate unsigned int hd_lcndx; /* call graph arc structure */ 560Sstevel@tonic-gate } L_hdr; 570Sstevel@tonic-gate 580Sstevel@tonic-gate 590Sstevel@tonic-gate /* 600Sstevel@tonic-gate * The *64 structs are for gprof, as a 32-bit program, 610Sstevel@tonic-gate * to read 64-bit profiles correctly. 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate 640Sstevel@tonic-gate typedef struct l_hdr64 { /* Linker profile buffer header */ 650Sstevel@tonic-gate unsigned int hd_magic; /* identifier for file */ 660Sstevel@tonic-gate unsigned int hd_version; /* version for rtld prof file */ 670Sstevel@tonic-gate lwp_mutex_t hd_mutex; /* Provides for process locking */ 680Sstevel@tonic-gate u_longlong_t hd_hpc; /* Relative high pc address */ 690Sstevel@tonic-gate unsigned int hd_psize; /* Size of profil(2) buffer */ 700Sstevel@tonic-gate unsigned int hd_fsize; /* Size of file */ 710Sstevel@tonic-gate unsigned int hd_ncndx; /* Next (and last) index into */ 720Sstevel@tonic-gate unsigned int hd_lcndx; /* call graph arc structure */ 730Sstevel@tonic-gate } L_hdr64; 740Sstevel@tonic-gate 750Sstevel@tonic-gate 760Sstevel@tonic-gate 770Sstevel@tonic-gate typedef struct l_cgarc { /* Linker call graph arc entry */ 780Sstevel@tonic-gate caddr_t cg_from; /* Source of call */ 790Sstevel@tonic-gate caddr_t cg_to; /* Destination of call */ 800Sstevel@tonic-gate unsigned int cg_count; /* Instance count */ 810Sstevel@tonic-gate unsigned int cg_next; /* Link index for multiple sources */ 820Sstevel@tonic-gate } L_cgarc; 830Sstevel@tonic-gate 840Sstevel@tonic-gate 850Sstevel@tonic-gate typedef struct l_cgarc64 { /* Linker call graph arc entry */ 860Sstevel@tonic-gate u_longlong_t cg_from; /* Source of call */ 870Sstevel@tonic-gate u_longlong_t cg_to; /* Destination of call */ 880Sstevel@tonic-gate unsigned int cg_count; /* Instance count */ 890Sstevel@tonic-gate unsigned int cg_next; /* Link index for multiple sources */ 900Sstevel@tonic-gate } L_cgarc64; 910Sstevel@tonic-gate 920Sstevel@tonic-gate 930Sstevel@tonic-gate 940Sstevel@tonic-gate /* 950Sstevel@tonic-gate * Generic defines for creating profiled output buffer. 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate 980Sstevel@tonic-gate #define PRF_BARSIZE 2 /* No. of program bytes that */ 990Sstevel@tonic-gate /* correspond to each histogram */ 1000Sstevel@tonic-gate /* bar in the profil(2) buffer */ 1010Sstevel@tonic-gate #define PRF_SCALE 0x8000 /* Scale to provide above */ 1020Sstevel@tonic-gate /* histogram correspondence */ 1030Sstevel@tonic-gate #define PRF_CGNUMB 256 /* Size of call graph extension */ 1040Sstevel@tonic-gate #define PRF_CGINIT 2 /* Initial symbol blocks to allocate */ 1050Sstevel@tonic-gate /* for the call graph structure */ 1060Sstevel@tonic-gate #define PRF_OUTADDR (caddr_t)-1 /* Function addresses outside of */ 1070Sstevel@tonic-gate /* the range being monitored */ 1080Sstevel@tonic-gate #define PRF_OUTADDR64 (u_longlong_t)-1 /* Function addresses outside */ 1090Sstevel@tonic-gate /* of the range being monitored */ 1100Sstevel@tonic-gate #define PRF_UNKNOWN (caddr_t)-2 /* Unknown function address */ 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate #define PRF_ROUNDUP(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) 1130Sstevel@tonic-gate #define PRF_ROUNDWN(x, a) ((x) & ~((a) - 1)) 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate #define PRF_MAGIC 0xffffffff /* unique number to differentiate */ 1160Sstevel@tonic-gate /* profiled file from gmon.out for */ 1170Sstevel@tonic-gate /* gprof */ 1180Sstevel@tonic-gate #define PRF_VERSION 0x1 /* current PROF file version */ 1190Sstevel@tonic-gate #define PRF_VERSION_64 0x2 /* 64-bit current PROF file version */ 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* 1230Sstevel@tonic-gate * Related data and function definitions. 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate extern int profile_rtld; /* Rtld is being profiled */ 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate extern uintptr_t (* p_cg_interp)(int, caddr_t, caddr_t); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate #endif 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate #ifdef __cplusplus 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate #endif 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate #endif /* _PROFILE_H */ 137