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