Print this page
4474 DTrace Userland CTF Support
4475 DTrace userland Keyword
4476 DTrace tests should be better citizens
4479 pid provider types
4480 dof emulation missing checks
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libdtrace/common/dt_error.c
+++ new/usr/src/lib/libdtrace/common/dt_error.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright (c) 2012 by Delphix. All rights reserved.
29 29 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
30 30 */
31 31
32 32 #include <strings.h>
33 33 #include <dt_impl.h>
34 34
35 35 static const struct {
36 36 int err;
37 37 const char *msg;
38 38 } _dt_errlist[] = {
39 39 { EDT_VERSION, "Client requested version newer than library" },
40 40 { EDT_VERSINVAL, "Version is not properly formatted or is too large" },
41 41 { EDT_VERSUNDEF, "Requested version is not supported by compiler" },
42 42 { EDT_VERSREDUCED, "Requested version conflicts with earlier setting" },
43 43 { EDT_CTF, "Unexpected libctf error" },
44 44 { EDT_COMPILER, "Error in D program compilation" },
45 45 { EDT_NOTUPREG, "Insufficient tuple registers to generate code" },
46 46 { EDT_NOMEM, "Memory allocation failure" },
47 47 { EDT_INT2BIG, "Integer constant table limit exceeded" },
48 48 { EDT_STR2BIG, "String constant table limit exceeded" },
49 49 { EDT_NOMOD, "Unknown module name" },
50 50 { EDT_NOPROV, "Unknown provider name" },
51 51 { EDT_NOPROBE, "No probe matches description" },
52 52 { EDT_NOSYM, "Unknown symbol name" },
53 53 { EDT_NOSYMADDR, "No symbol corresponds to address" },
54 54 { EDT_NOTYPE, "Unknown type name" },
55 55 { EDT_NOVAR, "Unknown variable name" },
56 56 { EDT_NOAGG, "Unknown aggregation name" },
57 57 { EDT_BADSCOPE, "Improper use of scoping operator in type name" },
58 58 { EDT_BADSPEC, "Overspecified probe description" },
59 59 { EDT_BADSPCV, "Undefined macro variable in probe description" },
60 60 { EDT_BADID, "Unknown probe identifier" },
61 61 { EDT_NOTLOADED, "Module is no longer loaded" },
62 62 { EDT_NOCTF, "Module does not contain any CTF data" },
63 63 { EDT_DATAMODEL, "Module and program data models do not match" },
64 64 { EDT_DIFVERS, "Library uses newer DIF version than kernel" },
65 65 { EDT_BADAGG, "Unknown aggregating action" },
66 66 { EDT_FIO, "Error occurred while reading from input stream" },
67 67 { EDT_DIFINVAL, "DIF program content is invalid" },
68 68 { EDT_DIFSIZE, "DIF program exceeds maximum program size" },
69 69 { EDT_DIFFAULT, "DIF program contains invalid pointer" },
70 70 { EDT_BADPROBE, "Invalid probe specification" },
71 71 { EDT_BADPGLOB, "Probe description has too many globbing characters" },
72 72 { EDT_NOSCOPE, "Declaration scope stack underflow" },
73 73 { EDT_NODECL, "Declaration stack underflow" },
74 74 { EDT_DMISMATCH, "Data record list does not match statement" },
75 75 { EDT_DOFFSET, "Data record offset exceeds buffer boundary" },
76 76 { EDT_DALIGN, "Data record has inappropriate alignment" },
77 77 { EDT_BADOPTNAME, "Invalid option name" },
78 78 { EDT_BADOPTVAL, "Invalid value for specified option" },
79 79 { EDT_BADOPTCTX, "Option cannot be used from within a D program" },
80 80 { EDT_CPPFORK, "Failed to fork preprocessor" },
81 81 { EDT_CPPEXEC, "Failed to exec preprocessor" },
82 82 { EDT_CPPENT, "Preprocessor not found" },
83 83 { EDT_CPPERR, "Preprocessor failed to process input program" },
84 84 { EDT_SYMOFLOW, "Symbol table identifier space exhausted" },
85 85 { EDT_ACTIVE, "Operation illegal when tracing is active" },
86 86 { EDT_DESTRUCTIVE, "Destructive actions not allowed" },
87 87 { EDT_NOANON, "No anonymous tracing state" },
88 88 { EDT_ISANON, "Can't claim anonymous state and enable probes" },
89 89 { EDT_ENDTOOBIG, "END enablings exceed size of principal buffer" },
90 90 { EDT_NOCONV, "Failed to load type for printf conversion" },
91 91 { EDT_BADCONV, "Incomplete printf conversion" },
92 92 { EDT_BADERROR, "Invalid library ERROR action" },
93 93 { EDT_ERRABORT, "Abort due to error" },
94 94 { EDT_DROPABORT, "Abort due to drop" },
95 95 { EDT_DIRABORT, "Abort explicitly directed" },
96 96 { EDT_BADRVAL, "Invalid return value from callback" },
97 97 { EDT_BADNORMAL, "Invalid normalization" },
98 98 { EDT_BUFTOOSMALL, "Enabling exceeds size of buffer" },
99 99 { EDT_BADTRUNC, "Invalid truncation" },
100 100 { EDT_BUSY, "DTrace cannot be used when kernel debugger is active" },
101 101 { EDT_ACCESS, "DTrace requires additional privileges" },
102 102 { EDT_NOENT, "DTrace device not available on system" },
↓ open down ↓ |
102 lines elided |
↑ open up ↑ |
103 103 { EDT_BRICKED, "Abort due to systemic unresponsiveness" },
104 104 { EDT_HARDWIRE, "Failed to load language definitions" },
105 105 { EDT_ELFVERSION, "libelf is out-of-date with respect to libdtrace" },
106 106 { EDT_NOBUFFERED, "Attempt to buffer output without handler" },
107 107 { EDT_UNSTABLE, "Description matched an unstable set of probes" },
108 108 { EDT_BADSETOPT, "Invalid setopt() library action" },
109 109 { EDT_BADSTACKPC, "Invalid stack program counter size" },
110 110 { EDT_BADAGGVAR, "Invalid aggregation variable identifier" },
111 111 { EDT_OVERSION, "Client requested deprecated version of library" },
112 112 { EDT_ENABLING_ERR, "Failed to enable probe" },
113 - { EDT_NOPROBES, "No probe sites found for declared provider" }
113 + { EDT_NOPROBES, "No probe sites found for declared provider" },
114 + { EDT_CANTLOAD, "Failed to load module" },
114 115 };
115 116
116 117 static const int _dt_nerr = sizeof (_dt_errlist) / sizeof (_dt_errlist[0]);
117 118
118 119 const char *
119 120 dtrace_errmsg(dtrace_hdl_t *dtp, int error)
120 121 {
121 122 const char *str;
122 123 int i;
123 124
124 125 if (error == EDT_COMPILER && dtp != NULL && dtp->dt_errmsg[0] != '\0')
125 126 str = dtp->dt_errmsg;
126 127 else if (error == EDT_CTF && dtp != NULL && dtp->dt_ctferr != 0)
127 128 str = ctf_errmsg(dtp->dt_ctferr);
128 129 else if (error >= EDT_BASE && (error - EDT_BASE) < _dt_nerr) {
129 130 for (i = 0; i < _dt_nerr; i++) {
130 131 if (_dt_errlist[i].err == error)
131 132 return (_dt_errlist[i].msg);
132 133 }
133 134 str = NULL;
134 135 } else
135 136 str = strerror(error);
136 137
137 138 return (str ? str : "Unknown error");
138 139 }
139 140
140 141 int
141 142 dtrace_errno(dtrace_hdl_t *dtp)
142 143 {
143 144 return (dtp->dt_errno);
144 145 }
145 146
146 147 int
147 148 dt_set_errno(dtrace_hdl_t *dtp, int err)
148 149 {
149 150 dtp->dt_errno = err;
150 151 return (-1);
151 152 }
152 153
153 154 void
154 155 dt_set_errmsg(dtrace_hdl_t *dtp, const char *errtag, const char *region,
155 156 const char *filename, int lineno, const char *format, va_list ap)
156 157 {
157 158 size_t len, n;
158 159 char *p, *s;
159 160
160 161 s = dtp->dt_errmsg;
161 162 n = sizeof (dtp->dt_errmsg);
162 163
163 164 if (errtag != NULL && (yypcb->pcb_cflags & DTRACE_C_ETAGS))
164 165 (void) snprintf(s, n, "[%s] ", errtag);
165 166 else
166 167 s[0] = '\0';
167 168
168 169 len = strlen(dtp->dt_errmsg);
169 170 s = dtp->dt_errmsg + len;
170 171 n = sizeof (dtp->dt_errmsg) - len;
171 172
172 173 if (filename == NULL)
173 174 filename = dtp->dt_filetag;
174 175
175 176 if (filename != NULL)
176 177 (void) snprintf(s, n, "\"%s\", line %d: ", filename, lineno);
177 178 else if (lineno != 0)
178 179 (void) snprintf(s, n, "line %d: ", lineno);
179 180 else if (region != NULL)
180 181 (void) snprintf(s, n, "in %s: ", region);
181 182
182 183 len = strlen(dtp->dt_errmsg);
183 184 s = dtp->dt_errmsg + len;
184 185 n = sizeof (dtp->dt_errmsg) - len;
185 186 (void) vsnprintf(s, n, format, ap);
186 187
187 188 if ((p = strrchr(dtp->dt_errmsg, '\n')) != NULL)
188 189 *p = '\0'; /* remove trailing \n from message buffer */
189 190
190 191 dtp->dt_errtag = errtag;
191 192 }
192 193
193 194 /*ARGSUSED*/
194 195 const char *
195 196 dtrace_faultstr(dtrace_hdl_t *dtp, int fault)
196 197 {
197 198 int i;
198 199
199 200 static const struct {
200 201 int code;
201 202 const char *str;
202 203 } faults[] = {
203 204 { DTRACEFLT_BADADDR, "invalid address" },
204 205 { DTRACEFLT_BADALIGN, "invalid alignment" },
205 206 { DTRACEFLT_ILLOP, "illegal operation" },
206 207 { DTRACEFLT_DIVZERO, "divide-by-zero" },
207 208 { DTRACEFLT_NOSCRATCH, "out of scratch space" },
208 209 { DTRACEFLT_KPRIV, "invalid kernel access" },
209 210 { DTRACEFLT_UPRIV, "invalid user access" },
210 211 { DTRACEFLT_TUPOFLOW, "tuple stack overflow" },
211 212 { DTRACEFLT_BADSTACK, "bad stack" },
212 213 { DTRACEFLT_LIBRARY, "library-level fault" },
213 214 { 0, NULL }
214 215 };
215 216
216 217 for (i = 0; faults[i].str != NULL; i++) {
217 218 if (faults[i].code == fault)
218 219 return (faults[i].str);
219 220 }
220 221
221 222 return ("unknown fault");
222 223 }
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX