xref: /freebsd/cddl/contrib/opensolaris/lib/libdtrace/common/dt_xlator.h (revision 6ff6d951ade3f3379932df7f878ef3ea272cfc59)
16ff6d951SJohn Birrell /*
26ff6d951SJohn Birrell  * CDDL HEADER START
36ff6d951SJohn Birrell  *
46ff6d951SJohn Birrell  * The contents of this file are subject to the terms of the
56ff6d951SJohn Birrell  * Common Development and Distribution License, Version 1.0 only
66ff6d951SJohn Birrell  * (the "License").  You may not use this file except in compliance
76ff6d951SJohn Birrell  * with the License.
86ff6d951SJohn Birrell  *
96ff6d951SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
106ff6d951SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
116ff6d951SJohn Birrell  * See the License for the specific language governing permissions
126ff6d951SJohn Birrell  * and limitations under the License.
136ff6d951SJohn Birrell  *
146ff6d951SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
156ff6d951SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
166ff6d951SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
176ff6d951SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
186ff6d951SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
196ff6d951SJohn Birrell  *
206ff6d951SJohn Birrell  * CDDL HEADER END
216ff6d951SJohn Birrell  */
226ff6d951SJohn Birrell /*
236ff6d951SJohn Birrell  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
246ff6d951SJohn Birrell  * Use is subject to license terms.
256ff6d951SJohn Birrell  */
266ff6d951SJohn Birrell 
276ff6d951SJohn Birrell #ifndef	_DT_XLATOR_H
286ff6d951SJohn Birrell #define	_DT_XLATOR_H
296ff6d951SJohn Birrell 
306ff6d951SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
316ff6d951SJohn Birrell 
326ff6d951SJohn Birrell #include <libctf.h>
336ff6d951SJohn Birrell #include <dtrace.h>
346ff6d951SJohn Birrell #include <dt_ident.h>
356ff6d951SJohn Birrell #include <dt_list.h>
366ff6d951SJohn Birrell 
376ff6d951SJohn Birrell #ifdef	__cplusplus
386ff6d951SJohn Birrell extern "C" {
396ff6d951SJohn Birrell #endif
406ff6d951SJohn Birrell 
416ff6d951SJohn Birrell struct dt_node;
426ff6d951SJohn Birrell 
436ff6d951SJohn Birrell typedef struct dt_xlator {
446ff6d951SJohn Birrell 	dt_list_t dx_list;		/* list forward/back pointers */
456ff6d951SJohn Birrell 	dt_idhash_t *dx_locals;		/* hash of local scope identifiers */
466ff6d951SJohn Birrell 	dt_ident_t *dx_ident;		/* identifier ref for input param */
476ff6d951SJohn Birrell 	dt_ident_t dx_souid;		/* fake identifier for sou output */
486ff6d951SJohn Birrell 	dt_ident_t dx_ptrid;		/* fake identifier for ptr output */
496ff6d951SJohn Birrell 	ctf_file_t *dx_src_ctfp;	/* CTF container for input type */
506ff6d951SJohn Birrell 	ctf_id_t dx_src_type;		/* CTF reference for input type */
516ff6d951SJohn Birrell 	ctf_id_t dx_src_base;		/* CTF reference for input base */
526ff6d951SJohn Birrell 	ctf_file_t *dx_dst_ctfp;	/* CTF container for output type */
536ff6d951SJohn Birrell 	ctf_id_t dx_dst_type;		/* CTF reference for output type */
546ff6d951SJohn Birrell 	ctf_id_t dx_dst_base;		/* CTF reference for output base */
556ff6d951SJohn Birrell 	struct dt_node *dx_members;	/* list of member translations */
566ff6d951SJohn Birrell 	uint_t dx_nmembers;		/* length of dx_members list */
576ff6d951SJohn Birrell 	dtrace_difo_t **dx_membdif;	/* DIF for member expressions */
586ff6d951SJohn Birrell 	struct dt_node *dx_nodes;	/* list of parse tree nodes */
596ff6d951SJohn Birrell 	dtrace_hdl_t *dx_hdl;		/* back pointer to containing handle */
606ff6d951SJohn Birrell 	ulong_t dx_gen;			/* generation number that created me */
616ff6d951SJohn Birrell 	id_t dx_id;			/* global translator id */
626ff6d951SJohn Birrell 	int dx_arg;			/* dynamic argument index */
636ff6d951SJohn Birrell } dt_xlator_t;
646ff6d951SJohn Birrell 
656ff6d951SJohn Birrell extern dt_xlator_t *dt_xlator_create(dtrace_hdl_t *,
666ff6d951SJohn Birrell     const dtrace_typeinfo_t *, const dtrace_typeinfo_t *,
676ff6d951SJohn Birrell     const char *, struct dt_node *, struct dt_node *);
686ff6d951SJohn Birrell 
696ff6d951SJohn Birrell extern void dt_xlator_destroy(dtrace_hdl_t *, dt_xlator_t *);
706ff6d951SJohn Birrell 
716ff6d951SJohn Birrell #define	DT_XLATE_FUZZY	0x0		/* lookup any matching translator */
726ff6d951SJohn Birrell #define	DT_XLATE_EXACT	0x1		/* lookup only exact type matches */
736ff6d951SJohn Birrell #define	DT_XLATE_EXTERN	0x2		/* extern translator if none exists */
746ff6d951SJohn Birrell 
756ff6d951SJohn Birrell extern dt_xlator_t *dt_xlator_lookup(dtrace_hdl_t *,
766ff6d951SJohn Birrell     struct dt_node *, struct dt_node *, int);
776ff6d951SJohn Birrell 
786ff6d951SJohn Birrell extern dt_xlator_t *dt_xlator_lookup_id(dtrace_hdl_t *, id_t);
796ff6d951SJohn Birrell extern dt_ident_t *dt_xlator_ident(dt_xlator_t *, ctf_file_t *, ctf_id_t);
806ff6d951SJohn Birrell extern struct dt_node *dt_xlator_member(dt_xlator_t *, const char *);
816ff6d951SJohn Birrell extern int dt_xlator_dynamic(const dt_xlator_t *);
826ff6d951SJohn Birrell 
836ff6d951SJohn Birrell #ifdef	__cplusplus
846ff6d951SJohn Birrell }
856ff6d951SJohn Birrell #endif
866ff6d951SJohn Birrell 
876ff6d951SJohn Birrell #endif	/* _DT_XLATOR_H */
88