xref: /titanic_52/usr/src/uts/common/dtrace/sdt_subr.c (revision 02e56f3f1bfc8d9977bafb8cb5202f576dcded27)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/sdt_impl.h>
30 
31 static dtrace_pattr_t vtrace_attr = {
32 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
33 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
34 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
35 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
36 { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_ISA },
37 };
38 
39 static dtrace_pattr_t info_attr = {
40 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
41 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
42 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
43 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
44 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
45 };
46 
47 static dtrace_pattr_t fpu_attr = {
48 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
49 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
50 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
51 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_CPU },
52 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
53 };
54 
55 static dtrace_pattr_t stab_attr = {
56 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
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 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
61 };
62 
63 static dtrace_pattr_t sdt_attr = {
64 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
65 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
66 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
67 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
68 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
69 };
70 
71 sdt_provider_t sdt_providers[] = {
72 	{ "vtrace", "__vtrace_", &vtrace_attr, 0 },
73 	{ "sysinfo", "__cpu_sysinfo_", &info_attr, 0 },
74 	{ "vminfo", "__cpu_vminfo_", &info_attr, 0 },
75 	{ "fpuinfo", "__fpuinfo_", &fpu_attr, 0 },
76 	{ "sched", "__sched_", &stab_attr, 0 },
77 	{ "proc", "__proc_", &stab_attr, 0 },
78 	{ "io", "__io_", &stab_attr, 0 },
79 	{ "mib", "__mib_", &stab_attr, 0 },
80 	{ "sdt", NULL, &sdt_attr, 0 },
81 	{ NULL }
82 };
83 
84 sdt_argdesc_t sdt_args[] = {
85 	{ "sched", "wakeup", 0, 0, "kthread_t *", "lwpsinfo_t *" },
86 	{ "sched", "wakeup", 1, 0, "kthread_t *", "psinfo_t *" },
87 	{ "sched", "dequeue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
88 	{ "sched", "dequeue", 1, 0, "kthread_t *", "psinfo_t *" },
89 	{ "sched", "dequeue", 2, 1, "disp_t *", "cpuinfo_t *" },
90 	{ "sched", "enqueue", 0, 0, "kthread_t *", "lwpsinfo_t *" },
91 	{ "sched", "enqueue", 1, 0, "kthread_t *", "psinfo_t *" },
92 	{ "sched", "enqueue", 2, 1, "disp_t *", "cpuinfo_t *" },
93 	{ "sched", "enqueue", 3, 2, "int" },
94 	{ "sched", "off-cpu", 0, 0, "kthread_t *", "lwpsinfo_t *" },
95 	{ "sched", "off-cpu", 1, 0, "kthread_t *", "psinfo_t *" },
96 	{ "sched", "tick", 0, 0, "kthread_t *", "lwpsinfo_t *" },
97 	{ "sched", "tick", 1, 0, "kthread_t *", "psinfo_t *" },
98 	{ "sched", "change-pri", 0, 0, "kthread_t *", "lwpsinfo_t *" },
99 	{ "sched", "change-pri", 1, 0, "kthread_t *", "psinfo_t *" },
100 	{ "sched", "change-pri", 2, 1, "pri_t" },
101 	{ "sched", "schedctl-nopreempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
102 	{ "sched", "schedctl-nopreempt", 1, 0, "kthread_t *", "psinfo_t *" },
103 	{ "sched", "schedctl-nopreempt", 2, 1, "int" },
104 	{ "sched", "schedctl-preempt", 0, 0, "kthread_t *", "lwpsinfo_t *" },
105 	{ "sched", "schedctl-preempt", 1, 0, "kthread_t *", "psinfo_t *" },
106 	{ "sched", "schedctl-yield", 0, 0, "int" },
107 	{ "sched", "surrender", 0, 0, "kthread_t *", "lwpsinfo_t *" },
108 	{ "sched", "surrender", 1, 0, "kthread_t *", "psinfo_t *" },
109 	{ "proc", "create", 0, 0, "proc_t *", "psinfo_t *" },
110 	{ "proc", "exec", 0, 0, "string" },
111 	{ "proc", "exec-failure", 0, 0, "int" },
112 	{ "proc", "exit", 0, 0, "int" },
113 	{ "proc", "fault", 0, 0, "int" },
114 	{ "proc", "fault", 1, 1, "siginfo_t *" },
115 	{ "proc", "lwp-create", 0, 0, "kthread_t *", "lwpsinfo_t *" },
116 	{ "proc", "lwp-create", 1, 0, "kthread_t *", "psinfo_t *" },
117 	{ "proc", "signal-clear", 0, 0, "int" },
118 	{ "proc", "signal-clear", 1, 1, "siginfo_t *" },
119 	{ "proc", "signal-discard", 0, 0, "kthread_t *", "lwpsinfo_t *" },
120 	{ "proc", "signal-discard", 1, 1, "proc_t *", "psinfo_t *" },
121 	{ "proc", "signal-discard", 2, 2, "int" },
122 	{ "proc", "signal-handle", 0, 0, "int" },
123 	{ "proc", "signal-handle", 1, 1, "siginfo_t *" },
124 	{ "proc", "signal-handle", 2, 2, "void (*)(void)" },
125 	{ "proc", "signal-send", 0, 0, "kthread_t *", "lwpsinfo_t *" },
126 	{ "proc", "signal-send", 1, 0, "kthread_t *", "psinfo_t *" },
127 	{ "proc", "signal-send", 2, 1, "int" },
128 	{ "io", "start", 0, 0, "buf_t *", "bufinfo_t *" },
129 	{ "io", "start", 1, 0, "buf_t *", "devinfo_t *" },
130 	{ "io", "start", 2, 0, "buf_t *", "fileinfo_t *" },
131 	{ "io", "done", 0, 0, "buf_t *", "bufinfo_t *" },
132 	{ "io", "done", 1, 0, "buf_t *", "devinfo_t *" },
133 	{ "io", "done", 2, 0, "buf_t *", "fileinfo_t *" },
134 	{ "io", "wait-start", 0, 0, "buf_t *", "bufinfo_t *" },
135 	{ "io", "wait-start", 1, 0, "buf_t *", "devinfo_t *" },
136 	{ "io", "wait-start", 2, 0, "buf_t *", "fileinfo_t *" },
137 	{ "io", "wait-done", 0, 0, "buf_t *", "bufinfo_t *" },
138 	{ "io", "wait-done", 1, 0, "buf_t *", "devinfo_t *" },
139 	{ "io", "wait-done", 2, 0, "buf_t *", "fileinfo_t *" },
140 	{ "mib", NULL, 0, 0, "int" },
141 	{ NULL }
142 };
143 
144 /*ARGSUSED*/
145 void
146 sdt_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
147 {
148 	sdt_probe_t *sdp = parg;
149 	int i;
150 
151 	desc->dtargd_native[0] = '\0';
152 	desc->dtargd_xlate[0] = '\0';
153 
154 	for (i = 0; sdt_args[i].sda_provider != NULL; i++) {
155 		sdt_argdesc_t *a = &sdt_args[i];
156 
157 		if (strcmp(sdp->sdp_provider->sdtp_name, a->sda_provider) != 0)
158 			continue;
159 
160 		if (a->sda_name != NULL &&
161 		    strcmp(sdp->sdp_name, a->sda_name) != 0)
162 			continue;
163 
164 		if (desc->dtargd_ndx != a->sda_ndx)
165 			continue;
166 
167 		if (a->sda_native != NULL)
168 			(void) strcpy(desc->dtargd_native, a->sda_native);
169 
170 		if (a->sda_xlate != NULL)
171 			(void) strcpy(desc->dtargd_xlate, a->sda_xlate);
172 
173 		desc->dtargd_mapping = a->sda_mapping;
174 		return;
175 	}
176 
177 	desc->dtargd_ndx = DTRACE_ARGNONE;
178 }
179