Print this page
4474 DTrace Userland CTF Support
4475 DTrace userland Keyword
4476 DTrace tests should be better citizens
4479 pid provider types
4480 dof emulation missing checks
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libdtrace/common/dt_parser.h
+++ new/usr/src/lib/libdtrace/common/dt_parser.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 +/*
26 + * Copyright (c) 2013 by Delphix. All rights reserved.
27 + * Copyright (c) 2013 Joyent, Inc. All rights reserved.
28 + */
25 29
26 30 #ifndef _DT_PARSER_H
27 31 #define _DT_PARSER_H
28 32
29 -#pragma ident "%Z%%M% %I% %E% SMI"
30 -
31 33 #include <sys/types.h>
32 34 #include <sys/dtrace.h>
33 35
34 36 #include <libctf.h>
35 37 #include <stdarg.h>
36 38 #include <stdio.h>
37 39
38 40 #ifdef __cplusplus
39 41 extern "C" {
40 42 #endif
41 43
42 44 #include <dt_errtags.h>
43 45 #include <dt_ident.h>
44 46 #include <dt_decl.h>
45 47 #include <dt_xlator.h>
46 48 #include <dt_list.h>
47 49
48 50 typedef struct dt_node {
49 51 ctf_file_t *dn_ctfp; /* CTF type container for node's type */
50 52 ctf_id_t dn_type; /* CTF type reference for node's type */
51 53 uchar_t dn_kind; /* node kind (DT_NODE_*, defined below) */
52 54 uchar_t dn_flags; /* node flags (DT_NF_*, defined below) */
53 55 ushort_t dn_op; /* operator (DT_TOK_*, defined by lex) */
54 56 int dn_line; /* line number for error messages */
55 57 int dn_reg; /* register allocated by cg */
56 58 dtrace_attribute_t dn_attr; /* node stability attributes */
57 59
58 60 /*
59 61 * D compiler nodes, as is the usual style, contain a union of the
60 62 * different sub-elements required by the various kinds of nodes.
61 63 * These sub-elements are accessed using the macros defined below.
62 64 */
63 65 union {
64 66 struct {
65 67 uintmax_t _value; /* integer value */
66 68 char *_string; /* string value */
67 69 } _const;
68 70
69 71 struct {
70 72 dt_ident_t *_ident; /* identifier reference */
71 73 struct dt_node *_links[3]; /* child node pointers */
72 74 } _nodes;
73 75
74 76 struct {
75 77 struct dt_node *_descs; /* list of descriptions */
76 78 struct dt_node *_pred; /* predicate expression */
77 79 struct dt_node *_acts; /* action statement list */
78 80 dt_idhash_t *_locals; /* local variable hash */
79 81 dtrace_attribute_t _attr; /* context attributes */
80 82 } _clause;
81 83
82 84 struct {
83 85 char *_spec; /* specifier string (if any) */
84 86 dtrace_probedesc_t *_desc; /* final probe description */
85 87 } _pdesc;
86 88
87 89 struct {
88 90 char *_name; /* string name of member */
89 91 struct dt_node *_expr; /* expression node pointer */
90 92 dt_xlator_t *_xlator; /* translator reference */
91 93 uint_t _id; /* member identifier */
92 94 } _member;
93 95
94 96 struct {
95 97 dt_xlator_t *_xlator; /* translator reference */
96 98 struct dt_node *_xmemb; /* individual xlator member */
97 99 struct dt_node *_membs; /* list of member nodes */
98 100 } _xlator;
99 101
100 102 struct {
101 103 char *_name; /* string name of provider */
102 104 struct dt_provider *_pvp; /* provider references */
103 105 struct dt_node *_probes; /* list of probe nodes */
104 106 int _redecl; /* provider redeclared */
105 107 } _provider;
106 108 } dn_u;
107 109
108 110 struct dt_node *dn_list; /* parse tree list link */
109 111 struct dt_node *dn_link; /* allocation list link */
110 112 } dt_node_t;
111 113
112 114 #define dn_value dn_u._const._value /* DT_NODE_INT */
113 115 #define dn_string dn_u._const._string /* STRING, IDENT, TYPE */
114 116 #define dn_ident dn_u._nodes._ident /* VAR,SYM,FUN,AGG,INL,PROBE */
115 117 #define dn_args dn_u._nodes._links[0] /* DT_NODE_VAR, FUNC */
116 118 #define dn_child dn_u._nodes._links[0] /* DT_NODE_OP1 */
117 119 #define dn_left dn_u._nodes._links[0] /* DT_NODE_OP2, OP3 */
118 120 #define dn_right dn_u._nodes._links[1] /* DT_NODE_OP2, OP3 */
119 121 #define dn_expr dn_u._nodes._links[2] /* DT_NODE_OP3, DEXPR */
120 122 #define dn_aggfun dn_u._nodes._links[0] /* DT_NODE_AGG */
121 123 #define dn_aggtup dn_u._nodes._links[1] /* DT_NODE_AGG */
122 124 #define dn_pdescs dn_u._clause._descs /* DT_NODE_CLAUSE */
123 125 #define dn_pred dn_u._clause._pred /* DT_NODE_CLAUSE */
124 126 #define dn_acts dn_u._clause._acts /* DT_NODE_CLAUSE */
125 127 #define dn_locals dn_u._clause._locals /* DT_NODE_CLAUSE */
126 128 #define dn_ctxattr dn_u._clause._attr /* DT_NODE_CLAUSE */
127 129 #define dn_spec dn_u._pdesc._spec /* DT_NODE_PDESC */
128 130 #define dn_desc dn_u._pdesc._desc /* DT_NODE_PDESC */
129 131 #define dn_membname dn_u._member._name /* DT_NODE_MEMBER */
130 132 #define dn_membexpr dn_u._member._expr /* DT_NODE_MEMBER */
131 133 #define dn_membxlator dn_u._member._xlator /* DT_NODE_MEMBER */
132 134 #define dn_membid dn_u._member._id /* DT_NODE_MEMBER */
133 135 #define dn_xlator dn_u._xlator._xlator /* DT_NODE_XLATOR */
134 136 #define dn_xmember dn_u._xlator._xmemb /* DT_NODE_XLATOR */
135 137 #define dn_members dn_u._xlator._membs /* DT_NODE_XLATOR */
136 138 #define dn_provname dn_u._provider._name /* DT_NODE_PROVIDER */
137 139 #define dn_provider dn_u._provider._pvp /* DT_NODE_PROVIDER */
138 140 #define dn_provred dn_u._provider._redecl /* DT_NODE_PROVIDER */
139 141 #define dn_probes dn_u._provider._probes /* DT_NODE_PROVIDER */
140 142
141 143 #define DT_NODE_FREE 0 /* unused node (waiting to be freed) */
142 144 #define DT_NODE_INT 1 /* integer value */
143 145 #define DT_NODE_STRING 2 /* string value */
144 146 #define DT_NODE_IDENT 3 /* identifier */
145 147 #define DT_NODE_VAR 4 /* variable reference */
146 148 #define DT_NODE_SYM 5 /* symbol reference */
147 149 #define DT_NODE_TYPE 6 /* type reference or formal parameter */
148 150 #define DT_NODE_FUNC 7 /* function call */
149 151 #define DT_NODE_OP1 8 /* unary operator */
150 152 #define DT_NODE_OP2 9 /* binary operator */
151 153 #define DT_NODE_OP3 10 /* ternary operator */
152 154 #define DT_NODE_DEXPR 11 /* D expression action */
153 155 #define DT_NODE_DFUNC 12 /* D function action */
154 156 #define DT_NODE_AGG 13 /* aggregation */
155 157 #define DT_NODE_PDESC 14 /* probe description */
156 158 #define DT_NODE_CLAUSE 15 /* clause definition */
157 159 #define DT_NODE_INLINE 16 /* inline definition */
158 160 #define DT_NODE_MEMBER 17 /* member definition */
159 161 #define DT_NODE_XLATOR 18 /* translator definition */
160 162 #define DT_NODE_PROBE 19 /* probe definition */
161 163 #define DT_NODE_PROVIDER 20 /* provider definition */
162 164 #define DT_NODE_PROG 21 /* program translation unit */
163 165
164 166 #define DT_NF_SIGNED 0x01 /* data is a signed quantity (else unsigned) */
165 167 #define DT_NF_COOKED 0x02 /* data is a known type (else still cooking) */
166 168 #define DT_NF_REF 0x04 /* pass by reference (array, struct, union) */
167 169 #define DT_NF_LVALUE 0x08 /* node is an l-value according to ANSI-C */
168 170 #define DT_NF_WRITABLE 0x10 /* node is writable (can be modified) */
169 171 #define DT_NF_BITFIELD 0x20 /* node is an integer bitfield */
170 172 #define DT_NF_USERLAND 0x40 /* data is a userland address */
171 173
172 174 #define DT_TYPE_NAMELEN 128 /* reasonable size for ctf_type_name() */
173 175
174 176 extern int dt_node_is_integer(const dt_node_t *);
175 177 extern int dt_node_is_float(const dt_node_t *);
176 178 extern int dt_node_is_scalar(const dt_node_t *);
177 179 extern int dt_node_is_arith(const dt_node_t *);
178 180 extern int dt_node_is_vfptr(const dt_node_t *);
179 181 extern int dt_node_is_dynamic(const dt_node_t *);
180 182 extern int dt_node_is_stack(const dt_node_t *);
181 183 extern int dt_node_is_symaddr(const dt_node_t *);
182 184 extern int dt_node_is_usymaddr(const dt_node_t *);
183 185 extern int dt_node_is_string(const dt_node_t *);
184 186 extern int dt_node_is_strcompat(const dt_node_t *);
185 187 extern int dt_node_is_pointer(const dt_node_t *);
186 188 extern int dt_node_is_void(const dt_node_t *);
187 189 extern int dt_node_is_ptrcompat(const dt_node_t *, const dt_node_t *,
188 190 ctf_file_t **, ctf_id_t *);
189 191 extern int dt_node_is_argcompat(const dt_node_t *, const dt_node_t *);
190 192 extern int dt_node_is_posconst(const dt_node_t *);
191 193 extern int dt_node_is_actfunc(const dt_node_t *);
192 194
193 195 extern dt_node_t *dt_node_int(uintmax_t);
194 196 extern dt_node_t *dt_node_string(char *);
195 197 extern dt_node_t *dt_node_ident(char *);
196 198 extern dt_node_t *dt_node_type(dt_decl_t *);
197 199 extern dt_node_t *dt_node_vatype(void);
198 200 extern dt_node_t *dt_node_decl(void);
199 201 extern dt_node_t *dt_node_func(dt_node_t *, dt_node_t *);
200 202 extern dt_node_t *dt_node_offsetof(dt_decl_t *, char *);
201 203 extern dt_node_t *dt_node_op1(int, dt_node_t *);
202 204 extern dt_node_t *dt_node_op2(int, dt_node_t *, dt_node_t *);
203 205 extern dt_node_t *dt_node_op3(dt_node_t *, dt_node_t *, dt_node_t *);
204 206 extern dt_node_t *dt_node_statement(dt_node_t *);
205 207 extern dt_node_t *dt_node_pdesc_by_name(char *);
206 208 extern dt_node_t *dt_node_pdesc_by_id(uintmax_t);
207 209 extern dt_node_t *dt_node_clause(dt_node_t *, dt_node_t *, dt_node_t *);
208 210 extern dt_node_t *dt_node_inline(dt_node_t *);
209 211 extern dt_node_t *dt_node_member(dt_decl_t *, char *, dt_node_t *);
210 212 extern dt_node_t *dt_node_xlator(dt_decl_t *, dt_decl_t *, char *, dt_node_t *);
211 213 extern dt_node_t *dt_node_probe(char *, int, dt_node_t *, dt_node_t *);
212 214 extern dt_node_t *dt_node_provider(char *, dt_node_t *);
213 215 extern dt_node_t *dt_node_program(dt_node_t *);
214 216
215 217 extern dt_node_t *dt_node_link(dt_node_t *, dt_node_t *);
↓ open down ↓ |
175 lines elided |
↑ open up ↑ |
216 218 extern dt_node_t *dt_node_cook(dt_node_t *, uint_t);
217 219
218 220 extern dt_node_t *dt_node_xalloc(dtrace_hdl_t *, int);
219 221 extern void dt_node_free(dt_node_t *);
220 222
221 223 extern dtrace_attribute_t dt_node_list_cook(dt_node_t **, uint_t);
222 224 extern void dt_node_list_free(dt_node_t **);
223 225 extern void dt_node_link_free(dt_node_t **);
224 226
225 227 extern void dt_node_attr_assign(dt_node_t *, dtrace_attribute_t);
226 -extern void dt_node_type_assign(dt_node_t *, ctf_file_t *, ctf_id_t);
228 +extern void dt_node_type_assign(dt_node_t *, ctf_file_t *, ctf_id_t, boolean_t);
227 229 extern void dt_node_type_propagate(const dt_node_t *, dt_node_t *);
228 230 extern const char *dt_node_type_name(const dt_node_t *, char *, size_t);
229 231 extern size_t dt_node_type_size(const dt_node_t *);
230 232
231 233 extern dt_ident_t *dt_node_resolve(const dt_node_t *, uint_t);
232 234 extern size_t dt_node_sizeof(const dt_node_t *);
233 235 extern void dt_node_promote(dt_node_t *, dt_node_t *, dt_node_t *);
234 236
235 237 extern void dt_node_diftype(dtrace_hdl_t *,
236 238 const dt_node_t *, dtrace_diftype_t *);
237 239 extern void dt_node_printr(dt_node_t *, FILE *, int);
238 240 extern const char *dt_node_name(const dt_node_t *, char *, size_t);
239 241 extern int dt_node_root(dt_node_t *);
240 242
241 243 struct dtrace_typeinfo; /* see <dtrace.h> */
242 244 struct dt_pcb; /* see <dt_impl.h> */
243 245
244 246 #define IS_CHAR(e) \
245 247 (((e).cte_format & (CTF_INT_CHAR | CTF_INT_SIGNED)) == \
246 248 (CTF_INT_CHAR | CTF_INT_SIGNED) && (e).cte_bits == NBBY)
247 249
248 250 #define IS_VOID(e) \
249 251 ((e).cte_offset == 0 && (e).cte_bits == 0)
250 252
251 253 extern int dt_type_lookup(const char *, struct dtrace_typeinfo *);
252 254 extern int dt_type_pointer(struct dtrace_typeinfo *);
253 255 extern const char *dt_type_name(ctf_file_t *, ctf_id_t, char *, size_t);
254 256
255 257 typedef enum {
256 258 YYS_CLAUSE, /* lex/yacc state for finding program clauses */
257 259 YYS_DEFINE, /* lex/yacc state for parsing persistent definitions */
258 260 YYS_EXPR, /* lex/yacc state for parsing D expressions */
259 261 YYS_DONE, /* lex/yacc state for indicating parse tree is done */
260 262 YYS_CONTROL /* lex/yacc state for parsing control lines */
261 263 } yystate_t;
262 264
263 265 extern void dnerror(const dt_node_t *, dt_errtag_t, const char *, ...);
264 266 extern void dnwarn(const dt_node_t *, dt_errtag_t, const char *, ...);
265 267
266 268 extern void xyerror(dt_errtag_t, const char *, ...);
267 269 extern void xywarn(dt_errtag_t, const char *, ...);
268 270 extern void xyvwarn(dt_errtag_t, const char *, va_list);
269 271
270 272 extern void yyerror(const char *, ...);
271 273 extern void yywarn(const char *, ...);
272 274 extern void yyvwarn(const char *, va_list);
273 275
274 276 extern void yylabel(const char *);
275 277 extern void yybegin(yystate_t);
276 278 extern void yyinit(struct dt_pcb *);
277 279
278 280 extern int yyparse(void);
279 281 extern int yyinput(void);
280 282
281 283 #ifdef __cplusplus
282 284 }
283 285 #endif
284 286
285 287 #endif /* _DT_PARSER_H */
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX