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