xref: /onnv-gate/usr/src/lib/libdtrace/common/dt_decl.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_DT_DECL_H
28*0Sstevel@tonic-gate #define	_DT_DECL_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/types.h>
33*0Sstevel@tonic-gate #include <libctf.h>
34*0Sstevel@tonic-gate #include <dtrace.h>
35*0Sstevel@tonic-gate #include <stdio.h>
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #ifdef	__cplusplus
38*0Sstevel@tonic-gate extern "C" {
39*0Sstevel@tonic-gate #endif
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate struct dt_node;				/* forward declaration of dt_node_t */
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate typedef struct dt_decl {
44*0Sstevel@tonic-gate 	ushort_t dd_kind;		/* declaration kind (CTF_K_* kind) */
45*0Sstevel@tonic-gate 	ushort_t dd_attr;		/* attributes (DT_DA_* flags) */
46*0Sstevel@tonic-gate 	ctf_file_t *dd_ctfp;		/* CTF container for decl's type */
47*0Sstevel@tonic-gate 	ctf_id_t dd_type;		/* CTF identifier for decl's type */
48*0Sstevel@tonic-gate 	char *dd_name;			/* string name of this decl (or NULL) */
49*0Sstevel@tonic-gate 	struct dt_node *dd_node;	/* node for array size or parm list */
50*0Sstevel@tonic-gate 	struct dt_decl *dd_next;	/* next declaration in list */
51*0Sstevel@tonic-gate } dt_decl_t;
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate #define	DT_DA_SIGNED	0x0001		/* signed integer value */
54*0Sstevel@tonic-gate #define	DT_DA_UNSIGNED	0x0002		/* unsigned integer value */
55*0Sstevel@tonic-gate #define	DT_DA_SHORT	0x0004		/* short integer value */
56*0Sstevel@tonic-gate #define	DT_DA_LONG	0x0008		/* long integer or double */
57*0Sstevel@tonic-gate #define	DT_DA_LONGLONG	0x0010		/* long long integer value */
58*0Sstevel@tonic-gate #define	DT_DA_CONST	0x0020		/* qualify type as const */
59*0Sstevel@tonic-gate #define	DT_DA_RESTRICT	0x0040		/* qualify type as restrict */
60*0Sstevel@tonic-gate #define	DT_DA_VOLATILE	0x0080		/* qualify type as volatile */
61*0Sstevel@tonic-gate #define	DT_DA_PAREN	0x0100		/* parenthesis tag */
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate typedef enum dt_dclass {
64*0Sstevel@tonic-gate 	DT_DC_DEFAULT,			/* no storage class specified */
65*0Sstevel@tonic-gate 	DT_DC_AUTO,			/* automatic storage */
66*0Sstevel@tonic-gate 	DT_DC_REGISTER,			/* register storage */
67*0Sstevel@tonic-gate 	DT_DC_STATIC,			/* static storage */
68*0Sstevel@tonic-gate 	DT_DC_EXTERN,			/* extern storage */
69*0Sstevel@tonic-gate 	DT_DC_TYPEDEF,			/* type definition */
70*0Sstevel@tonic-gate 	DT_DC_SELF,			/* thread-local storage */
71*0Sstevel@tonic-gate 	DT_DC_THIS			/* clause-local storage */
72*0Sstevel@tonic-gate } dt_dclass_t;
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate typedef struct dt_scope {
75*0Sstevel@tonic-gate 	dt_decl_t *ds_decl;		/* pointer to top of decl stack */
76*0Sstevel@tonic-gate 	struct dt_scope *ds_next;	/* pointer to next scope */
77*0Sstevel@tonic-gate 	char *ds_ident;			/* identifier for this scope (if any) */
78*0Sstevel@tonic-gate 	ctf_file_t *ds_ctfp;		/* CTF container for this scope */
79*0Sstevel@tonic-gate 	ctf_id_t ds_type;		/* CTF id of enclosing type */
80*0Sstevel@tonic-gate 	dt_dclass_t ds_class;		/* declaration class for this scope */
81*0Sstevel@tonic-gate 	int ds_enumval;			/* most recent enumerator value */
82*0Sstevel@tonic-gate } dt_scope_t;
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_alloc(ushort_t, char *);
85*0Sstevel@tonic-gate extern void dt_decl_free(dt_decl_t *);
86*0Sstevel@tonic-gate extern void dt_decl_reset(void);
87*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_push(dt_decl_t *);
88*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_pop(void);
89*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_pop_param(char **);
90*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_top(void);
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_ident(char *);
93*0Sstevel@tonic-gate extern void dt_decl_class(dt_dclass_t);
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #define	DT_DP_VARARGS	0x1		/* permit varargs in prototype */
96*0Sstevel@tonic-gate #define	DT_DP_DYNAMIC	0x2		/* permit dynamic type in prototype */
97*0Sstevel@tonic-gate #define	DT_DP_VOID	0x4		/* permit void type in prototype */
98*0Sstevel@tonic-gate #define	DT_DP_ANON	0x8		/* permit anonymous parameters */
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate extern int dt_decl_prototype(struct dt_node *, struct dt_node *,
101*0Sstevel@tonic-gate     const char *, uint_t);
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_spec(ushort_t, char *);
104*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_attr(ushort_t);
105*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_array(struct dt_node *);
106*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_func(dt_decl_t *, struct dt_node *);
107*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_ptr(void);
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_sou(uint_t, char *);
110*0Sstevel@tonic-gate extern void dt_decl_member(struct dt_node *);
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate extern dt_decl_t *dt_decl_enum(char *);
113*0Sstevel@tonic-gate extern void dt_decl_enumerator(char *, struct dt_node *);
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate extern int dt_decl_type(dt_decl_t *, dtrace_typeinfo_t *);
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate extern void dt_scope_create(dt_scope_t *);
118*0Sstevel@tonic-gate extern void dt_scope_destroy(dt_scope_t *);
119*0Sstevel@tonic-gate extern void dt_scope_push(ctf_file_t *, ctf_id_t);
120*0Sstevel@tonic-gate extern dt_decl_t *dt_scope_pop(void);
121*0Sstevel@tonic-gate 
122*0Sstevel@tonic-gate #ifdef	__cplusplus
123*0Sstevel@tonic-gate }
124*0Sstevel@tonic-gate #endif
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate #endif	/* _DT_DECL_H */
127