xref: /titanic_44/usr/src/uts/common/sys/fasttrap.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FASTTRAP_H
28 #define	_SYS_FASTTRAP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/fasttrap_isa.h>
33 #include <sys/dtrace.h>
34 #include <sys/types.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #define	FASTTRAPIOC		(('m' << 24) | ('r' << 16) | ('f' << 8))
41 #define	FASTTRAPIOC_MAKEPROBE	(FASTTRAPIOC | 1)
42 #define	FASTTRAPIOC_GETINSTR	(FASTTRAPIOC | 2)
43 
44 typedef enum fasttrap_probe_type {
45 	DTFTP_NONE = 0,
46 	DTFTP_ENTRY,
47 	DTFTP_RETURN,
48 	DTFTP_OFFSETS,
49 	DTFTP_POST_OFFSETS
50 } fasttrap_probe_type_t;
51 
52 typedef struct fasttrap_probe_spec {
53 	pid_t			ftps_pid;
54 	fasttrap_probe_type_t	ftps_type;
55 
56 	char			ftps_func[DTRACE_FUNCNAMELEN];
57 	char			ftps_mod[DTRACE_MODNAMELEN];
58 
59 	uint64_t		ftps_pc;
60 	uint64_t		ftps_size;
61 	uint64_t		ftps_noffs;
62 	uint64_t		ftps_offs[1];
63 } fasttrap_probe_spec_t;
64 
65 typedef struct fasttrap_instr_query {
66 	uint64_t		ftiq_pc;
67 	pid_t			ftiq_pid;
68 	fasttrap_instr_t	ftiq_instr;
69 } fasttrap_instr_query_t;
70 
71 /*
72  * To support the fasttrap provider from very early in a process's life,
73  * the run-time linker, ld.so.1, has a program header of type PT_SUNWDTRACE
74  * which points to a data object which must be PT_SUNWDTRACE_SIZE bytes.
75  * This structure mimics the fasttrap provider section of the ulwp_t structure.
76  * When the fasttrap provider is changed to require new or different
77  * instructions, the data object in ld.so.1 and the thread initializers in libc
78  * (libc_init() and _thrp_create()) need to be updated to include the new
79  * instructions, and PT_SUNWDTRACE needs to be changed to a new unique number
80  * (while the old value gets assigned something like PT_SUNWDTRACE_1). Since the
81  * linker must be backward compatible with old Solaris releases, it must have
82  * program headers for each of the PT_SUNWDTRACE versions. The kernel's
83  * elfexec() function only has to look for the latest version of the
84  * PT_SUNWDTRACE program header.
85  */
86 #define	PT_SUNWDTRACE_SIZE	FASTTRAP_SUNWDTRACE_SIZE
87 
88 #ifdef	__cplusplus
89 }
90 #endif
91 
92 #endif	/* _SYS_FASTTRAP_H */
93