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