xref: /onnv-gate/usr/src/lib/libdtrace/common/dt_xlator.h (revision 265:a968e4ece133)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*265Smws  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_DT_XLATOR_H
280Sstevel@tonic-gate #define	_DT_XLATOR_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <libctf.h>
330Sstevel@tonic-gate #include <dtrace.h>
340Sstevel@tonic-gate #include <dt_ident.h>
350Sstevel@tonic-gate #include <dt_list.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate struct dt_node;
420Sstevel@tonic-gate 
430Sstevel@tonic-gate typedef struct dt_xlator {
440Sstevel@tonic-gate 	dt_list_t dx_list;		/* list forward/back pointers */
450Sstevel@tonic-gate 	dt_idhash_t *dx_locals;		/* hash of local scope identifiers */
460Sstevel@tonic-gate 	dt_ident_t *dx_ident;		/* identifier ref for input param */
470Sstevel@tonic-gate 	dt_ident_t dx_souid;		/* fake identifier for sou output */
480Sstevel@tonic-gate 	dt_ident_t dx_ptrid;		/* fake identifier for ptr output */
490Sstevel@tonic-gate 	ctf_file_t *dx_src_ctfp;	/* CTF container for input type */
500Sstevel@tonic-gate 	ctf_id_t dx_src_type;		/* CTF reference for input type */
510Sstevel@tonic-gate 	ctf_id_t dx_src_base;		/* CTF reference for input base */
520Sstevel@tonic-gate 	ctf_file_t *dx_dst_ctfp;	/* CTF container for output type */
530Sstevel@tonic-gate 	ctf_id_t dx_dst_type;		/* CTF reference for output type */
540Sstevel@tonic-gate 	ctf_id_t dx_dst_base;		/* CTF reference for output base */
550Sstevel@tonic-gate 	struct dt_node *dx_members;	/* list of member translations */
56*265Smws 	uint_t dx_nmembers;		/* length of dx_members list */
57*265Smws 	dtrace_difo_t **dx_membdif;	/* DIF for member expressions */
580Sstevel@tonic-gate 	struct dt_node *dx_nodes;	/* list of parse tree nodes */
59*265Smws 	dtrace_hdl_t *dx_hdl;		/* back pointer to containing handle */
600Sstevel@tonic-gate 	ulong_t dx_gen;			/* generation number that created me */
61*265Smws 	id_t dx_id;			/* global translator id */
62*265Smws 	int dx_arg;			/* dynamic argument index */
630Sstevel@tonic-gate } dt_xlator_t;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate extern dt_xlator_t *dt_xlator_create(dtrace_hdl_t *,
660Sstevel@tonic-gate     const dtrace_typeinfo_t *, const dtrace_typeinfo_t *,
670Sstevel@tonic-gate     const char *, struct dt_node *, struct dt_node *);
680Sstevel@tonic-gate 
69*265Smws extern void dt_xlator_destroy(dtrace_hdl_t *, dt_xlator_t *);
70*265Smws 
71*265Smws #define	DT_XLATE_FUZZY	0x0		/* lookup any matching translator */
72*265Smws #define	DT_XLATE_EXACT	0x1		/* lookup only exact type matches */
73*265Smws #define	DT_XLATE_EXTERN	0x2		/* extern translator if none exists */
740Sstevel@tonic-gate 
750Sstevel@tonic-gate extern dt_xlator_t *dt_xlator_lookup(dtrace_hdl_t *,
760Sstevel@tonic-gate     struct dt_node *, struct dt_node *, int);
770Sstevel@tonic-gate 
78*265Smws extern dt_xlator_t *dt_xlator_lookup_id(dtrace_hdl_t *, id_t);
790Sstevel@tonic-gate extern dt_ident_t *dt_xlator_ident(dt_xlator_t *, ctf_file_t *, ctf_id_t);
800Sstevel@tonic-gate extern struct dt_node *dt_xlator_member(dt_xlator_t *, const char *);
81*265Smws extern int dt_xlator_dynamic(const dt_xlator_t *);
820Sstevel@tonic-gate 
830Sstevel@tonic-gate #ifdef	__cplusplus
840Sstevel@tonic-gate }
850Sstevel@tonic-gate #endif
860Sstevel@tonic-gate 
870Sstevel@tonic-gate #endif	/* _DT_XLATOR_H */
88