xref: /freebsd/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.h (revision d899be7d43d8df9cb485af5705e2724165a461c7)
16ff6d951SJohn Birrell /*
26ff6d951SJohn Birrell  * CDDL HEADER START
36ff6d951SJohn Birrell  *
46ff6d951SJohn Birrell  * The contents of this file are subject to the terms of the
56ff6d951SJohn Birrell  * Common Development and Distribution License (the "License").
66ff6d951SJohn Birrell  * You may not use this file except in compliance with the License.
76ff6d951SJohn Birrell  *
86ff6d951SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96ff6d951SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
106ff6d951SJohn Birrell  * See the License for the specific language governing permissions
116ff6d951SJohn Birrell  * and limitations under the License.
126ff6d951SJohn Birrell  *
136ff6d951SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
146ff6d951SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156ff6d951SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
166ff6d951SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
176ff6d951SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
186ff6d951SJohn Birrell  *
196ff6d951SJohn Birrell  * CDDL HEADER END
206ff6d951SJohn Birrell  */
216ff6d951SJohn Birrell 
226ff6d951SJohn Birrell /*
236ff6d951SJohn Birrell  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
246ff6d951SJohn Birrell  * Use is subject to license terms.
256ff6d951SJohn Birrell  */
266ff6d951SJohn Birrell 
276ff6d951SJohn Birrell #ifndef	_DT_PROVIDER_H
286ff6d951SJohn Birrell #define	_DT_PROVIDER_H
296ff6d951SJohn Birrell 
306ff6d951SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
316ff6d951SJohn Birrell 
326ff6d951SJohn Birrell #include <dt_impl.h>
336ff6d951SJohn Birrell #include <dt_ident.h>
346ff6d951SJohn Birrell #include <dt_list.h>
356ff6d951SJohn Birrell 
366ff6d951SJohn Birrell #ifdef	__cplusplus
376ff6d951SJohn Birrell extern "C" {
386ff6d951SJohn Birrell #endif
396ff6d951SJohn Birrell 
406ff6d951SJohn Birrell typedef struct dt_provider {
416ff6d951SJohn Birrell 	dt_list_t pv_list;		/* list forward/back pointers */
426ff6d951SJohn Birrell 	struct dt_provider *pv_next;	/* pointer to next provider in hash */
436ff6d951SJohn Birrell 	dtrace_providerdesc_t pv_desc;	/* provider name and attributes */
446ff6d951SJohn Birrell 	dt_idhash_t *pv_probes;		/* probe defs (if user-declared) */
456ff6d951SJohn Birrell 	dt_node_t *pv_nodes;		/* parse node allocation list */
466ff6d951SJohn Birrell 	ulong_t *pv_xrefs;		/* translator reference bitmap */
476ff6d951SJohn Birrell 	ulong_t pv_xrmax;		/* number of valid bits in pv_xrefs */
486ff6d951SJohn Birrell 	ulong_t pv_gen;			/* generation # that created me */
496ff6d951SJohn Birrell 	dtrace_hdl_t *pv_hdl;		/* pointer to containing dtrace_hdl */
506ff6d951SJohn Birrell 	uint_t pv_flags;		/* flags (see below) */
516ff6d951SJohn Birrell } dt_provider_t;
526ff6d951SJohn Birrell 
536ff6d951SJohn Birrell #define	DT_PROVIDER_INTF	0x1	/* provider interface declaration */
546ff6d951SJohn Birrell #define	DT_PROVIDER_IMPL	0x2	/* provider implementation is loaded */
556ff6d951SJohn Birrell 
566ff6d951SJohn Birrell typedef struct dt_probe_iter {
576ff6d951SJohn Birrell 	dtrace_probedesc_t pit_desc;	/* description storage */
586ff6d951SJohn Birrell 	dtrace_hdl_t *pit_hdl;		/* libdtrace handle */
596ff6d951SJohn Birrell 	dt_provider_t *pit_pvp;		/* current provider */
606ff6d951SJohn Birrell 	const char *pit_pat;		/* caller's name pattern (or NULL) */
616ff6d951SJohn Birrell 	dtrace_probe_f *pit_func;	/* caller's function */
626ff6d951SJohn Birrell 	void *pit_arg;			/* caller's argument */
636ff6d951SJohn Birrell 	uint_t pit_matches;		/* number of matches */
646ff6d951SJohn Birrell } dt_probe_iter_t;
656ff6d951SJohn Birrell 
666ff6d951SJohn Birrell typedef struct dt_probe_instance {
67*af62c4ddSMark Johnston 	char *pi_fname;			/* function name */
68*af62c4ddSMark Johnston 	char *pi_rname;			/* mangled relocation name */
696ff6d951SJohn Birrell 	uint32_t *pi_offs;		/* offsets into the function */
706ff6d951SJohn Birrell 	uint32_t *pi_enoffs;		/* is-enabled offsets */
716ff6d951SJohn Birrell 	uint_t pi_noffs;		/* number of offsets */
726ff6d951SJohn Birrell 	uint_t pi_maxoffs;		/* size of pi_offs allocation */
736ff6d951SJohn Birrell 	uint_t pi_nenoffs;		/* number of is-enabled offsets */
746ff6d951SJohn Birrell 	uint_t pi_maxenoffs;		/* size of pi_enoffs allocation */
756ff6d951SJohn Birrell 	struct dt_probe_instance *pi_next; /* next instance in the list */
766ff6d951SJohn Birrell } dt_probe_instance_t;
776ff6d951SJohn Birrell 
786ff6d951SJohn Birrell typedef struct dt_probe {
796ff6d951SJohn Birrell 	dt_provider_t *pr_pvp;		/* pointer to containing provider */
806ff6d951SJohn Birrell 	dt_ident_t *pr_ident;		/* pointer to probe identifier */
816ff6d951SJohn Birrell 	const char *pr_name;		/* pointer to name component */
826ff6d951SJohn Birrell 	dt_node_t *pr_nargs;		/* native argument list */
836ff6d951SJohn Birrell 	dt_node_t **pr_nargv;		/* native argument vector */
846ff6d951SJohn Birrell 	uint_t pr_nargc;		/* native argument count */
856ff6d951SJohn Birrell 	dt_node_t *pr_xargs;		/* translated argument list */
866ff6d951SJohn Birrell 	dt_node_t **pr_xargv;		/* translated argument vector */
876ff6d951SJohn Birrell 	uint_t pr_xargc;		/* translated argument count */
886ff6d951SJohn Birrell 	uint8_t *pr_mapping;		/* translated argument mapping */
896ff6d951SJohn Birrell 	dt_probe_instance_t *pr_inst;	/* list of functions and offsets */
906ff6d951SJohn Birrell 	dtrace_typeinfo_t *pr_argv;	/* output argument types */
916ff6d951SJohn Birrell 	int pr_argc;			/* output argument count */
926ff6d951SJohn Birrell } dt_probe_t;
936ff6d951SJohn Birrell 
946ff6d951SJohn Birrell extern dt_provider_t *dt_provider_lookup(dtrace_hdl_t *, const char *);
956ff6d951SJohn Birrell extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *);
966ff6d951SJohn Birrell extern void dt_provider_destroy(dtrace_hdl_t *, dt_provider_t *);
976ff6d951SJohn Birrell extern int dt_provider_xref(dtrace_hdl_t *, dt_provider_t *, id_t);
986ff6d951SJohn Birrell 
996ff6d951SJohn Birrell extern dt_probe_t *dt_probe_create(dtrace_hdl_t *, dt_ident_t *, int,
1006ff6d951SJohn Birrell     dt_node_t *, uint_t, dt_node_t *, uint_t);
1016ff6d951SJohn Birrell 
1026ff6d951SJohn Birrell extern dt_probe_t *dt_probe_info(dtrace_hdl_t *,
1036ff6d951SJohn Birrell     const dtrace_probedesc_t *, dtrace_probeinfo_t *);
1046ff6d951SJohn Birrell 
1056ff6d951SJohn Birrell extern dt_probe_t *dt_probe_lookup(dt_provider_t *, const char *);
1066ff6d951SJohn Birrell extern void dt_probe_declare(dt_provider_t *, dt_probe_t *);
1076ff6d951SJohn Birrell extern void dt_probe_destroy(dt_probe_t *);
1086ff6d951SJohn Birrell 
1096ff6d951SJohn Birrell extern int dt_probe_define(dt_provider_t *, dt_probe_t *,
1106ff6d951SJohn Birrell     const char *, const char *, uint32_t, int);
1116ff6d951SJohn Birrell 
1126ff6d951SJohn Birrell extern dt_node_t *dt_probe_tag(dt_probe_t *, uint_t, dt_node_t *);
1136ff6d951SJohn Birrell 
1146ff6d951SJohn Birrell #ifdef	__cplusplus
1156ff6d951SJohn Birrell }
1166ff6d951SJohn Birrell #endif
1176ff6d951SJohn Birrell 
1186ff6d951SJohn Birrell #endif	/* _DT_PROVIDER_H */
119