xref: /onnv-gate/usr/src/uts/common/sys/fasttrap.h (revision 1710:2710bf829bf1)
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
5*1710Sahl  * Common Development and Distribution License (the "License").
6*1710Sahl  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1710Sahl 
220Sstevel@tonic-gate /*
23*1710Sahl  * 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	_SYS_FASTTRAP_H
280Sstevel@tonic-gate #define	_SYS_FASTTRAP_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <sys/fasttrap_isa.h>
330Sstevel@tonic-gate #include <sys/dtrace.h>
340Sstevel@tonic-gate #include <sys/types.h>
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifdef	__cplusplus
370Sstevel@tonic-gate extern "C" {
380Sstevel@tonic-gate #endif
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #define	FASTTRAPIOC		(('m' << 24) | ('r' << 16) | ('f' << 8))
410Sstevel@tonic-gate #define	FASTTRAPIOC_MAKEPROBE	(FASTTRAPIOC | 1)
420Sstevel@tonic-gate #define	FASTTRAPIOC_GETINSTR	(FASTTRAPIOC | 2)
430Sstevel@tonic-gate 
440Sstevel@tonic-gate typedef enum fasttrap_probe_type {
450Sstevel@tonic-gate 	DTFTP_NONE = 0,
460Sstevel@tonic-gate 	DTFTP_ENTRY,
470Sstevel@tonic-gate 	DTFTP_RETURN,
480Sstevel@tonic-gate 	DTFTP_OFFSETS,
49*1710Sahl 	DTFTP_POST_OFFSETS,
50*1710Sahl 	DTFTP_IS_ENABLED
510Sstevel@tonic-gate } fasttrap_probe_type_t;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate typedef struct fasttrap_probe_spec {
540Sstevel@tonic-gate 	pid_t			ftps_pid;
550Sstevel@tonic-gate 	fasttrap_probe_type_t	ftps_type;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate 	char			ftps_func[DTRACE_FUNCNAMELEN];
580Sstevel@tonic-gate 	char			ftps_mod[DTRACE_MODNAMELEN];
590Sstevel@tonic-gate 
600Sstevel@tonic-gate 	uint64_t		ftps_pc;
610Sstevel@tonic-gate 	uint64_t		ftps_size;
620Sstevel@tonic-gate 	uint64_t		ftps_noffs;
630Sstevel@tonic-gate 	uint64_t		ftps_offs[1];
640Sstevel@tonic-gate } fasttrap_probe_spec_t;
650Sstevel@tonic-gate 
660Sstevel@tonic-gate typedef struct fasttrap_instr_query {
670Sstevel@tonic-gate 	uint64_t		ftiq_pc;
680Sstevel@tonic-gate 	pid_t			ftiq_pid;
690Sstevel@tonic-gate 	fasttrap_instr_t	ftiq_instr;
700Sstevel@tonic-gate } fasttrap_instr_query_t;
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /*
730Sstevel@tonic-gate  * To support the fasttrap provider from very early in a process's life,
740Sstevel@tonic-gate  * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE
750Sstevel@tonic-gate  * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes.
760Sstevel@tonic-gate  * This structure mimics the fasttrap provider section of the ulwp_t structure.
770Sstevel@tonic-gate  * When the fasttrap provider is changed to require new or different
780Sstevel@tonic-gate  * instructions, the data object in ld.so.1 and the thread initializers in libc
790Sstevel@tonic-gate  * (libc_init() and _thrp_create()) need to be updated to include the new
800Sstevel@tonic-gate  * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number
810Sstevel@tonic-gate  * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the
820Sstevel@tonic-gate  * linker must be backward compatible with old Solaris releases, it must have
830Sstevel@tonic-gate  * program headers for each of the PT_SUNWDTRACE versions. The kernel's
840Sstevel@tonic-gate  * elfexec() function only has to look for the latest version of the
850Sstevel@tonic-gate  * PT_SUNWDTRACE program header.
860Sstevel@tonic-gate  */
870Sstevel@tonic-gate #define	PT_SUNWDTRACE_SIZE	FASTTRAP_SUNWDTRACE_SIZE
880Sstevel@tonic-gate 
890Sstevel@tonic-gate #ifdef	__cplusplus
900Sstevel@tonic-gate }
910Sstevel@tonic-gate #endif
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #endif	/* _SYS_FASTTRAP_H */
94