xref: /titanic_50/usr/src/uts/common/dtrace/sdt_subr.c (revision 60c807700988885656502665e0cf8afd4b4346f7)
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 2006 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 	{ "sdt", NULL, &sdt_attr, 0 },
89 	{ NULL }
90 };
91 
92 sdt_argdesc_t sdt_args[] = {
93 	{ "sched", "wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
94 	{ "sched", "wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
95 	{ "sched", "dequeue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
96 	{ "sched", "dequeue", 1, 0, "kthread_t *", "psinfo_t *" },
97 	{ "sched", "dequeue", 2, 1, "disp_t *", "cpuinfo_t *" },
98 	{ "sched", "enqueue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
99 	{ "sched", "enqueue", 1, 0, "kthread_t *", "psinfo_t *" },
100 	{ "sched", "enqueue", 2, 1, "disp_t *", "cpuinfo_t *" },
101 	{ "sched", "enqueue", 3, 2, "int" },
102 	{ "sched", "off-cpu", 0, 0, "kthread_t *", "lwpsinfo_t *" },
103 	{ "sched", "off-cpu", 1, 0, "kthread_t *", "psinfo_t *" },
104 	{ "sched", "tick", 0, 0, "kthread_t *", "lwpsinfo_t *" },
105 	{ "sched", "tick", 1, 0, "kthread_t *", "psinfo_t *" },
106 	{ "sched", "change-pri", 0, 0, "kthread_t *", "lwpsinfo_t *" },
107 	{ "sched", "change-pri", 1, 0, "kthread_t *", "psinfo_t *" },
108 	{ "sched", "change-pri", 2, 1, "pri_t" },
109 	{ "sched", "schedctl-nopreempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
110 	{ "sched", "schedctl-nopreempt", 1, 0, "kthread_t *", "psinfo_t *" },
111 	{ "sched", "schedctl-nopreempt", 2, 1, "int" },
112 	{ "sched", "schedctl-preempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
113 	{ "sched", "schedctl-preempt", 1, 0, "kthread_t *", "psinfo_t *" },
114 	{ "sched", "schedctl-yield", 0, 0, "int" },
115 	{ "sched", "surrender", 0, 0, "kthread_t *", "lwpsinfo_t *" },
116 	{ "sched", "surrender", 1, 0, "kthread_t *", "psinfo_t *" },
117 	{ "proc", "create", 0, 0, "proc_t *", "psinfo_t *" },
118 	{ "proc", "exec", 0, 0, "string" },
119 	{ "proc", "exec-failure", 0, 0, "int" },
120 	{ "proc", "exit", 0, 0, "int" },
121 	{ "proc", "fault", 0, 0, "int" },
122 	{ "proc", "fault", 1, 1, "siginfo_t *" },
123 	{ "proc", "lwp-create", 0, 0, "kthread_t *", "lwpsinfo_t *" },
124 	{ "proc", "lwp-create", 1, 0, "kthread_t *", "psinfo_t *" },
125 	{ "proc", "signal-clear", 0, 0, "int" },
126 	{ "proc", "signal-clear", 1, 1, "siginfo_t *" },
127 	{ "proc", "signal-discard", 0, 0, "kthread_t *", "lwpsinfo_t *" },
128 	{ "proc", "signal-discard", 1, 1, "proc_t *", "psinfo_t *" },
129 	{ "proc", "signal-discard", 2, 2, "int" },
130 	{ "proc", "signal-handle", 0, 0, "int" },
131 	{ "proc", "signal-handle", 1, 1, "siginfo_t *" },
132 	{ "proc", "signal-handle", 2, 2, "void (*)(void)" },
133 	{ "proc", "signal-send", 0, 0, "kthread_t *", "lwpsinfo_t *" },
134 	{ "proc", "signal-send", 1, 0, "kthread_t *", "psinfo_t *" },
135 	{ "proc", "signal-send", 2, 1, "int" },
136 	{ "io", "start", 0, 0, "buf_t *", "bufinfo_t *" },
137 	{ "io", "start", 1, 0, "buf_t *", "devinfo_t *" },
138 	{ "io", "start", 2, 0, "buf_t *", "fileinfo_t *" },
139 	{ "io", "done", 0, 0, "buf_t *", "bufinfo_t *" },
140 	{ "io", "done", 1, 0, "buf_t *", "devinfo_t *" },
141 	{ "io", "done", 2, 0, "buf_t *", "fileinfo_t *" },
142 	{ "io", "wait-start", 0, 0, "buf_t *", "bufinfo_t *" },
143 	{ "io", "wait-start", 1, 0, "buf_t *", "devinfo_t *" },
144 	{ "io", "wait-start", 2, 0, "buf_t *", "fileinfo_t *" },
145 	{ "io", "wait-done", 0, 0, "buf_t *", "bufinfo_t *" },
146 	{ "io", "wait-done", 1, 0, "buf_t *", "devinfo_t *" },
147 	{ "io", "wait-done", 2, 0, "buf_t *", "fileinfo_t *" },
148 	{ "mib", NULL, 0, 0, "int" },
149 	{ "fsinfo", NULL, 0, 0, "vnode_t *", "fileinfo_t *" },
150 	{ "fsinfo", NULL, 1, 1, "int", "int" },
151 	{ NULL }
152 };
153 
154 /*ARGSUSED*/
155 void
156 sdt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
157 {
158 	sdt_probe_t *sdp = parg;
159 	int i;
160 
161 	desc->dtargd_native[0] = '\0';
162 	desc->dtargd_xlate[0] = '\0';
163 
164 	for (i = 0; sdt_args[i].sda_provider != NULL; i++) {
165 		sdt_argdesc_t *a = &sdt_args[i];
166 
167 		if (strcmp(sdp->sdp_provider->sdtp_name, a->sda_provider) != 0)
168 			continue;
169 
170 		if (a->sda_name != NULL &&
171 		    strcmp(sdp->sdp_name, a->sda_name) != 0)
172 			continue;
173 
174 		if (desc->dtargd_ndx != a->sda_ndx)
175 			continue;
176 
177 		if (a->sda_native != NULL)
178 			(void) strcpy(desc->dtargd_native, a->sda_native);
179 
180 		if (a->sda_xlate != NULL)
181 			(void) strcpy(desc->dtargd_xlate, a->sda_xlate);
182 
183 		desc->dtargd_mapping = a->sda_mapping;
184 		return;
185 	}
186 
187 	desc->dtargd_ndx = DTRACE_ARGNONE;
188 }
189