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