xref: /illumos-gate/usr/src/lib/libdtrace/common/dt_provider.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_DT_PROVIDER_H
28 #define	_DT_PROVIDER_H
29 
30 #include <dt_impl.h>
31 #include <dt_ident.h>
32 #include <dt_list.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct dt_provider {
39 	dt_list_t pv_list;		/* list forward/back pointers */
40 	struct dt_provider *pv_next;	/* pointer to next provider in hash */
41 	dtrace_providerdesc_t pv_desc;	/* provider name and attributes */
42 	dt_idhash_t *pv_probes;		/* probe defs (if user-declared) */
43 	dt_node_t *pv_nodes;		/* parse node allocation list */
44 	ulong_t *pv_xrefs;		/* translator reference bitmap */
45 	ulong_t pv_xrmax;		/* number of valid bits in pv_xrefs */
46 	ulong_t pv_gen;			/* generation # that created me */
47 	dtrace_hdl_t *pv_hdl;		/* pointer to containing dtrace_hdl */
48 	uint_t pv_flags;		/* flags (see below) */
49 } dt_provider_t;
50 
51 #define	DT_PROVIDER_INTF	0x1	/* provider interface declaration */
52 #define	DT_PROVIDER_IMPL	0x2	/* provider implementation is loaded */
53 
54 typedef struct dt_probe_iter {
55 	dtrace_probedesc_t pit_desc;	/* description storage */
56 	dtrace_hdl_t *pit_hdl;		/* libdtrace handle */
57 	dt_provider_t *pit_pvp;		/* current provider */
58 	const char *pit_pat;		/* caller's name pattern (or NULL) */
59 	dtrace_probe_f *pit_func;	/* caller's function */
60 	void *pit_arg;			/* caller's argument */
61 	uint_t pit_matches;		/* number of matches */
62 } dt_probe_iter_t;
63 
64 typedef struct dt_probe_instance {
65 	char pi_fname[DTRACE_FUNCNAMELEN]; /* function name */
66 	char pi_rname[DTRACE_FUNCNAMELEN + 20]; /* mangled relocation name */
67 	uint32_t *pi_offs;		/* offsets into the function */
68 	uint32_t *pi_enoffs;		/* is-enabled offsets */
69 	uint_t pi_noffs;		/* number of offsets */
70 	uint_t pi_maxoffs;		/* size of pi_offs allocation */
71 	uint_t pi_nenoffs;		/* number of is-enabled offsets */
72 	uint_t pi_maxenoffs;		/* size of pi_enoffs allocation */
73 	struct dt_probe_instance *pi_next; /* next instance in the list */
74 } dt_probe_instance_t;
75 
76 typedef struct dt_probe {
77 	dt_provider_t *pr_pvp;		/* pointer to containing provider */
78 	dt_ident_t *pr_ident;		/* pointer to probe identifier */
79 	const char *pr_name;		/* pointer to name component */
80 	dt_node_t *pr_nargs;		/* native argument list */
81 	dt_node_t **pr_nargv;		/* native argument vector */
82 	uint_t pr_nargc;		/* native argument count */
83 	dt_node_t *pr_xargs;		/* translated argument list */
84 	dt_node_t **pr_xargv;		/* translated argument vector */
85 	uint_t pr_xargc;		/* translated argument count */
86 	uint8_t *pr_mapping;		/* translated argument mapping */
87 	dt_probe_instance_t *pr_inst;	/* list of functions and offsets */
88 	dtrace_typeinfo_t *pr_argv;	/* output argument types */
89 	int pr_argc;			/* output argument count */
90 } dt_probe_t;
91 
92 extern dt_provider_t *dt_provider_lookup(dtrace_hdl_t *, const char *);
93 extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *);
94 extern void dt_provider_destroy(dtrace_hdl_t *, dt_provider_t *);
95 extern int dt_provider_xref(dtrace_hdl_t *, dt_provider_t *, id_t);
96 
97 extern dt_probe_t *dt_probe_create(dtrace_hdl_t *, dt_ident_t *, int,
98     dt_node_t *, uint_t, dt_node_t *, uint_t);
99 
100 extern dt_probe_t *dt_probe_info(dtrace_hdl_t *,
101     const dtrace_probedesc_t *, dtrace_probeinfo_t *);
102 
103 extern dt_probe_t *dt_probe_lookup(dt_provider_t *, const char *);
104 extern void dt_probe_declare(dt_provider_t *, dt_probe_t *);
105 extern void dt_probe_destroy(dt_probe_t *);
106 
107 extern int dt_probe_define(dt_provider_t *, dt_probe_t *,
108     const char *, const char *, uint32_t, int);
109 
110 extern dt_node_t *dt_probe_tag(dt_probe_t *, uint_t, dt_node_t *);
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif	/* _DT_PROVIDER_H */
117