xref: /illumos-gate/usr/src/uts/common/sys/fasttrap.h (revision 2d6eb4a5)
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 #include <sys/fasttrap_isa.h>
317c478bd9Sstevel@tonic-gate #include <sys/dtrace.h>
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	FASTTRAPIOC		(('m' << 24) | ('r' << 16) | ('f' << 8))
397c478bd9Sstevel@tonic-gate #define	FASTTRAPIOC_MAKEPROBE	(FASTTRAPIOC | 1)
407c478bd9Sstevel@tonic-gate #define	FASTTRAPIOC_GETINSTR	(FASTTRAPIOC | 2)
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate typedef enum fasttrap_probe_type {
437c478bd9Sstevel@tonic-gate 	DTFTP_NONE = 0,
447c478bd9Sstevel@tonic-gate 	DTFTP_ENTRY,
457c478bd9Sstevel@tonic-gate 	DTFTP_RETURN,
467c478bd9Sstevel@tonic-gate 	DTFTP_OFFSETS,
47*ac448965Sahl 	DTFTP_POST_OFFSETS,
48*ac448965Sahl 	DTFTP_IS_ENABLED
497c478bd9Sstevel@tonic-gate } fasttrap_probe_type_t;
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate typedef struct fasttrap_probe_spec {
527c478bd9Sstevel@tonic-gate 	pid_t			ftps_pid;
537c478bd9Sstevel@tonic-gate 	fasttrap_probe_type_t	ftps_type;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 	char			ftps_func[DTRACE_FUNCNAMELEN];
567c478bd9Sstevel@tonic-gate 	char			ftps_mod[DTRACE_MODNAMELEN];
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate 	uint64_t		ftps_pc;
597c478bd9Sstevel@tonic-gate 	uint64_t		ftps_size;
607c478bd9Sstevel@tonic-gate 	uint64_t		ftps_noffs;
617c478bd9Sstevel@tonic-gate 	uint64_t		ftps_offs[1];
627c478bd9Sstevel@tonic-gate } fasttrap_probe_spec_t;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate typedef struct fasttrap_instr_query {
657c478bd9Sstevel@tonic-gate 	uint64_t		ftiq_pc;
667c478bd9Sstevel@tonic-gate 	pid_t			ftiq_pid;
677c478bd9Sstevel@tonic-gate 	fasttrap_instr_t	ftiq_instr;
687c478bd9Sstevel@tonic-gate } fasttrap_instr_query_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * To support the fasttrap provider from very early in a process's life,
727c478bd9Sstevel@tonic-gate  * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE
737c478bd9Sstevel@tonic-gate  * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes.
747c478bd9Sstevel@tonic-gate  * This structure mimics the fasttrap provider section of the ulwp_t structure.
757c478bd9Sstevel@tonic-gate  * When the fasttrap provider is changed to require new or different
767c478bd9Sstevel@tonic-gate  * instructions, the data object in ld.so.1 and the thread initializers in libc
777c478bd9Sstevel@tonic-gate  * (libc_init() and _thrp_create()) need to be updated to include the new
787c478bd9Sstevel@tonic-gate  * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number
797c478bd9Sstevel@tonic-gate  * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the
807c478bd9Sstevel@tonic-gate  * linker must be backward compatible with old Solaris releases, it must have
817c478bd9Sstevel@tonic-gate  * program headers for each of the PT_SUNWDTRACE versions. The kernel's
827c478bd9Sstevel@tonic-gate  * elfexec() function only has to look for the latest version of the
837c478bd9Sstevel@tonic-gate  * PT_SUNWDTRACE program header.
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate #define	PT_SUNWDTRACE_SIZE	FASTTRAP_SUNWDTRACE_SIZE
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
887c478bd9Sstevel@tonic-gate }
897c478bd9Sstevel@tonic-gate #endif
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate #endif	/* _SYS_FASTTRAP_H */
92