xref: /titanic_51/usr/src/uts/common/sys/fasttrap.h (revision ac448965596bc1c42f7accb3023f48d5fa9b8180)
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
5*ac448965Sahl  * Common Development and Distribution License (the "License").
6*ac448965Sahl  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*ac448965Sahl 
227c478bd9Sstevel@tonic-gate /*
23*ac448965Sahl  * 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	_SYS_FASTTRAP_H
287c478bd9Sstevel@tonic-gate #define	_SYS_FASTTRAP_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/fasttrap_isa.h>
337c478bd9Sstevel@tonic-gate #include <sys/dtrace.h>
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #define	FASTTRAPIOC		(('m' << 24) | ('r' << 16) | ('f' << 8))
417c478bd9Sstevel@tonic-gate #define	FASTTRAPIOC_MAKEPROBE	(FASTTRAPIOC | 1)
427c478bd9Sstevel@tonic-gate #define	FASTTRAPIOC_GETINSTR	(FASTTRAPIOC | 2)
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate typedef enum fasttrap_probe_type {
457c478bd9Sstevel@tonic-gate 	DTFTP_NONE = 0,
467c478bd9Sstevel@tonic-gate 	DTFTP_ENTRY,
477c478bd9Sstevel@tonic-gate 	DTFTP_RETURN,
487c478bd9Sstevel@tonic-gate 	DTFTP_OFFSETS,
49*ac448965Sahl 	DTFTP_POST_OFFSETS,
50*ac448965Sahl 	DTFTP_IS_ENABLED
517c478bd9Sstevel@tonic-gate } fasttrap_probe_type_t;
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate typedef struct fasttrap_probe_spec {
547c478bd9Sstevel@tonic-gate 	pid_t			ftps_pid;
557c478bd9Sstevel@tonic-gate 	fasttrap_probe_type_t	ftps_type;
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate 	char			ftps_func[DTRACE_FUNCNAMELEN];
587c478bd9Sstevel@tonic-gate 	char			ftps_mod[DTRACE_MODNAMELEN];
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate 	uint64_t		ftps_pc;
617c478bd9Sstevel@tonic-gate 	uint64_t		ftps_size;
627c478bd9Sstevel@tonic-gate 	uint64_t		ftps_noffs;
637c478bd9Sstevel@tonic-gate 	uint64_t		ftps_offs[1];
647c478bd9Sstevel@tonic-gate } fasttrap_probe_spec_t;
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate typedef struct fasttrap_instr_query {
677c478bd9Sstevel@tonic-gate 	uint64_t		ftiq_pc;
687c478bd9Sstevel@tonic-gate 	pid_t			ftiq_pid;
697c478bd9Sstevel@tonic-gate 	fasttrap_instr_t	ftiq_instr;
707c478bd9Sstevel@tonic-gate } fasttrap_instr_query_t;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * To support the fasttrap provider from very early in a process's life,
747c478bd9Sstevel@tonic-gate  * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE
757c478bd9Sstevel@tonic-gate  * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes.
767c478bd9Sstevel@tonic-gate  * This structure mimics the fasttrap provider section of the ulwp_t structure.
777c478bd9Sstevel@tonic-gate  * When the fasttrap provider is changed to require new or different
787c478bd9Sstevel@tonic-gate  * instructions, the data object in ld.so.1 and the thread initializers in libc
797c478bd9Sstevel@tonic-gate  * (libc_init() and _thrp_create()) need to be updated to include the new
807c478bd9Sstevel@tonic-gate  * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number
817c478bd9Sstevel@tonic-gate  * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the
827c478bd9Sstevel@tonic-gate  * linker must be backward compatible with old Solaris releases, it must have
837c478bd9Sstevel@tonic-gate  * program headers for each of the PT_SUNWDTRACE versions. The kernel's
847c478bd9Sstevel@tonic-gate  * elfexec() function only has to look for the latest version of the
857c478bd9Sstevel@tonic-gate  * PT_SUNWDTRACE program header.
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate #define	PT_SUNWDTRACE_SIZE	FASTTRAP_SUNWDTRACE_SIZE
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
907c478bd9Sstevel@tonic-gate }
917c478bd9Sstevel@tonic-gate #endif
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #endif	/* _SYS_FASTTRAP_H */
94