xref: /titanic_52/usr/src/lib/libdtrace/common/dt_provider.h (revision b35ccd53da4e9ec8f91c398e23ba0157c26f0822)
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 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 	uint_t pi_noffs;		/* number of offsets */
71 	uint_t pi_maxoffs;		/* size of pi_offs allocation */
72 	struct dt_probe_instance *pi_next; /* next instance in the list */
73 } dt_probe_instance_t;
74 
75 typedef struct dt_probe {
76 	dt_provider_t *pr_pvp;		/* pointer to containing provider */
77 	dt_ident_t *pr_ident;		/* pointer to probe identifier */
78 	const char *pr_name;		/* pointer to name component */
79 	dt_node_t *pr_nargs;		/* native argument list */
80 	dt_node_t **pr_nargv;		/* native argument vector */
81 	uint_t pr_nargc;		/* native argument count */
82 	dt_node_t *pr_xargs;		/* translated argument list */
83 	dt_node_t **pr_xargv;		/* translated argument vector */
84 	uint_t pr_xargc;		/* translated argument count */
85 	uint8_t *pr_mapping;		/* translated argument mapping */
86 	dt_probe_instance_t *pr_inst;	/* list of functions and offsets */
87 	dtrace_typeinfo_t *pr_argv;	/* output argument types */
88 	int pr_argc;			/* output argument count */
89 } dt_probe_t;
90 
91 extern dt_provider_t *dt_provider_lookup(dtrace_hdl_t *, const char *);
92 extern dt_provider_t *dt_provider_create(dtrace_hdl_t *, const char *);
93 extern void dt_provider_destroy(dtrace_hdl_t *, dt_provider_t *);
94 extern int dt_provider_xref(dtrace_hdl_t *, dt_provider_t *, id_t);
95 
96 extern dt_probe_t *dt_probe_create(dtrace_hdl_t *, dt_ident_t *, int,
97     dt_node_t *, uint_t, dt_node_t *, uint_t);
98 
99 extern dt_probe_t *dt_probe_info(dtrace_hdl_t *,
100     const dtrace_probedesc_t *, dtrace_probeinfo_t *);
101 
102 extern dt_probe_t *dt_probe_lookup(dt_provider_t *, const char *);
103 extern void dt_probe_declare(dt_provider_t *, dt_probe_t *);
104 extern void dt_probe_destroy(dt_probe_t *);
105 
106 extern int dt_probe_define(dt_provider_t *, dt_probe_t *,
107     const char *, const char *, uint32_t);
108 
109 extern dt_node_t *dt_probe_tag(dt_probe_t *, uint_t, dt_node_t *);
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif	/* _DT_PROVIDER_H */
116