Print this page
1730 DTrace should ignore type information from modules with cth_parlabel mismatches
Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libdtrace/common/dt_impl.h
+++ new/usr/src/lib/libdtrace/common/dt_impl.h
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 2010 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
29 29 * Copyright (c) 2012 by Delphix. All rights reserved.
30 30 */
31 31
32 32 #ifndef _DT_IMPL_H
33 33 #define _DT_IMPL_H
34 34
35 35 #include <sys/param.h>
36 36 #include <sys/objfs.h>
37 37 #include <setjmp.h>
38 38 #include <libctf.h>
39 39 #include <dtrace.h>
40 40 #include <gelf.h>
41 41 #include <synch.h>
42 42
43 43 #ifdef __cplusplus
44 44 extern "C" {
45 45 #endif
46 46
47 47 #include <dt_parser.h>
48 48 #include <dt_regset.h>
49 49 #include <dt_inttab.h>
50 50 #include <dt_strtab.h>
51 51 #include <dt_ident.h>
52 52 #include <dt_list.h>
53 53 #include <dt_decl.h>
54 54 #include <dt_as.h>
55 55 #include <dt_proc.h>
56 56 #include <dt_dof.h>
57 57 #include <dt_pcb.h>
58 58 #include <dt_pq.h>
59 59
60 60 struct dt_module; /* see below */
61 61 struct dt_pfdict; /* see <dt_printf.h> */
62 62 struct dt_arg; /* see below */
63 63 struct dt_provider; /* see <dt_provider.h> */
64 64 struct dt_xlator; /* see <dt_xlator.h> */
65 65
66 66 typedef struct dt_intrinsic {
67 67 const char *din_name; /* string name of the intrinsic type */
68 68 ctf_encoding_t din_data; /* integer or floating-point CTF encoding */
69 69 uint_t din_kind; /* CTF type kind to instantiate */
70 70 } dt_intrinsic_t;
71 71
72 72 typedef struct dt_typedef {
73 73 const char *dty_src; /* string name of typedef source type */
74 74 const char *dty_dst; /* string name of typedef destination type */
75 75 } dt_typedef_t;
76 76
77 77 typedef struct dt_intdesc {
78 78 const char *did_name; /* string name of the integer type */
79 79 ctf_file_t *did_ctfp; /* CTF container for this type reference */
80 80 ctf_id_t did_type; /* CTF type reference for this type */
81 81 uintmax_t did_limit; /* maximum positive value held by type */
82 82 } dt_intdesc_t;
83 83
84 84 typedef struct dt_modops {
85 85 uint_t (*do_syminit)(struct dt_module *);
86 86 void (*do_symsort)(struct dt_module *);
87 87 GElf_Sym *(*do_symname)(struct dt_module *,
88 88 const char *, GElf_Sym *, uint_t *);
89 89 GElf_Sym *(*do_symaddr)(struct dt_module *,
90 90 GElf_Addr, GElf_Sym *, uint_t *);
91 91 } dt_modops_t;
92 92
93 93 typedef struct dt_arg {
94 94 int da_ndx; /* index of this argument */
95 95 int da_mapping; /* mapping of argument indices to arguments */
96 96 ctf_id_t da_type; /* type of argument */
97 97 ctf_file_t *da_ctfp; /* CTF container for type */
98 98 dt_ident_t *da_xlator; /* translator, if any */
99 99 struct dt_arg *da_next; /* next argument */
100 100 } dt_arg_t;
101 101
102 102 typedef struct dt_sym {
103 103 uint_t ds_symid; /* id of corresponding symbol */
104 104 uint_t ds_next; /* index of next element in hash chain */
105 105 } dt_sym_t;
106 106
107 107 typedef struct dt_module {
108 108 dt_list_t dm_list; /* list forward/back pointers */
109 109 char dm_name[DTRACE_MODNAMELEN]; /* string name of module */
110 110 char dm_file[MAXPATHLEN]; /* file path of module (if any) */
111 111 struct dt_module *dm_next; /* pointer to next module in hash chain */
112 112 const dt_modops_t *dm_ops; /* pointer to data model's ops vector */
113 113 Elf *dm_elf; /* libelf handle for module object */
114 114 objfs_info_t dm_info; /* object filesystem private info */
115 115 ctf_sect_t dm_symtab; /* symbol table for module */
116 116 ctf_sect_t dm_strtab; /* string table for module */
117 117 ctf_sect_t dm_ctdata; /* CTF data for module */
118 118 ctf_file_t *dm_ctfp; /* CTF container handle */
119 119 uint_t *dm_symbuckets; /* symbol table hash buckets (chain indices) */
120 120 dt_sym_t *dm_symchains; /* symbol table hash chains buffer */
121 121 void *dm_asmap; /* symbol pointers sorted by value */
122 122 uint_t dm_symfree; /* index of next free hash element */
123 123 uint_t dm_nsymbuckets; /* number of elements in bucket array */
124 124 uint_t dm_nsymelems; /* number of elements in hash table */
125 125 uint_t dm_asrsv; /* actual reserved size of dm_asmap */
126 126 uint_t dm_aslen; /* number of entries in dm_asmap */
127 127 uint_t dm_flags; /* module flags (see below) */
128 128 int dm_modid; /* modinfo(1M) module identifier */
129 129 GElf_Addr dm_text_va; /* virtual address of text section */
130 130 GElf_Xword dm_text_size; /* size in bytes of text section */
131 131 GElf_Addr dm_data_va; /* virtual address of data section */
132 132 GElf_Xword dm_data_size; /* size in bytes of data section */
133 133 GElf_Addr dm_bss_va; /* virtual address of BSS */
134 134 GElf_Xword dm_bss_size; /* size in bytes of BSS */
135 135 dt_idhash_t *dm_extern; /* external symbol definitions */
136 136 pid_t dm_pid; /* pid for this module */
137 137 uint_t dm_nctflibs; /* number of ctf children libraries */
138 138 ctf_file_t **dm_libctfp; /* process library ctf pointers */
139 139 char **dm_libctfn; /* names of process ctf containers */
140 140 } dt_module_t;
141 141
142 142 #define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */
143 143 #define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */
144 144 #define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */
145 145
146 146 typedef struct dt_provmod {
147 147 char *dp_name; /* name of provider module */
148 148 struct dt_provmod *dp_next; /* next module */
149 149 } dt_provmod_t;
150 150
151 151 typedef struct dt_ahashent {
152 152 struct dt_ahashent *dtahe_prev; /* prev on hash chain */
153 153 struct dt_ahashent *dtahe_next; /* next on hash chain */
154 154 struct dt_ahashent *dtahe_prevall; /* prev on list of all */
155 155 struct dt_ahashent *dtahe_nextall; /* next on list of all */
156 156 uint64_t dtahe_hashval; /* hash value */
157 157 size_t dtahe_size; /* size of data */
158 158 dtrace_aggdata_t dtahe_data; /* data */
159 159 void (*dtahe_aggregate)(int64_t *, int64_t *, size_t); /* function */
160 160 } dt_ahashent_t;
161 161
162 162 typedef struct dt_ahash {
163 163 dt_ahashent_t **dtah_hash; /* hash table */
164 164 dt_ahashent_t *dtah_all; /* list of all elements */
165 165 size_t dtah_size; /* size of hash table */
166 166 } dt_ahash_t;
167 167
168 168 typedef struct dt_aggregate {
169 169 dtrace_bufdesc_t dtat_buf; /* buf aggregation snapshot */
170 170 int dtat_flags; /* aggregate flags */
171 171 processorid_t dtat_ncpus; /* number of CPUs in aggregate */
172 172 processorid_t *dtat_cpus; /* CPUs in aggregate */
173 173 processorid_t dtat_ncpu; /* size of dtat_cpus array */
174 174 processorid_t dtat_maxcpu; /* maximum number of CPUs */
175 175 dt_ahash_t dtat_hash; /* aggregate hash table */
176 176 } dt_aggregate_t;
177 177
178 178 typedef struct dt_print_aggdata {
179 179 dtrace_hdl_t *dtpa_dtp; /* pointer to libdtrace handle */
180 180 dtrace_aggvarid_t dtpa_id; /* aggregation variable of interest */
181 181 FILE *dtpa_fp; /* file pointer */
182 182 int dtpa_allunprint; /* print only unprinted aggregations */
183 183 int dtpa_agghist; /* print aggregation as histogram */
184 184 int dtpa_agghisthdr; /* aggregation histogram hdr printed */
185 185 int dtpa_aggpack; /* pack quantized aggregations */
186 186 } dt_print_aggdata_t;
187 187
188 188 typedef struct dt_dirpath {
189 189 dt_list_t dir_list; /* linked-list forward/back pointers */
190 190 char *dir_path; /* directory pathname */
191 191 } dt_dirpath_t;
192 192
193 193 typedef struct dt_lib_depend {
194 194 dt_list_t dtld_deplist; /* linked-list forward/back pointers */
195 195 char *dtld_library; /* library name */
196 196 char *dtld_libpath; /* library pathname */
197 197 uint_t dtld_finish; /* completion time in tsort for lib */
198 198 uint_t dtld_start; /* starting time in tsort for lib */
199 199 uint_t dtld_loaded; /* boolean: is this library loaded */
200 200 dt_list_t dtld_dependencies; /* linked-list of lib dependencies */
201 201 dt_list_t dtld_dependents; /* linked-list of lib dependents */
202 202 } dt_lib_depend_t;
203 203
204 204 typedef uint32_t dt_version_t; /* encoded version (see below) */
205 205
206 206 struct dtrace_hdl {
207 207 const dtrace_vector_t *dt_vector; /* library vector, if vectored open */
208 208 void *dt_varg; /* vector argument, if vectored open */
209 209 dtrace_conf_t dt_conf; /* DTrace driver configuration profile */
210 210 char dt_errmsg[BUFSIZ]; /* buffer for formatted syntax error msgs */
211 211 const char *dt_errtag; /* tag used with last call to dt_set_errmsg() */
212 212 dt_pcb_t *dt_pcb; /* pointer to current parsing control block */
213 213 ulong_t dt_gen; /* compiler generation number */
214 214 dt_list_t dt_programs; /* linked list of dtrace_prog_t's */
215 215 dt_list_t dt_xlators; /* linked list of dt_xlator_t's */
216 216 struct dt_xlator **dt_xlatormap; /* dt_xlator_t's indexed by dx_id */
217 217 id_t dt_xlatorid; /* next dt_xlator_t id to assign */
218 218 dt_ident_t *dt_externs; /* linked list of external symbol identifiers */
219 219 dt_idhash_t *dt_macros; /* hash table of macro variable identifiers */
220 220 dt_idhash_t *dt_aggs; /* hash table of aggregation identifiers */
221 221 dt_idhash_t *dt_globals; /* hash table of global identifiers */
222 222 dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */
223 223 dt_list_t dt_modlist; /* linked list of dt_module_t's */
224 224 dt_module_t **dt_mods; /* hash table of dt_module_t's */
225 225 uint_t dt_modbuckets; /* number of module hash buckets */
226 226 uint_t dt_nmods; /* number of modules in hash and list */
227 227 dt_provmod_t *dt_provmod; /* linked list of provider modules */
228 228 dt_module_t *dt_exec; /* pointer to executable module */
229 229 dt_module_t *dt_rtld; /* pointer to run-time linker module */
230 230 dt_module_t *dt_cdefs; /* pointer to C dynamic type module */
231 231 dt_module_t *dt_ddefs; /* pointer to D dynamic type module */
232 232 dt_list_t dt_provlist; /* linked list of dt_provider_t's */
233 233 struct dt_provider **dt_provs; /* hash table of dt_provider_t's */
234 234 uint_t dt_provbuckets; /* number of provider hash buckets */
235 235 uint_t dt_nprovs; /* number of providers in hash and list */
236 236 dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */
237 237 char **dt_proc_env; /* additional environment variables */
238 238 dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */
239 239 ctf_id_t dt_type_func; /* cached CTF identifier for function type */
240 240 ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */
241 241 ctf_id_t dt_type_str; /* cached CTF identifier for string type */
242 242 ctf_id_t dt_type_dyn; /* cached CTF identifier for <DYN> type */
243 243 ctf_id_t dt_type_stack; /* cached CTF identifier for stack type */
244 244 ctf_id_t dt_type_symaddr; /* cached CTF identifier for _symaddr type */
245 245 ctf_id_t dt_type_usymaddr; /* cached CTF ident. for _usymaddr type */
246 246 size_t dt_maxprobe; /* max enabled probe ID */
247 247 dtrace_eprobedesc_t **dt_edesc; /* enabled probe descriptions */
248 248 dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */
249 249 size_t dt_maxagg; /* max aggregation ID */
250 250 dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */
251 251 int dt_maxformat; /* max format ID */
252 252 void **dt_formats; /* pointer to format array */
253 253 int dt_maxstrdata; /* max strdata ID */
254 254 char **dt_strdata; /* pointer to strdata array */
255 255 dt_aggregate_t dt_aggregate; /* aggregate */
256 256 dt_pq_t *dt_bufq; /* CPU-specific data queue */
257 257 struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */
258 258 dt_version_t dt_vmax; /* optional ceiling on program API binding */
259 259 dtrace_attribute_t dt_amin; /* optional floor on program attributes */
260 260 char *dt_cpp_path; /* pathname of cpp(1) to invoke if needed */
261 261 char **dt_cpp_argv; /* argument vector for exec'ing cpp(1) */
262 262 int dt_cpp_argc; /* count of initialized cpp(1) arguments */
263 263 int dt_cpp_args; /* size of dt_cpp_argv[] array */
264 264 char *dt_ld_path; /* pathname of ld(1) to invoke if needed */
265 265 dt_list_t dt_lib_path; /* linked-list forming library search path */
266 266 uint_t dt_lazyload; /* boolean: set via -xlazyload */
267 267 uint_t dt_droptags; /* boolean: set via -xdroptags */
268 268 uint_t dt_active; /* boolean: set once tracing is active */
269 269 uint_t dt_stopped; /* boolean: set once tracing is stopped */
270 270 processorid_t dt_beganon; /* CPU that executed BEGIN probe (if any) */
271 271 processorid_t dt_endedon; /* CPU that executed END probe (if any) */
272 272 uint_t dt_oflags; /* dtrace open-time options (see dtrace.h) */
273 273 uint_t dt_cflags; /* dtrace compile-time options (see dtrace.h) */
274 274 uint_t dt_dflags; /* dtrace link-time options (see dtrace.h) */
275 275 uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */
276 276 uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */
277 277 uint_t dt_linktype; /* dtrace link output file type (see below) */
278 278 uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */
279 279 uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */
280 280 uint_t dt_encoding; /* dtrace output encoding (see below) */
281 281 uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */
282 282 uint64_t dt_options[DTRACEOPT_MAX]; /* dtrace run-time options */
283 283 int dt_version; /* library version requested by client */
284 284 int dt_ctferr; /* error resulting from last CTF failure */
285 285 int dt_errno; /* error resulting from last failed operation */
286 286 int dt_fd; /* file descriptor for dtrace pseudo-device */
287 287 int dt_ftfd; /* file descriptor for fasttrap pseudo-device */
288 288 int dt_fterr; /* saved errno from failed open of dt_ftfd */
289 289 int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */
290 290 int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */
291 291 int dt_stdout_fd; /* file descriptor for saved stdout */
292 292 dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */
293 293 void *dt_errarg; /* error handler argument */
294 294 dtrace_prog_t *dt_errprog; /* error handler program, if any */
295 295 dtrace_handle_drop_f *dt_drophdlr; /* drop handler, if any */
296 296 void *dt_droparg; /* drop handler argument */
297 297 dtrace_handle_proc_f *dt_prochdlr; /* proc handler, if any */
298 298 void *dt_procarg; /* proc handler argument */
299 299 dtrace_handle_setopt_f *dt_setopthdlr; /* setopt handler, if any */
300 300 void *dt_setoptarg; /* setopt handler argument */
301 301 dtrace_status_t dt_status[2]; /* status cache */
302 302 int dt_statusgen; /* current status generation */
303 303 hrtime_t dt_laststatus; /* last status */
304 304 hrtime_t dt_lastswitch; /* last switch of buffer data */
305 305 hrtime_t dt_lastagg; /* last snapshot of aggregation data */
306 306 char *dt_sprintf_buf; /* buffer for dtrace_sprintf() */
307 307 int dt_sprintf_buflen; /* length of dtrace_sprintf() buffer */
308 308 const char *dt_filetag; /* default filetag for dt_set_errmsg() */
309 309 char *dt_buffered_buf; /* buffer for buffered output */
310 310 size_t dt_buffered_offs; /* current offset into buffered buffer */
311 311 size_t dt_buffered_size; /* size of buffered buffer */
312 312 dtrace_handle_buffered_f *dt_bufhdlr; /* buffered handler, if any */
313 313 void *dt_bufarg; /* buffered handler argument */
314 314 dt_dof_t dt_dof; /* DOF generation buffers (see dt_dof.c) */
315 315 struct utsname dt_uts; /* uname(2) information for system */
316 316 dt_list_t dt_lib_dep; /* scratch linked-list of lib dependencies */
317 317 dt_list_t dt_lib_dep_sorted; /* dependency sorted library list */
318 318 dtrace_flowkind_t dt_flow; /* flow kind */
319 319 const char *dt_prefix; /* recommended flow prefix */
320 320 int dt_indent; /* recommended flow indent */
321 321 dtrace_epid_t dt_last_epid; /* most recently consumed EPID */
322 322 uint64_t dt_last_timestamp; /* most recently consumed timestamp */
323 323 };
324 324
325 325 /*
326 326 * Values for the user arg of the ECB.
327 327 */
328 328 #define DT_ECB_DEFAULT 0
329 329 #define DT_ECB_ERROR 1
330 330
331 331 /*
332 332 * Values for the dt_linkmode property, which is used by the assembler when
333 333 * processing external symbol references. User can set using -xlink=<mode>.
334 334 */
335 335 #define DT_LINK_KERNEL 0 /* kernel syms static, user syms dynamic */
336 336 #define DT_LINK_PRIMARY 1 /* primary kernel syms static, others dynamic */
337 337 #define DT_LINK_DYNAMIC 2 /* all symbols dynamic */
338 338 #define DT_LINK_STATIC 3 /* all symbols static */
339 339
340 340 /*
341 341 * Values for the dt_linktype property, which is used by dtrace_program_link()
342 342 * to determine the type of output file that is desired by the client.
343 343 */
344 344 #define DT_LTYP_ELF 0 /* produce ELF containing DOF */
345 345 #define DT_LTYP_DOF 1 /* produce stand-alone DOF */
346 346
347 347 /*
348 348 * Values for the dt_xlatemode property, which is used to determine whether
349 349 * references to dynamic translators are permitted. Set using -xlate=<mode>.
350 350 */
351 351 #define DT_XL_STATIC 0 /* require xlators to be statically defined */
352 352 #define DT_XL_DYNAMIC 1 /* produce references to dynamic translators */
353 353
354 354 /*
355 355 * Values for the dt_stdcmode property, which is used by the compiler when
356 356 * running cpp to determine the presence and setting of the __STDC__ macro.
357 357 */
358 358 #define DT_STDC_XA 0 /* ISO C + K&R C compat w/o ISO: __STDC__=0 */
359 359 #define DT_STDC_XC 1 /* Strict ISO C: __STDC__=1 */
360 360 #define DT_STDC_XS 2 /* K&R C: __STDC__ not defined */
361 361 #define DT_STDC_XT 3 /* ISO C + K&R C compat with ISO: __STDC__=0 */
362 362
363 363 /*
364 364 * Values for the dt_encoding property, which is used to force a particular
365 365 * character encoding (overriding default behavior and/or automatic detection).
366 366 */
367 367 #define DT_ENCODING_UNSET 0
368 368 #define DT_ENCODING_ASCII 1
369 369 #define DT_ENCODING_UTF8 2
370 370
371 371 /*
372 372 * Macro to test whether a given pass bit is set in the dt_treedump bit-vector.
373 373 * If the bit for pass 'p' is set, the D compiler displays the parse tree for
374 374 * the program by printing it to stderr at the end of compiler pass 'p'.
375 375 */
376 376 #define DT_TREEDUMP_PASS(dtp, p) ((dtp)->dt_treedump & (1 << ((p) - 1)))
377 377
378 378 /*
379 379 * Macros for accessing the cached CTF container and type ID for the common
380 380 * types "int", "string", and <DYN>, which we need to use frequently in the D
381 381 * compiler. The DT_INT_* macro relies upon "int" being at index 0 in the
382 382 * _dtrace_ints_* tables in dt_open.c; the others are also set up there.
383 383 */
384 384 #define DT_INT_CTFP(dtp) ((dtp)->dt_ints[0].did_ctfp)
385 385 #define DT_INT_TYPE(dtp) ((dtp)->dt_ints[0].did_type)
386 386
387 387 #define DT_FUNC_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
388 388 #define DT_FUNC_TYPE(dtp) ((dtp)->dt_type_func)
389 389
390 390 #define DT_FPTR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
391 391 #define DT_FPTR_TYPE(dtp) ((dtp)->dt_type_fptr)
392 392
393 393 #define DT_STR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
394 394 #define DT_STR_TYPE(dtp) ((dtp)->dt_type_str)
395 395
396 396 #define DT_DYN_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
397 397 #define DT_DYN_TYPE(dtp) ((dtp)->dt_type_dyn)
398 398
399 399 #define DT_STACK_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
400 400 #define DT_STACK_TYPE(dtp) ((dtp)->dt_type_stack)
401 401
402 402 #define DT_SYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
403 403 #define DT_SYMADDR_TYPE(dtp) ((dtp)->dt_type_symaddr)
404 404
405 405 #define DT_USYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp)
406 406 #define DT_USYMADDR_TYPE(dtp) ((dtp)->dt_type_usymaddr)
407 407
408 408 /*
409 409 * Actions and subroutines are both DT_NODE_FUNC nodes; to avoid confusing
410 410 * an action for a subroutine (or vice versa), we assure that the DT_ACT_*
411 411 * constants and the DIF_SUBR_* constants occupy non-overlapping ranges by
412 412 * starting the DT_ACT_* constants at DIF_SUBR_MAX + 1.
413 413 */
414 414 #define DT_ACT_BASE DIF_SUBR_MAX + 1
415 415 #define DT_ACT(n) (DT_ACT_BASE + (n))
416 416
417 417 #define DT_ACT_PRINTF DT_ACT(0) /* printf() action */
418 418 #define DT_ACT_TRACE DT_ACT(1) /* trace() action */
419 419 #define DT_ACT_TRACEMEM DT_ACT(2) /* tracemem() action */
420 420 #define DT_ACT_STACK DT_ACT(3) /* stack() action */
421 421 #define DT_ACT_STOP DT_ACT(4) /* stop() action */
422 422 #define DT_ACT_BREAKPOINT DT_ACT(5) /* breakpoint() action */
423 423 #define DT_ACT_PANIC DT_ACT(6) /* panic() action */
424 424 #define DT_ACT_SPECULATE DT_ACT(7) /* speculate() action */
425 425 #define DT_ACT_COMMIT DT_ACT(8) /* commit() action */
426 426 #define DT_ACT_DISCARD DT_ACT(9) /* discard() action */
427 427 #define DT_ACT_CHILL DT_ACT(10) /* chill() action */
428 428 #define DT_ACT_EXIT DT_ACT(11) /* exit() action */
429 429 #define DT_ACT_USTACK DT_ACT(12) /* ustack() action */
430 430 #define DT_ACT_PRINTA DT_ACT(13) /* printa() action */
431 431 #define DT_ACT_RAISE DT_ACT(14) /* raise() action */
432 432 #define DT_ACT_CLEAR DT_ACT(15) /* clear() action */
433 433 #define DT_ACT_NORMALIZE DT_ACT(16) /* normalize() action */
434 434 #define DT_ACT_DENORMALIZE DT_ACT(17) /* denormalize() action */
435 435 #define DT_ACT_TRUNC DT_ACT(18) /* trunc() action */
436 436 #define DT_ACT_SYSTEM DT_ACT(19) /* system() action */
437 437 #define DT_ACT_JSTACK DT_ACT(20) /* jstack() action */
438 438 #define DT_ACT_FTRUNCATE DT_ACT(21) /* ftruncate() action */
439 439 #define DT_ACT_FREOPEN DT_ACT(22) /* freopen() action */
440 440 #define DT_ACT_SYM DT_ACT(23) /* sym()/func() actions */
441 441 #define DT_ACT_MOD DT_ACT(24) /* mod() action */
442 442 #define DT_ACT_USYM DT_ACT(25) /* usym()/ufunc() actions */
443 443 #define DT_ACT_UMOD DT_ACT(26) /* umod() action */
444 444 #define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */
445 445 #define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */
446 446 #define DT_ACT_PRINT DT_ACT(29) /* print() action */
447 447
448 448 /*
449 449 * Sentinel to tell freopen() to restore the saved stdout. This must not
450 450 * be ever valid for opening for write access via freopen(3C), which of
451 451 * course, "." never is.
452 452 */
453 453 #define DT_FREOPEN_RESTORE "."
454 454
455 455 #define EDT_BASE 1000 /* base value for libdtrace errnos */
456 456
457 457 enum {
458 458 EDT_VERSION = EDT_BASE, /* client is requesting unsupported version */
459 459 EDT_VERSINVAL, /* version string is invalid or overflows */
460 460 EDT_VERSUNDEF, /* requested API version is not defined */
461 461 EDT_VERSREDUCED, /* requested API version has been reduced */
462 462 EDT_CTF, /* libctf called failed (dt_ctferr has more) */
463 463 EDT_COMPILER, /* error in D program compilation */
464 464 EDT_NOTUPREG, /* tuple register allocation failure */
465 465 EDT_NOMEM, /* memory allocation failure */
466 466 EDT_INT2BIG, /* integer limit exceeded */
467 467 EDT_STR2BIG, /* string limit exceeded */
468 468 EDT_NOMOD, /* unknown module name */
469 469 EDT_NOPROV, /* unknown provider name */
470 470 EDT_NOPROBE, /* unknown probe name */
471 471 EDT_NOSYM, /* unknown symbol name */
472 472 EDT_NOSYMADDR, /* no symbol corresponds to address */
473 473 EDT_NOTYPE, /* unknown type name */
474 474 EDT_NOVAR, /* unknown variable name */
475 475 EDT_NOAGG, /* unknown aggregation name */
476 476 EDT_BADSCOPE, /* improper use of type name scoping operator */
477 477 EDT_BADSPEC, /* overspecified probe description */
478 478 EDT_BADSPCV, /* bad macro variable in probe description */
479 479 EDT_BADID, /* invalid probe identifier */
480 480 EDT_NOTLOADED, /* module is not currently loaded */
481 481 EDT_NOCTF, /* module does not contain any CTF data */
482 482 EDT_DATAMODEL, /* module and program data models don't match */
483 483 EDT_DIFVERS, /* library has newer DIF version than driver */
484 484 EDT_BADAGG, /* unrecognized aggregating action */
485 485 EDT_FIO, /* file i/o error */
486 486 EDT_DIFINVAL, /* invalid DIF program */
487 487 EDT_DIFSIZE, /* invalid DIF size */
488 488 EDT_DIFFAULT, /* failed to copyin DIF program */
489 489 EDT_BADPROBE, /* bad probe description */
490 490 EDT_BADPGLOB, /* bad probe description globbing pattern */
491 491 EDT_NOSCOPE, /* declaration scope stack underflow */
492 492 EDT_NODECL, /* declaration stack underflow */
493 493 EDT_DMISMATCH, /* record list does not match statement */
494 494 EDT_DOFFSET, /* record data offset error */
495 495 EDT_DALIGN, /* record data alignment error */
496 496 EDT_BADOPTNAME, /* invalid dtrace_setopt option name */
497 497 EDT_BADOPTVAL, /* invalid dtrace_setopt option value */
498 498 EDT_BADOPTCTX, /* invalid dtrace_setopt option context */
499 499 EDT_CPPFORK, /* failed to fork preprocessor */
500 500 EDT_CPPEXEC, /* failed to exec preprocessor */
501 501 EDT_CPPENT, /* preprocessor not found */
502 502 EDT_CPPERR, /* unknown preprocessor error */
503 503 EDT_SYMOFLOW, /* external symbol table overflow */
504 504 EDT_ACTIVE, /* operation illegal when tracing is active */
505 505 EDT_DESTRUCTIVE, /* destructive actions not allowed */
506 506 EDT_NOANON, /* no anonymous tracing state */
507 507 EDT_ISANON, /* can't claim anon state and enable probes */
508 508 EDT_ENDTOOBIG, /* END enablings exceed size of prncpl buffer */
509 509 EDT_NOCONV, /* failed to load type for printf conversion */
510 510 EDT_BADCONV, /* incomplete printf conversion */
511 511 EDT_BADERROR, /* invalid library ERROR action */
512 512 EDT_ERRABORT, /* abort due to error */
513 513 EDT_DROPABORT, /* abort due to drop */
514 514 EDT_DIRABORT, /* abort explicitly directed */
515 515 EDT_BADRVAL, /* invalid return value from callback */
516 516 EDT_BADNORMAL, /* invalid normalization */
517 517 EDT_BUFTOOSMALL, /* enabling exceeds size of buffer */
518 518 EDT_BADTRUNC, /* invalid truncation */
519 519 EDT_BUSY, /* device busy (active kernel debugger) */
520 520 EDT_ACCESS, /* insufficient privileges to use DTrace */
521 521 EDT_NOENT, /* dtrace device not available */
522 522 EDT_BRICKED, /* abort due to systemic unresponsiveness */
↓ open down ↓ |
522 lines elided |
↑ open up ↑ |
523 523 EDT_HARDWIRE, /* failed to load hard-wired definitions */
524 524 EDT_ELFVERSION, /* libelf is out-of-date w.r.t libdtrace */
525 525 EDT_NOBUFFERED, /* attempt to buffer output without handler */
526 526 EDT_UNSTABLE, /* description matched unstable set of probes */
527 527 EDT_BADSETOPT, /* invalid setopt library action */
528 528 EDT_BADSTACKPC, /* invalid stack program counter size */
529 529 EDT_BADAGGVAR, /* invalid aggregation variable identifier */
530 530 EDT_OVERSION, /* client is requesting deprecated version */
531 531 EDT_ENABLING_ERR, /* failed to enable probe */
532 532 EDT_NOPROBES, /* no probes sites for declared provider */
533 - EDT_CANTLOAD /* failed to load a module */
533 + EDT_CANTLOAD, /* failed to load a module */
534 + EDT_BADCTF /* module contains invalid CTF */
534 535 };
535 536
536 537 /*
537 538 * Interfaces for parsing and comparing DTrace attribute tuples, which describe
538 539 * stability and architectural binding information. The dtrace_attribute_t
539 540 * structure and associated constant definitions are found in <sys/dtrace.h>.
540 541 */
541 542 extern dtrace_attribute_t dt_attr_min(dtrace_attribute_t, dtrace_attribute_t);
542 543 extern dtrace_attribute_t dt_attr_max(dtrace_attribute_t, dtrace_attribute_t);
543 544 extern char *dt_attr_str(dtrace_attribute_t, char *, size_t);
544 545 extern int dt_attr_cmp(dtrace_attribute_t, dtrace_attribute_t);
545 546
546 547 /*
547 548 * Interfaces for parsing and handling DTrace version strings. Version binding
548 549 * is a feature of the D compiler that is handled completely independently of
549 550 * the DTrace kernel infrastructure, so the definitions are here in libdtrace.
550 551 * Version strings are compiled into an encoded uint32_t which can be compared
551 552 * using C comparison operators. Version definitions are found in dt_open.c.
552 553 */
553 554 #define DT_VERSION_STRMAX 16 /* enough for "255.4095.4095\0" */
554 555 #define DT_VERSION_MAJMAX 0xFF /* maximum major version number */
555 556 #define DT_VERSION_MINMAX 0xFFF /* maximum minor version number */
556 557 #define DT_VERSION_MICMAX 0xFFF /* maximum micro version number */
557 558
558 559 #define DT_VERSION_NUMBER(M, m, u) \
559 560 ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF))
560 561
561 562 #define DT_VERSION_MAJOR(v) (((v) & 0xFF000000) >> 24)
562 563 #define DT_VERSION_MINOR(v) (((v) & 0x00FFF000) >> 12)
563 564 #define DT_VERSION_MICRO(v) ((v) & 0x00000FFF)
564 565
565 566 extern char *dt_version_num2str(dt_version_t, char *, size_t);
566 567 extern int dt_version_str2num(const char *, dt_version_t *);
567 568 extern int dt_version_defined(dt_version_t);
568 569
569 570 /*
570 571 * Miscellaneous internal libdtrace interfaces. The definitions below are for
571 572 * libdtrace routines that do not yet merit their own separate header file.
572 573 */
573 574 extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *);
574 575 extern char *dt_cpp_pop_arg(dtrace_hdl_t *);
575 576
576 577 extern int dt_set_errno(dtrace_hdl_t *, int);
577 578 extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *,
578 579 const char *, int, const char *, va_list);
579 580
580 581 extern int dt_ioctl(dtrace_hdl_t *, int, void *);
581 582 extern int dt_status(dtrace_hdl_t *, processorid_t);
582 583 extern long dt_sysconf(dtrace_hdl_t *, int);
583 584 extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t);
584 585 extern int dt_printf(dtrace_hdl_t *, FILE *, const char *, ...);
585 586
586 587 extern void *dt_zalloc(dtrace_hdl_t *, size_t);
587 588 extern void *dt_alloc(dtrace_hdl_t *, size_t);
588 589 extern void dt_free(dtrace_hdl_t *, void *);
589 590 extern void dt_difo_free(dtrace_hdl_t *, dtrace_difo_t *);
590 591
591 592 extern int dt_gmatch(const char *, const char *);
592 593 extern char *dt_basename(char *);
593 594
594 595 extern ulong_t dt_popc(ulong_t);
595 596 extern ulong_t dt_popcb(const ulong_t *, ulong_t);
596 597
597 598 extern int dt_buffered_enable(dtrace_hdl_t *);
598 599 extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *,
599 600 const dtrace_recdesc_t *, const dtrace_aggdata_t *, uint32_t flags);
600 601 extern void dt_buffered_disable(dtrace_hdl_t *);
601 602 extern void dt_buffered_destroy(dtrace_hdl_t *);
602 603
603 604 extern uint64_t dt_stddev(uint64_t *, uint64_t);
604 605
605 606 extern int dt_options_load(dtrace_hdl_t *);
606 607
607 608 extern void dt_dprintf(const char *, ...);
608 609
609 610 extern void dt_setcontext(dtrace_hdl_t *, dtrace_probedesc_t *);
610 611 extern void dt_endcontext(dtrace_hdl_t *);
611 612
612 613 extern void dt_pragma(dt_node_t *);
613 614 extern int dt_reduce(dtrace_hdl_t *, dt_version_t);
614 615 extern void dt_cg(dt_pcb_t *, dt_node_t *);
615 616 extern dtrace_difo_t *dt_as(dt_pcb_t *);
616 617 extern void dt_dis(const dtrace_difo_t *, FILE *);
617 618
618 619 extern int dt_aggregate_go(dtrace_hdl_t *);
619 620 extern int dt_aggregate_init(dtrace_hdl_t *);
620 621 extern void dt_aggregate_destroy(dtrace_hdl_t *);
621 622
622 623 extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t,
623 624 dtrace_eprobedesc_t **, dtrace_probedesc_t **);
624 625 extern void dt_epid_destroy(dtrace_hdl_t *);
625 626 extern int dt_aggid_lookup(dtrace_hdl_t *, dtrace_aggid_t, dtrace_aggdesc_t **);
626 627 extern void dt_aggid_destroy(dtrace_hdl_t *);
627 628
628 629 extern void *dt_format_lookup(dtrace_hdl_t *, int);
629 630 extern void dt_format_destroy(dtrace_hdl_t *);
630 631
631 632 extern const char *dt_strdata_lookup(dtrace_hdl_t *, int);
632 633 extern void dt_strdata_destroy(dtrace_hdl_t *);
633 634
634 635 extern int dt_print_quantize(dtrace_hdl_t *, FILE *,
635 636 const void *, size_t, uint64_t);
636 637 extern int dt_print_lquantize(dtrace_hdl_t *, FILE *,
637 638 const void *, size_t, uint64_t);
638 639 extern int dt_print_llquantize(dtrace_hdl_t *, FILE *,
639 640 const void *, size_t, uint64_t);
640 641 extern int dt_print_agg(const dtrace_aggdata_t *, void *);
641 642
642 643 extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *);
643 644 extern int dt_handle_liberr(dtrace_hdl_t *,
644 645 const dtrace_probedata_t *, const char *);
645 646 extern int dt_handle_cpudrop(dtrace_hdl_t *, processorid_t,
646 647 dtrace_dropkind_t, uint64_t);
647 648 extern int dt_handle_status(dtrace_hdl_t *,
648 649 dtrace_status_t *, dtrace_status_t *);
649 650 extern int dt_handle_setopt(dtrace_hdl_t *, dtrace_setoptdata_t *);
650 651
651 652 extern int dt_lib_depend_add(dtrace_hdl_t *, dt_list_t *, const char *);
652 653 extern dt_lib_depend_t *dt_lib_depend_lookup(dt_list_t *, const char *);
653 654
654 655 extern dt_pcb_t *yypcb; /* pointer to current parser control block */
655 656 extern char yyintprefix; /* int token prefix for macros (+/-) */
656 657 extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */
657 658 extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */
658 659 extern char yytext[]; /* lex input buffer */
659 660 extern int yylineno; /* lex line number */
660 661 extern int yydebug; /* lex debugging */
661 662 extern dt_node_t *yypragma; /* lex token list for control lines */
662 663
663 664 extern const dtrace_attribute_t _dtrace_maxattr; /* maximum attributes */
664 665 extern const dtrace_attribute_t _dtrace_defattr; /* default attributes */
665 666 extern const dtrace_attribute_t _dtrace_symattr; /* symbol ref attributes */
666 667 extern const dtrace_attribute_t _dtrace_typattr; /* type ref attributes */
667 668 extern const dtrace_attribute_t _dtrace_prvattr; /* provider attributes */
668 669 extern const dtrace_pattr_t _dtrace_prvdesc; /* provider attribute bundle */
669 670
670 671 extern const dt_version_t _dtrace_versions[]; /* array of valid versions */
671 672 extern const char *const _dtrace_version; /* current version string */
672 673
673 674 extern int _dtrace_strbuckets; /* number of hash buckets for strings */
674 675 extern int _dtrace_intbuckets; /* number of hash buckets for ints */
675 676 extern uint_t _dtrace_stkindent; /* default indent for stack/ustack */
676 677 extern uint_t _dtrace_pidbuckets; /* number of hash buckets for pids */
677 678 extern uint_t _dtrace_pidlrulim; /* number of proc handles to cache */
678 679 extern int _dtrace_debug; /* debugging messages enabled */
679 680 extern size_t _dtrace_bufsize; /* default dt_buf_create() size */
680 681 extern int _dtrace_argmax; /* default maximum probe arguments */
681 682
682 683 extern const char *_dtrace_libdir; /* default library directory */
683 684 extern const char *_dtrace_moddir; /* default kernel module directory */
684 685
685 686 #ifdef __cplusplus
686 687 }
687 688 #endif
688 689
689 690 #endif /* _DT_IMPL_H */
↓ open down ↓ |
146 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX