xref: /illumos-gate/usr/src/lib/libdtrace/common/dt_xlator.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, 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_XLATOR_H
28 #define	_DT_XLATOR_H
29 
30 #include <libctf.h>
31 #include <dtrace.h>
32 #include <dt_ident.h>
33 #include <dt_list.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 struct dt_node;
40 
41 typedef struct dt_xlator {
42 	dt_list_t dx_list;		/* list forward/back pointers */
43 	dt_idhash_t *dx_locals;		/* hash of local scope identifiers */
44 	dt_ident_t *dx_ident;		/* identifier ref for input param */
45 	dt_ident_t dx_souid;		/* fake identifier for sou output */
46 	dt_ident_t dx_ptrid;		/* fake identifier for ptr output */
47 	ctf_file_t *dx_src_ctfp;	/* CTF container for input type */
48 	ctf_id_t dx_src_type;		/* CTF reference for input type */
49 	ctf_id_t dx_src_base;		/* CTF reference for input base */
50 	ctf_file_t *dx_dst_ctfp;	/* CTF container for output type */
51 	ctf_id_t dx_dst_type;		/* CTF reference for output type */
52 	ctf_id_t dx_dst_base;		/* CTF reference for output base */
53 	struct dt_node *dx_members;	/* list of member translations */
54 	uint_t dx_nmembers;		/* length of dx_members list */
55 	dtrace_difo_t **dx_membdif;	/* DIF for member expressions */
56 	struct dt_node *dx_nodes;	/* list of parse tree nodes */
57 	dtrace_hdl_t *dx_hdl;		/* back pointer to containing handle */
58 	ulong_t dx_gen;			/* generation number that created me */
59 	id_t dx_id;			/* global translator id */
60 	int dx_arg;			/* dynamic argument index */
61 } dt_xlator_t;
62 
63 extern dt_xlator_t *dt_xlator_create(dtrace_hdl_t *,
64     const dtrace_typeinfo_t *, const dtrace_typeinfo_t *,
65     const char *, struct dt_node *, struct dt_node *);
66 
67 extern void dt_xlator_destroy(dtrace_hdl_t *, dt_xlator_t *);
68 
69 #define	DT_XLATE_FUZZY	0x0		/* lookup any matching translator */
70 #define	DT_XLATE_EXACT	0x1		/* lookup only exact type matches */
71 #define	DT_XLATE_EXTERN	0x2		/* extern translator if none exists */
72 
73 extern dt_xlator_t *dt_xlator_lookup(dtrace_hdl_t *,
74     struct dt_node *, struct dt_node *, int);
75 
76 extern dt_xlator_t *dt_xlator_lookup_id(dtrace_hdl_t *, id_t);
77 extern dt_ident_t *dt_xlator_ident(dt_xlator_t *, ctf_file_t *, ctf_id_t);
78 extern struct dt_node *dt_xlator_member(dt_xlator_t *, const char *);
79 extern int dt_xlator_dynamic(const dt_xlator_t *);
80 
81 #ifdef	__cplusplus
82 }
83 #endif
84 
85 #endif	/* _DT_XLATOR_H */
86