xref: /titanic_50/usr/src/uts/common/dtrace/sdt_subr.c (revision dfb96a4f56fb431b915bc67e5d9d5c8d4f4f6679)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <sys/sdt_impl.h>
29 
30 static dtrace_pattr_t vtrace_attr = {
31 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
32 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
33 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
34 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
35 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
36 };
37 
38 static dtrace_pattr_t info_attr = {
39 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
40 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
41 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
42 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
43 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
44 };
45 
46 static dtrace_pattr_t fpu_attr = {
47 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
48 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
49 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
50 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_CPU },
51 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
52 };
53 
54 static dtrace_pattr_t fsinfo_attr = {
55 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
56 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
57 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
58 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
59 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
60 };
61 
62 static dtrace_pattr_t stab_attr = {
63 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
64 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
65 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
66 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
67 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
68 };
69 
70 static dtrace_pattr_t sdt_attr = {
71 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
72 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
73 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
74 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
75 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
76 };
77 
78 sdt_provider_t sdt_providers[] = {
79 	{ "vtrace", "__vtrace_", &vtrace_attr, 0 },
80 	{ "sysinfo", "__cpu_sysinfo_", &info_attr, 0 },
81 	{ "vminfo", "__cpu_vminfo_", &info_attr, 0 },
82 	{ "fpuinfo", "__fpuinfo_", &fpu_attr, 0 },
83 	{ "sched", "__sched_", &stab_attr, 0 },
84 	{ "proc", "__proc_", &stab_attr, 0 },
85 	{ "io", "__io_", &stab_attr, 0 },
86 	{ "mib", "__mib_", &stab_attr, 0 },
87 	{ "fsinfo", "__fsinfo_", &fsinfo_attr, 0 },
88 	{ "sysevent", "__sysevent_", &stab_attr, 0 },
89 	{ "sdt", NULL, &sdt_attr, 0 },
90 	{ NULL }
91 };
92 
93 sdt_argdesc_t sdt_args[] = {
94 	{ "sched", "wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
95 	{ "sched", "wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
96 	{ "sched", "dequeue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
97 	{ "sched", "dequeue", 1, 0, "kthread_t *", "psinfo_t *" },
98 	{ "sched", "dequeue", 2, 1, "disp_t *", "cpuinfo_t *" },
99 	{ "sched", "enqueue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
100 	{ "sched", "enqueue", 1, 0, "kthread_t *", "psinfo_t *" },
101 	{ "sched", "enqueue", 2, 1, "disp_t *", "cpuinfo_t *" },
102 	{ "sched", "enqueue", 3, 2, "int" },
103 	{ "sched", "off-cpu", 0, 0, "kthread_t *", "lwpsinfo_t *" },
104 	{ "sched", "off-cpu", 1, 0, "kthread_t *", "psinfo_t *" },
105 	{ "sched", "tick", 0, 0, "kthread_t *", "lwpsinfo_t *" },
106 	{ "sched", "tick", 1, 0, "kthread_t *", "psinfo_t *" },
107 	{ "sched", "change-pri", 0, 0, "kthread_t *", "lwpsinfo_t *" },
108 	{ "sched", "change-pri", 1, 0, "kthread_t *", "psinfo_t *" },
109 	{ "sched", "change-pri", 2, 1, "pri_t" },
110 	{ "sched", "schedctl-nopreempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
111 	{ "sched", "schedctl-nopreempt", 1, 0, "kthread_t *", "psinfo_t *" },
112 	{ "sched", "schedctl-nopreempt", 2, 1, "int" },
113 	{ "sched", "schedctl-preempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
114 	{ "sched", "schedctl-preempt", 1, 0, "kthread_t *", "psinfo_t *" },
115 	{ "sched", "schedctl-yield", 0, 0, "int" },
116 	{ "sched", "surrender", 0, 0, "kthread_t *", "lwpsinfo_t *" },
117 	{ "sched", "surrender", 1, 0, "kthread_t *", "psinfo_t *" },
118 	{ "sched", "cpucaps-sleep", 0, 0, "kthread_t *", "lwpsinfo_t *" },
119 	{ "sched", "cpucaps-sleep", 1, 0, "kthread_t *", "psinfo_t *" },
120 	{ "sched", "cpucaps-wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
121 	{ "sched", "cpucaps-wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
122 	{ "proc", "create", 0, 0, "proc_t *", "psinfo_t *" },
123 	{ "proc", "exec", 0, 0, "string" },
124 	{ "proc", "exec-failure", 0, 0, "int" },
125 	{ "proc", "exit", 0, 0, "int" },
126 	{ "proc", "fault", 0, 0, "int" },
127 	{ "proc", "fault", 1, 1, "siginfo_t *" },
128 	{ "proc", "lwp-create", 0, 0, "kthread_t *", "lwpsinfo_t *" },
129 	{ "proc", "lwp-create", 1, 0, "kthread_t *", "psinfo_t *" },
130 	{ "proc", "signal-clear", 0, 0, "int" },
131 	{ "proc", "signal-clear", 1, 1, "siginfo_t *" },
132 	{ "proc", "signal-discard", 0, 0, "kthread_t *", "lwpsinfo_t *" },
133 	{ "proc", "signal-discard", 1, 1, "proc_t *", "psinfo_t *" },
134 	{ "proc", "signal-discard", 2, 2, "int" },
135 	{ "proc", "signal-handle", 0, 0, "int" },
136 	{ "proc", "signal-handle", 1, 1, "siginfo_t *" },
137 	{ "proc", "signal-handle", 2, 2, "void (*)(void)" },
138 	{ "proc", "signal-send", 0, 0, "kthread_t *", "lwpsinfo_t *" },
139 	{ "proc", "signal-send", 1, 0, "kthread_t *", "psinfo_t *" },
140 	{ "proc", "signal-send", 2, 1, "int" },
141 	{ "io", "start", 0, 0, "buf_t *", "bufinfo_t *" },
142 	{ "io", "start", 1, 0, "buf_t *", "devinfo_t *" },
143 	{ "io", "start", 2, 0, "buf_t *", "fileinfo_t *" },
144 	{ "io", "done", 0, 0, "buf_t *", "bufinfo_t *" },
145 	{ "io", "done", 1, 0, "buf_t *", "devinfo_t *" },
146 	{ "io", "done", 2, 0, "buf_t *", "fileinfo_t *" },
147 	{ "io", "wait-start", 0, 0, "buf_t *", "bufinfo_t *" },
148 	{ "io", "wait-start", 1, 0, "buf_t *", "devinfo_t *" },
149 	{ "io", "wait-start", 2, 0, "buf_t *", "fileinfo_t *" },
150 	{ "io", "wait-done", 0, 0, "buf_t *", "bufinfo_t *" },
151 	{ "io", "wait-done", 1, 0, "buf_t *", "devinfo_t *" },
152 	{ "io", "wait-done", 2, 0, "buf_t *", "fileinfo_t *" },
153 	{ "mib", NULL, 0, 0, "int" },
154 	{ "fsinfo", NULL, 0, 0, "vnode_t *", "fileinfo_t *" },
155 	{ "fsinfo", NULL, 1, 1, "int", "int" },
156 	{ "sysevent", "post", 0, 0, "evch_bind_t *", "syseventchaninfo_t *" },
157 	{ "sysevent", "post", 1, 1, "sysevent_impl_t *", "syseventinfo_t *" },
158 	{ NULL }
159 };
160 
161 /*ARGSUSED*/
162 void
163 sdt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
164 {
165 	sdt_probe_t *sdp = parg;
166 	int i;
167 
168 	desc->dtargd_native[0] = '\0';
169 	desc->dtargd_xlate[0] = '\0';
170 
171 	for (i = 0; sdt_args[i].sda_provider != NULL; i++) {
172 		sdt_argdesc_t *a = &sdt_args[i];
173 
174 		if (strcmp(sdp->sdp_provider->sdtp_name, a->sda_provider) != 0)
175 			continue;
176 
177 		if (a->sda_name != NULL &&
178 		    strcmp(sdp->sdp_name, a->sda_name) != 0)
179 			continue;
180 
181 		if (desc->dtargd_ndx != a->sda_ndx)
182 			continue;
183 
184 		if (a->sda_native != NULL)
185 			(void) strcpy(desc->dtargd_native, a->sda_native);
186 
187 		if (a->sda_xlate != NULL)
188 			(void) strcpy(desc->dtargd_xlate, a->sda_xlate);
189 
190 		desc->dtargd_mapping = a->sda_mapping;
191 		return;
192 	}
193 
194 	desc->dtargd_ndx = DTRACE_ARGNONE;
195 }
196