xref: /titanic_50/usr/src/lib/libdtrace/common/dtrace.h (revision f22acdfff536d452df49dd85c5ecd42092b8fcad)
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 #ifndef	_DTRACE_H
28 #define	_DTRACE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/dtrace.h>
33 #include <stdarg.h>
34 #include <stdio.h>
35 #include <gelf.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * DTrace Dynamic Tracing Software: Library Interfaces
43  *
44  * Note: The contents of this file are private to the implementation of the
45  * Solaris system and DTrace subsystem and are subject to change at any time
46  * without notice.  Applications and drivers using these interfaces will fail
47  * to run on future releases.  These interfaces should not be used for any
48  * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
49  * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
50  */
51 
52 #define	DTRACE_VERSION	1		/* library ABI interface version */
53 
54 struct ps_prochandle;
55 typedef struct dtrace_hdl dtrace_hdl_t;
56 typedef struct dtrace_prog dtrace_prog_t;
57 typedef struct dtrace_vector dtrace_vector_t;
58 typedef struct dtrace_aggdata dtrace_aggdata_t;
59 typedef int64_t dtrace_aggvarid_t;
60 
61 #define	DTRACE_O_NODEV		0x01	/* do not open dtrace(7D) device */
62 #define	DTRACE_O_NOSYS		0x02	/* do not load /system/object modules */
63 #define	DTRACE_O_LP64		0x04	/* force D compiler to be LP64 */
64 #define	DTRACE_O_ILP32		0x08	/* force D compiler to be ILP32 */
65 #define	DTRACE_O_MASK		0x0f	/* mask of valid flags to dtrace_open */
66 
67 extern dtrace_hdl_t *dtrace_open(int, int, int *);
68 extern dtrace_hdl_t *dtrace_vopen(int, int, int *,
69     const dtrace_vector_t *, void *);
70 
71 extern int dtrace_go(dtrace_hdl_t *);
72 extern int dtrace_stop(dtrace_hdl_t *);
73 extern void dtrace_sleep(dtrace_hdl_t *);
74 extern void dtrace_close(dtrace_hdl_t *);
75 
76 extern int dtrace_errno(dtrace_hdl_t *);
77 extern const char *dtrace_errmsg(dtrace_hdl_t *, int);
78 extern const char *dtrace_faultstr(dtrace_hdl_t *, int);
79 extern const char *dtrace_subrstr(dtrace_hdl_t *, int);
80 
81 extern int dtrace_setopt(dtrace_hdl_t *, const char *, const char *);
82 extern int dtrace_getopt(dtrace_hdl_t *, const char *, dtrace_optval_t *);
83 
84 extern void dtrace_update(dtrace_hdl_t *);
85 extern int dtrace_ctlfd(dtrace_hdl_t *);
86 
87 /*
88  * DTrace Program Interface
89  *
90  * DTrace programs can be created by compiling ASCII text files containing
91  * D programs or by compiling in-memory C strings that specify a D program.
92  * Once created, callers can examine the list of program statements and
93  * enable the probes and actions described by these statements.
94  */
95 
96 typedef struct dtrace_proginfo {
97 	dtrace_attribute_t dpi_descattr; /* minimum probedesc attributes */
98 	dtrace_attribute_t dpi_stmtattr; /* minimum statement attributes */
99 	uint_t dpi_aggregates;	/* number of aggregates specified in program */
100 	uint_t dpi_recgens;	/* number of record generating probes in prog */
101 	uint_t dpi_matches;	/* number of probes matched by program */
102 	uint_t dpi_speculations; /* number of speculations specified in prog */
103 } dtrace_proginfo_t;
104 
105 #define	DTRACE_C_DIFV	0x0001	/* DIF verbose mode: show each compiled DIFO */
106 #define	DTRACE_C_EMPTY	0x0002	/* Permit compilation of empty D source files */
107 #define	DTRACE_C_ZDEFS	0x0004	/* Permit probe defs that match zero probes */
108 #define	DTRACE_C_EATTR	0x0008	/* Error if program attributes less than min */
109 #define	DTRACE_C_CPP	0x0010	/* Preprocess input file with cpp(1) utility */
110 #define	DTRACE_C_KNODEF	0x0020	/* Permit unresolved kernel symbols in DIFO */
111 #define	DTRACE_C_UNODEF	0x0040	/* Permit unresolved user symbols in DIFO */
112 #define	DTRACE_C_PSPEC	0x0080	/* Intepret ambiguous specifiers as probes */
113 #define	DTRACE_C_ETAGS	0x0100	/* Prefix error messages with error tags */
114 #define	DTRACE_C_ARGREF	0x0200	/* Do not require all macro args to be used */
115 #define	DTRACE_C_DEFARG	0x0800	/* Use 0/"" as value for unspecified args */
116 #define	DTRACE_C_NOLIBS	0x1000	/* Do not process D system libraries */
117 #define	DTRACE_C_MASK	0x1bff	/* mask of all valid flags to dtrace_*compile */
118 
119 extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *,
120     const char *, dtrace_probespec_t, uint_t, int, char *const []);
121 
122 extern dtrace_prog_t *dtrace_program_fcompile(dtrace_hdl_t *,
123     FILE *, uint_t, int, char *const []);
124 
125 extern int dtrace_program_exec(dtrace_hdl_t *, dtrace_prog_t *,
126     dtrace_proginfo_t *);
127 extern void dtrace_program_info(dtrace_hdl_t *, dtrace_prog_t *,
128     dtrace_proginfo_t *);
129 
130 #define	DTRACE_D_STRIP	0x01	/* strip non-loadable sections from program */
131 #define	DTRACE_D_PROBES	0x02	/* include provider and probe definitions */
132 #define	DTRACE_D_MASK	0x03	/* mask of valid flags to dtrace_dof_create */
133 
134 extern int dtrace_program_link(dtrace_hdl_t *, dtrace_prog_t *,
135     uint_t, const char *, int, char *const []);
136 
137 extern void *dtrace_dof_create(dtrace_hdl_t *, dtrace_prog_t *, uint_t);
138 extern void dtrace_dof_destroy(dtrace_hdl_t *, void *);
139 
140 extern void *dtrace_getopt_dof(dtrace_hdl_t *);
141 extern void *dtrace_geterr_dof(dtrace_hdl_t *);
142 
143 typedef struct dtrace_stmtdesc {
144 	dtrace_ecbdesc_t *dtsd_ecbdesc;		/* ECB description */
145 	dtrace_actdesc_t *dtsd_action;		/* action list */
146 	dtrace_actdesc_t *dtsd_action_last;	/* last action in action list */
147 	void *dtsd_aggdata;			/* aggregation data */
148 	void *dtsd_fmtdata;			/* type-specific output data */
149 	void (*dtsd_callback)();		/* callback function for EPID */
150 	void *dtsd_data;			/* callback data pointer */
151 	dtrace_attribute_t dtsd_descattr;	/* probedesc attributes */
152 	dtrace_attribute_t dtsd_stmtattr;	/* statement attributes */
153 } dtrace_stmtdesc_t;
154 
155 typedef int dtrace_stmt_f(dtrace_hdl_t *, dtrace_prog_t *,
156     dtrace_stmtdesc_t *, void *);
157 
158 extern dtrace_stmtdesc_t *dtrace_stmt_create(dtrace_hdl_t *,
159     dtrace_ecbdesc_t *);
160 extern dtrace_actdesc_t *dtrace_stmt_action(dtrace_hdl_t *,
161     dtrace_stmtdesc_t *);
162 extern int dtrace_stmt_add(dtrace_hdl_t *, dtrace_prog_t *,
163     dtrace_stmtdesc_t *);
164 extern int dtrace_stmt_iter(dtrace_hdl_t *, dtrace_prog_t *,
165     dtrace_stmt_f *, void *);
166 extern void dtrace_stmt_destroy(dtrace_hdl_t *, dtrace_stmtdesc_t *);
167 
168 /*
169  * DTrace Data Consumption Interface
170  */
171 typedef enum {
172 	DTRACEFLOW_ENTRY,
173 	DTRACEFLOW_RETURN,
174 	DTRACEFLOW_NONE
175 } dtrace_flowkind_t;
176 
177 #define	DTRACE_CONSUME_ERROR		-1	/* error while processing */
178 #define	DTRACE_CONSUME_THIS		0	/* consume this probe/record */
179 #define	DTRACE_CONSUME_NEXT		1	/* advance to next probe/rec */
180 #define	DTRACE_CONSUME_ABORT		2	/* abort consumption */
181 
182 typedef struct dtrace_probedata {
183 	dtrace_hdl_t *dtpda_handle;		/* handle to DTrace library */
184 	dtrace_eprobedesc_t *dtpda_edesc;	/* enabled probe description */
185 	dtrace_probedesc_t *dtpda_pdesc;	/* probe description */
186 	processorid_t dtpda_cpu;		/* CPU for data */
187 	caddr_t dtpda_data;			/* pointer to raw data */
188 	dtrace_flowkind_t dtpda_flow;		/* flow kind */
189 	const char *dtpda_prefix;		/* recommended flow prefix */
190 	int dtpda_indent;			/* recommended flow indent */
191 } dtrace_probedata_t;
192 
193 typedef int dtrace_consume_probe_f(const dtrace_probedata_t *, void *);
194 typedef int dtrace_consume_rec_f(const dtrace_probedata_t *,
195     const dtrace_recdesc_t *, void *);
196 
197 extern int dtrace_consume(dtrace_hdl_t *, FILE *,
198     dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
199 
200 #define	DTRACE_STATUS_NONE	0	/* no status; not yet time */
201 #define	DTRACE_STATUS_OKAY	1	/* status okay */
202 #define	DTRACE_STATUS_EXITED	2	/* exit() was called; tracing stopped */
203 #define	DTRACE_STATUS_FILLED	3	/* fill buffer filled; tracing stoped */
204 #define	DTRACE_STATUS_STOPPED	4	/* tracing already stopped */
205 
206 extern int dtrace_status(dtrace_hdl_t *);
207 
208 /*
209  * DTrace Formatted Output Interfaces
210  *
211  * To format output associated with a given dtrace_stmtdesc, the caller can
212  * invoke one of the following functions, passing the opaque dtsd_fmtdata and a
213  * list of record descriptions.  These functions return either -1 to indicate
214  * an error, or a positive integer indicating the number of records consumed.
215  * For anonymous enablings, the consumer can use the dtrd_format member of
216  * the record description to obtain a format description.  The dtfd_string
217  * member of the format description may be passed to dtrace_print{fa}_create()
218  * to create the opaque format data.
219  */
220 extern void *dtrace_printf_create(dtrace_hdl_t *, const char *);
221 extern void *dtrace_printa_create(dtrace_hdl_t *, const char *);
222 extern size_t dtrace_printf_format(dtrace_hdl_t *, void *, char *, size_t);
223 
224 extern int dtrace_fprintf(dtrace_hdl_t *, FILE *, void *,
225     const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
226     const void *, size_t);
227 
228 extern int dtrace_fprinta(dtrace_hdl_t *, FILE *, void *,
229     const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
230     const void *, size_t);
231 
232 extern int dtrace_system(dtrace_hdl_t *, FILE *, void *,
233     const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
234     const void *, size_t);
235 
236 extern int dtrace_freopen(dtrace_hdl_t *, FILE *, void *,
237     const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t,
238     const void *, size_t);
239 
240 /*
241  * DTrace Work Interface
242  */
243 typedef enum {
244 	DTRACE_WORKSTATUS_ERROR = -1,
245 	DTRACE_WORKSTATUS_OKAY,
246 	DTRACE_WORKSTATUS_DONE
247 } dtrace_workstatus_t;
248 
249 extern dtrace_workstatus_t dtrace_work(dtrace_hdl_t *, FILE *,
250     dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
251 
252 /*
253  * DTrace Handler Interface
254  */
255 #define	DTRACE_HANDLE_ABORT		-1	/* abort current operation */
256 #define	DTRACE_HANDLE_OK		0	/* handled okay; continue */
257 
258 typedef struct dtrace_errdata {
259 	dtrace_hdl_t *dteda_handle;		/* handle to DTrace library */
260 	dtrace_eprobedesc_t *dteda_edesc;	/* enabled probe inducing err */
261 	dtrace_probedesc_t *dteda_pdesc;	/* probe inducing error */
262 	processorid_t dteda_cpu;		/* CPU of error */
263 	int dteda_action;			/* action inducing error */
264 	int dteda_offset;			/* offset in DIFO of error */
265 	int dteda_fault;			/* specific fault */
266 	uint64_t dteda_addr;			/* address of fault, if any */
267 	const char *dteda_msg;			/* preconstructed message */
268 } dtrace_errdata_t;
269 
270 typedef int dtrace_handle_err_f(dtrace_errdata_t *, void *);
271 extern int dtrace_handle_err(dtrace_hdl_t *, dtrace_handle_err_f *, void *);
272 
273 typedef enum {
274 	DTRACEDROP_PRINCIPAL,			/* drop to principal buffer */
275 	DTRACEDROP_AGGREGATION,			/* drop to aggregation buffer */
276 	DTRACEDROP_DYNAMIC,			/* dynamic drop */
277 	DTRACEDROP_DYNRINSE,			/* dyn drop due to rinsing */
278 	DTRACEDROP_DYNDIRTY,			/* dyn drop due to dirty */
279 	DTRACEDROP_SPEC,			/* speculative drop */
280 	DTRACEDROP_SPECBUSY,			/* spec drop due to busy */
281 	DTRACEDROP_SPECUNAVAIL			/* spec drop due to unavail */
282 } dtrace_dropkind_t;
283 
284 typedef struct dtrace_dropdata {
285 	dtrace_hdl_t *dtdda_handle;		/* handle to DTrace library */
286 	processorid_t dtdda_cpu;		/* CPU, if any */
287 	dtrace_dropkind_t dtdda_kind;		/* kind of drop */
288 	uint64_t dtdda_drops;			/* number of drops */
289 	uint64_t dtdda_total;			/* total drops */
290 	const char *dtdda_msg;			/* preconstructed message */
291 } dtrace_dropdata_t;
292 
293 typedef int dtrace_handle_drop_f(dtrace_dropdata_t *, void *);
294 extern int dtrace_handle_drop(dtrace_hdl_t *, dtrace_handle_drop_f *, void *);
295 
296 typedef void dtrace_handle_proc_f(struct ps_prochandle *, void *);
297 extern int dtrace_handle_proc(dtrace_hdl_t *, dtrace_handle_proc_f *, void *);
298 
299 typedef struct dtrace_bufdata {
300 	dtrace_hdl_t *dtbda_handle;		/* handle to DTrace library */
301 	const char *dtbda_buffered;		/* buffered output */
302 	dtrace_probedata_t *dtbda_probe;	/* probe data */
303 	dtrace_recdesc_t *dtbda_recdesc;	/* record description */
304 	dtrace_aggdata_t *dtbda_aggdata;	/* aggregation data, if agg. */
305 } dtrace_bufdata_t;
306 
307 typedef int dtrace_handle_buffered_f(dtrace_bufdata_t *, void *);
308 extern int dtrace_handle_buffered(dtrace_hdl_t *,
309     dtrace_handle_buffered_f *, void *);
310 
311 /*
312  * DTrace Aggregate Interface
313  */
314 
315 #define	DTRACE_A_PERCPU		0x0001
316 #define	DTRACE_A_KEEPDELTA	0x0002
317 #define	DTRACE_A_ANONYMOUS	0x0004
318 
319 #define	DTRACE_AGGWALK_ERROR		-1	/* error while processing */
320 #define	DTRACE_AGGWALK_NEXT		0	/* proceed to next element */
321 #define	DTRACE_AGGWALK_ABORT		1	/* abort aggregation walk */
322 #define	DTRACE_AGGWALK_CLEAR		2	/* clear this element */
323 #define	DTRACE_AGGWALK_NORMALIZE	3	/* normalize this element */
324 #define	DTRACE_AGGWALK_DENORMALIZE	4	/* denormalize this element */
325 #define	DTRACE_AGGWALK_REMOVE		5	/* remove this element */
326 
327 struct dtrace_aggdata {
328 	dtrace_hdl_t *dtada_handle;		/* handle to DTrace library */
329 	dtrace_aggdesc_t *dtada_desc;		/* aggregation description */
330 	dtrace_eprobedesc_t *dtada_edesc;	/* enabled probe description */
331 	dtrace_probedesc_t *dtada_pdesc;	/* probe description */
332 	caddr_t dtada_data;			/* pointer to raw data */
333 	uint64_t dtada_normal;			/* the normal -- 1 for denorm */
334 	size_t dtada_size;			/* total size of the data */
335 	caddr_t dtada_delta;			/* delta data, if available */
336 	caddr_t *dtada_percpu;			/* per CPU data, if avail */
337 	caddr_t *dtada_percpu_delta;		/* per CPU delta, if avail */
338 };
339 
340 typedef int dtrace_aggregate_f(dtrace_aggdata_t *, void *);
341 typedef int dtrace_aggregate_walk_f(dtrace_hdl_t *,
342     dtrace_aggregate_f *, void *);
343 
344 extern void dtrace_aggregate_clear(dtrace_hdl_t *);
345 extern int dtrace_aggregate_snap(dtrace_hdl_t *);
346 extern int dtrace_aggregate_print(dtrace_hdl_t *, FILE *,
347     dtrace_aggregate_walk_f *);
348 
349 extern int dtrace_aggregate_walk(dtrace_hdl_t *, dtrace_aggregate_f *, void *);
350 
351 extern int dtrace_aggregate_walk_keysorted(dtrace_hdl_t *,
352     dtrace_aggregate_f *, void *);
353 
354 extern int dtrace_aggregate_walk_valsorted(dtrace_hdl_t *,
355     dtrace_aggregate_f *, void *);
356 
357 extern int dtrace_aggregate_walk_keyvarsorted(dtrace_hdl_t *,
358     dtrace_aggregate_f *, void *);
359 
360 extern int dtrace_aggregate_walk_valvarsorted(dtrace_hdl_t *,
361     dtrace_aggregate_f *, void *);
362 
363 extern int dtrace_aggregate_walk_keyrevsorted(dtrace_hdl_t *,
364     dtrace_aggregate_f *, void *);
365 
366 extern int dtrace_aggregate_walk_valrevsorted(dtrace_hdl_t *,
367     dtrace_aggregate_f *, void *);
368 
369 extern int dtrace_aggregate_walk_keyvarrevsorted(dtrace_hdl_t *,
370     dtrace_aggregate_f *, void *);
371 
372 extern int dtrace_aggregate_walk_valvarrevsorted(dtrace_hdl_t *,
373     dtrace_aggregate_f *, void *);
374 
375 #define	DTRACE_AGD_PRINTED	0x1	/* aggregation printed in program */
376 
377 /*
378  * DTrace Process Control Interface
379  *
380  * Library clients who wish to have libdtrace create or grab processes for
381  * monitoring of their symbol table changes may use these interfaces to
382  * request that libdtrace obtain control of the process using libproc.
383  */
384 
385 extern struct ps_prochandle *dtrace_proc_create(dtrace_hdl_t *,
386     const char *, char *const *);
387 
388 extern struct ps_prochandle *dtrace_proc_grab(dtrace_hdl_t *, pid_t, int);
389 extern void dtrace_proc_release(dtrace_hdl_t *, struct ps_prochandle *);
390 extern void dtrace_proc_continue(dtrace_hdl_t *, struct ps_prochandle *);
391 
392 /*
393  * DTrace Object, Symbol, and Type Interfaces
394  *
395  * Library clients can use libdtrace to perform symbol and C type information
396  * lookups by symbol name, symbol address, or C type name, or to lookup meta-
397  * information cached for each of the program objects in use by DTrace.  The
398  * resulting struct contain pointers to arbitrary-length strings, including
399  * object, symbol, and type names, that are persistent until the next call to
400  * dtrace_update().  Once dtrace_update() is called, any cached values must
401  * be flushed and not used subsequently by the client program.
402  */
403 
404 #define	DTRACE_OBJ_EXEC	 ((const char *)0L)	/* primary executable file */
405 #define	DTRACE_OBJ_RTLD	 ((const char *)1L)	/* run-time link-editor */
406 #define	DTRACE_OBJ_CDEFS ((const char *)2L)	/* C include definitions */
407 #define	DTRACE_OBJ_DDEFS ((const char *)3L)	/* D program definitions */
408 #define	DTRACE_OBJ_EVERY ((const char *)-1L)	/* all known objects */
409 #define	DTRACE_OBJ_KMODS ((const char *)-2L)	/* all kernel objects */
410 #define	DTRACE_OBJ_UMODS ((const char *)-3L)	/* all user objects */
411 
412 typedef struct dtrace_objinfo {
413 	const char *dto_name;			/* object file scope name */
414 	const char *dto_file;			/* object file path (if any) */
415 	int dto_id;				/* object file id (if any) */
416 	uint_t dto_flags;			/* object flags (see below) */
417 	GElf_Addr dto_text_va;			/* address of text section */
418 	GElf_Xword dto_text_size;		/* size of text section */
419 	GElf_Addr dto_data_va;			/* address of data section */
420 	GElf_Xword dto_data_size;		/* size of data section */
421 	GElf_Addr dto_bss_va;			/* address of BSS */
422 	GElf_Xword dto_bss_size;		/* size of BSS */
423 } dtrace_objinfo_t;
424 
425 #define	DTRACE_OBJ_F_KERNEL	0x1		/* object is a kernel module */
426 #define	DTRACE_OBJ_F_PRIMARY	0x2		/* object is a primary module */
427 
428 typedef int dtrace_obj_f(dtrace_hdl_t *, const dtrace_objinfo_t *, void *);
429 
430 extern int dtrace_object_iter(dtrace_hdl_t *, dtrace_obj_f *, void *);
431 extern int dtrace_object_info(dtrace_hdl_t *, const char *, dtrace_objinfo_t *);
432 
433 typedef struct dtrace_syminfo {
434 	const char *dts_object;			/* object name */
435 	const char *dts_name;			/* symbol name */
436 	ulong_t dts_id;				/* symbol id */
437 } dtrace_syminfo_t;
438 
439 extern int dtrace_lookup_by_name(dtrace_hdl_t *, const char *, const char *,
440     GElf_Sym *, dtrace_syminfo_t *);
441 
442 extern int dtrace_lookup_by_addr(dtrace_hdl_t *, GElf_Addr addr,
443     GElf_Sym *, dtrace_syminfo_t *);
444 
445 typedef struct dtrace_typeinfo {
446 	const char *dtt_object;			/* object containing type */
447 	ctf_file_t *dtt_ctfp;			/* CTF container handle */
448 	ctf_id_t dtt_type;			/* CTF type identifier */
449 } dtrace_typeinfo_t;
450 
451 extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
452     dtrace_typeinfo_t *);
453 
454 extern int dtrace_symbol_type(dtrace_hdl_t *, const GElf_Sym *,
455     const dtrace_syminfo_t *, dtrace_typeinfo_t *);
456 
457 extern int dtrace_type_strcompile(dtrace_hdl_t *,
458     const char *, dtrace_typeinfo_t *);
459 
460 extern int dtrace_type_fcompile(dtrace_hdl_t *,
461     FILE *, dtrace_typeinfo_t *);
462 
463 /*
464  * DTrace Probe Interface
465  *
466  * Library clients can use these functions to iterate over the set of available
467  * probe definitions and inquire as to their attributes.  The probe iteration
468  * interfaces report probes that are declared as well as those from dtrace(7D).
469  */
470 typedef struct dtrace_probeinfo {
471 	dtrace_attribute_t dtp_attr;		/* name attributes */
472 	dtrace_attribute_t dtp_arga;		/* arg attributes */
473 	const dtrace_typeinfo_t *dtp_argv;	/* arg types */
474 	int dtp_argc;				/* arg count */
475 } dtrace_probeinfo_t;
476 
477 typedef int dtrace_probe_f(dtrace_hdl_t *, const dtrace_probedesc_t *, void *);
478 
479 extern int dtrace_probe_iter(dtrace_hdl_t *,
480     const dtrace_probedesc_t *pdp, dtrace_probe_f *, void *);
481 
482 extern int dtrace_probe_info(dtrace_hdl_t *,
483     const dtrace_probedesc_t *, dtrace_probeinfo_t *);
484 
485 /*
486  * DTrace Vector Interface
487  *
488  * The DTrace library normally speaks directly to dtrace(7D).  However,
489  * this communication may be vectored elsewhere.  Consumers who wish to
490  * perform a vectored open must fill in the vector, and use the dtrace_vopen()
491  * entry point to obtain a library handle.
492  */
493 struct dtrace_vector {
494 	int (*dtv_ioctl)(void *, int, void *);
495 	int (*dtv_lookup_by_addr)(void *, GElf_Addr, GElf_Sym *,
496 	    dtrace_syminfo_t *);
497 	int (*dtv_status)(void *, processorid_t);
498 	long (*dtv_sysconf)(void *, int);
499 };
500 
501 /*
502  * DTrace Utility Functions
503  *
504  * Library clients can use these functions to convert between string and
505  * integer probe descriptions and the dtrace_probedesc_t representation
506  * and to perform similar conversions on stability attributes.
507  */
508 extern int dtrace_xstr2desc(dtrace_hdl_t *, dtrace_probespec_t,
509     const char *, int, char *const [], dtrace_probedesc_t *);
510 
511 extern int dtrace_str2desc(dtrace_hdl_t *, dtrace_probespec_t,
512     const char *, dtrace_probedesc_t *);
513 
514 extern int dtrace_id2desc(dtrace_hdl_t *, dtrace_id_t, dtrace_probedesc_t *);
515 
516 #define	DTRACE_DESC2STR_MAX	1024	/* min buf size for dtrace_desc2str() */
517 
518 extern char *dtrace_desc2str(const dtrace_probedesc_t *, char *, size_t);
519 
520 #define	DTRACE_ATTR2STR_MAX	64	/* min buf size for dtrace_attr2str() */
521 
522 extern char *dtrace_attr2str(dtrace_attribute_t, char *, size_t);
523 extern int dtrace_str2attr(const char *, dtrace_attribute_t *);
524 
525 extern const char *dtrace_stability_name(dtrace_stability_t);
526 extern const char *dtrace_class_name(dtrace_class_t);
527 
528 extern int dtrace_provider_modules(dtrace_hdl_t *, const char **, int);
529 
530 extern const char *const _dtrace_version;
531 extern int _dtrace_debug;
532 
533 #ifdef	__cplusplus
534 }
535 #endif
536 
537 #endif	/* _DTRACE_H */
538