Print this page
7085 add support for "if" and "else" statements in dtrace
@@ -25,10 +25,14 @@
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2014 by Delphix. All rights reserved.
+ */
+
#ifndef _DT_PARSER_H
#define _DT_PARSER_H
#include <sys/types.h>
#include <sys/dtrace.h>
@@ -103,10 +107,16 @@
char *_name; /* string name of provider */
struct dt_provider *_pvp; /* provider references */
struct dt_node *_probes; /* list of probe nodes */
int _redecl; /* provider redeclared */
} _provider;
+
+ struct {
+ struct dt_node *_conditional;
+ struct dt_node *_body;
+ struct dt_node *_alternate_body;
+ } _conditional;
} dn_u;
struct dt_node *dn_list; /* parse tree list link */
struct dt_node *dn_link; /* allocation list link */
} dt_node_t;
@@ -138,10 +148,15 @@
#define dn_provname dn_u._provider._name /* DT_NODE_PROVIDER */
#define dn_provider dn_u._provider._pvp /* DT_NODE_PROVIDER */
#define dn_provred dn_u._provider._redecl /* DT_NODE_PROVIDER */
#define dn_probes dn_u._provider._probes /* DT_NODE_PROVIDER */
+/* DT_NODE_IF: */
+#define dn_conditional dn_u._conditional._conditional
+#define dn_body dn_u._conditional._body
+#define dn_alternate_body dn_u._conditional._alternate_body
+
#define DT_NODE_FREE 0 /* unused node (waiting to be freed) */
#define DT_NODE_INT 1 /* integer value */
#define DT_NODE_STRING 2 /* string value */
#define DT_NODE_IDENT 3 /* identifier */
#define DT_NODE_VAR 4 /* variable reference */
@@ -160,10 +175,11 @@
#define DT_NODE_MEMBER 17 /* member definition */
#define DT_NODE_XLATOR 18 /* translator definition */
#define DT_NODE_PROBE 19 /* probe definition */
#define DT_NODE_PROVIDER 20 /* provider definition */
#define DT_NODE_PROG 21 /* program translation unit */
+#define DT_NODE_IF 22 /* if statement */
#define DT_NF_SIGNED 0x01 /* data is a signed quantity (else unsigned) */
#define DT_NF_COOKED 0x02 /* data is a known type (else still cooking) */
#define DT_NF_REF 0x04 /* pass by reference (array, struct, union) */
#define DT_NF_LVALUE 0x08 /* node is an l-value according to ANSI-C */
@@ -211,10 +227,11 @@
extern dt_node_t *dt_node_member(dt_decl_t *, char *, dt_node_t *);
extern dt_node_t *dt_node_xlator(dt_decl_t *, dt_decl_t *, char *, dt_node_t *);
extern dt_node_t *dt_node_probe(char *, int, dt_node_t *, dt_node_t *);
extern dt_node_t *dt_node_provider(char *, dt_node_t *);
extern dt_node_t *dt_node_program(dt_node_t *);
+extern dt_node_t *dt_node_if(dt_node_t *, dt_node_t *, dt_node_t *);
extern dt_node_t *dt_node_link(dt_node_t *, dt_node_t *);
extern dt_node_t *dt_node_cook(dt_node_t *, uint_t);
extern dt_node_t *dt_node_xalloc(dtrace_hdl_t *, int);
@@ -235,10 +252,11 @@
extern void dt_node_promote(dt_node_t *, dt_node_t *, dt_node_t *);
extern void dt_node_diftype(dtrace_hdl_t *,
const dt_node_t *, dtrace_diftype_t *);
extern void dt_node_printr(dt_node_t *, FILE *, int);
+extern void dt_printd(dt_node_t *, FILE *, int);
extern const char *dt_node_name(const dt_node_t *, char *, size_t);
extern int dt_node_root(dt_node_t *);
struct dtrace_typeinfo; /* see <dtrace.h> */
struct dt_pcb; /* see <dt_impl.h> */