xref: /illumos-gate/usr/src/lib/libdtrace/common/dt_provider.h (revision 814a60b13c0ad90e5d2edfd29a7a84bbf416cc1a)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 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 	uint32_t *pi_offs;		/* offsets into the function */
69 	uint_t pi_noffs;		/* number of offsets */
70 	uint_t pi_maxoffs;		/* size of pi_offs allocation */
71 	struct dt_probe_instance *pi_next; /* next instance in the list */
72 } dt_probe_instance_t;
73 
74 typedef struct dt_probe {
75 	dt_provider_t *pr_pvp;		/* pointer to containing provider */
76 	dt_ident_t *pr_ident;		/* pointer to probe identifier */
77 	const char *pr_name;		/* pointer to name component */
78 	dt_node_t *pr_nargs;		/* native argument list */
79 	dt_node_t **pr_nargv;		/* native argument vector */
80 	uint_t pr_nargc;		/* native argument count */
81 	dt_node_t *pr_xargs;		/* translated argument list */
82 	dt_node_t **pr_xargv;		/* translated argument vector */
83 	uint_t pr_xargc;		/* translated argument count */
84 	uint8_t *pr_mapping;		/* translated argument mapping */
85 	dt_probe_instance_t *pr_inst;	/* list of functions and offsets */
86 	dtrace_typeinfo_t *pr_argv;	/* output argument types */
87 	int pr_argc;			/* output argument count */
88 } dt_probe_t;
89 
90 extern dt_provider_t *dt_provider_lookup(dtrace_hdl_t *, const char *);
91 extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *);
92 extern void dt_provider_destroy(dtrace_hdl_t *, dt_provider_t *);
93 extern int dt_provider_xref(dtrace_hdl_t *, dt_provider_t *, id_t);
94 
95 extern dt_probe_t *dt_probe_create(dtrace_hdl_t *, dt_ident_t *, int,
96     dt_node_t *, uint_t, dt_node_t *, uint_t);
97 
98 extern dt_probe_t *dt_probe_info(dtrace_hdl_t *,
99     const dtrace_probedesc_t *, dtrace_probeinfo_t *);
100 
101 extern dt_probe_t *dt_probe_lookup(dt_provider_t *, const char *);
102 extern void dt_probe_declare(dt_provider_t *, dt_probe_t *);
103 extern void dt_probe_destroy(dt_probe_t *);
104 
105 extern int dt_probe_define(dt_provider_t *, dt_probe_t *,
106     const char *, uint32_t);
107 
108 extern dt_node_t *dt_probe_tag(dt_probe_t *, uint_t, dt_node_t *);
109 
110 #ifdef	__cplusplus
111 }
112 #endif
113 
114 #endif	/* _DT_PROVIDER_H */
115