Print this page
7085 add support for "if" and "else" statements in dtrace

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libdtrace/common/dt_parser.h
          +++ new/usr/src/lib/libdtrace/common/dt_parser.h
↓ open down ↓ 19 lines elided ↑ open up ↑
  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   25  /*
  26   26   * Copyright (c) 2013 by Delphix. All rights reserved.
  27   27   * Copyright (c) 2013 Joyent, Inc. All rights reserved.
  28   28   */
  29   29  
       30 +/*
       31 + * Copyright (c) 2014 by Delphix. All rights reserved.
       32 + */
       33 +
  30   34  #ifndef _DT_PARSER_H
  31   35  #define _DT_PARSER_H
  32   36  
  33   37  #include <sys/types.h>
  34   38  #include <sys/dtrace.h>
  35   39  
  36   40  #include <libctf.h>
  37   41  #include <stdarg.h>
  38   42  #include <stdio.h>
  39   43  
↓ open down ↓ 58 lines elided ↑ open up ↑
  98  102                          struct dt_node *_xmemb; /* individual xlator member */
  99  103                          struct dt_node *_membs; /* list of member nodes */
 100  104                  } _xlator;
 101  105  
 102  106                  struct {
 103  107                          char *_name;            /* string name of provider */
 104  108                          struct dt_provider *_pvp; /* provider references */
 105  109                          struct dt_node *_probes;  /* list of probe nodes */
 106  110                          int _redecl;            /* provider redeclared */
 107  111                  } _provider;
      112 +
      113 +                struct {
      114 +                        struct dt_node *_conditional;
      115 +                        struct dt_node *_body;
      116 +                        struct dt_node *_alternate_body;
      117 +                } _conditional;
 108  118          } dn_u;
 109  119  
 110  120          struct dt_node *dn_list; /* parse tree list link */
 111  121          struct dt_node *dn_link; /* allocation list link */
 112  122  } dt_node_t;
 113  123  
 114  124  #define dn_value        dn_u._const._value      /* DT_NODE_INT */
 115  125  #define dn_string       dn_u._const._string     /* STRING, IDENT, TYPE */
 116  126  #define dn_ident        dn_u._nodes._ident      /* VAR,SYM,FUN,AGG,INL,PROBE */
 117  127  #define dn_args         dn_u._nodes._links[0]   /* DT_NODE_VAR, FUNC */
↓ open down ↓ 15 lines elided ↑ open up ↑
 133  143  #define dn_membxlator   dn_u._member._xlator    /* DT_NODE_MEMBER */
 134  144  #define dn_membid       dn_u._member._id        /* DT_NODE_MEMBER */
 135  145  #define dn_xlator       dn_u._xlator._xlator    /* DT_NODE_XLATOR */
 136  146  #define dn_xmember      dn_u._xlator._xmemb     /* DT_NODE_XLATOR */
 137  147  #define dn_members      dn_u._xlator._membs     /* DT_NODE_XLATOR */
 138  148  #define dn_provname     dn_u._provider._name    /* DT_NODE_PROVIDER */
 139  149  #define dn_provider     dn_u._provider._pvp     /* DT_NODE_PROVIDER */
 140  150  #define dn_provred      dn_u._provider._redecl  /* DT_NODE_PROVIDER */
 141  151  #define dn_probes       dn_u._provider._probes  /* DT_NODE_PROVIDER */
 142  152  
      153 +/* DT_NODE_IF: */
      154 +#define dn_conditional          dn_u._conditional._conditional
      155 +#define dn_body                 dn_u._conditional._body
      156 +#define dn_alternate_body       dn_u._conditional._alternate_body
      157 +
 143  158  #define DT_NODE_FREE    0       /* unused node (waiting to be freed) */
 144  159  #define DT_NODE_INT     1       /* integer value */
 145  160  #define DT_NODE_STRING  2       /* string value */
 146  161  #define DT_NODE_IDENT   3       /* identifier */
 147  162  #define DT_NODE_VAR     4       /* variable reference */
 148  163  #define DT_NODE_SYM     5       /* symbol reference */
 149  164  #define DT_NODE_TYPE    6       /* type reference or formal parameter */
 150  165  #define DT_NODE_FUNC    7       /* function call */
 151  166  #define DT_NODE_OP1     8       /* unary operator */
 152  167  #define DT_NODE_OP2     9       /* binary operator */
↓ open down ↓ 2 lines elided ↑ open up ↑
 155  170  #define DT_NODE_DFUNC   12      /* D function action */
 156  171  #define DT_NODE_AGG     13      /* aggregation */
 157  172  #define DT_NODE_PDESC   14      /* probe description */
 158  173  #define DT_NODE_CLAUSE  15      /* clause definition */
 159  174  #define DT_NODE_INLINE  16      /* inline definition */
 160  175  #define DT_NODE_MEMBER  17      /* member definition */
 161  176  #define DT_NODE_XLATOR  18      /* translator definition */
 162  177  #define DT_NODE_PROBE   19      /* probe definition */
 163  178  #define DT_NODE_PROVIDER 20     /* provider definition */
 164  179  #define DT_NODE_PROG    21      /* program translation unit */
      180 +#define DT_NODE_IF      22      /* if statement */
 165  181  
 166  182  #define DT_NF_SIGNED    0x01    /* data is a signed quantity (else unsigned) */
 167  183  #define DT_NF_COOKED    0x02    /* data is a known type (else still cooking) */
 168  184  #define DT_NF_REF       0x04    /* pass by reference (array, struct, union) */
 169  185  #define DT_NF_LVALUE    0x08    /* node is an l-value according to ANSI-C */
 170  186  #define DT_NF_WRITABLE  0x10    /* node is writable (can be modified) */
 171  187  #define DT_NF_BITFIELD  0x20    /* node is an integer bitfield */
 172  188  #define DT_NF_USERLAND  0x40    /* data is a userland address */
 173  189  
 174  190  #define DT_TYPE_NAMELEN 128     /* reasonable size for ctf_type_name() */
↓ open down ↓ 31 lines elided ↑ open up ↑
 206  222  extern dt_node_t *dt_node_statement(dt_node_t *);
 207  223  extern dt_node_t *dt_node_pdesc_by_name(char *);
 208  224  extern dt_node_t *dt_node_pdesc_by_id(uintmax_t);
 209  225  extern dt_node_t *dt_node_clause(dt_node_t *, dt_node_t *, dt_node_t *);
 210  226  extern dt_node_t *dt_node_inline(dt_node_t *);
 211  227  extern dt_node_t *dt_node_member(dt_decl_t *, char *, dt_node_t *);
 212  228  extern dt_node_t *dt_node_xlator(dt_decl_t *, dt_decl_t *, char *, dt_node_t *);
 213  229  extern dt_node_t *dt_node_probe(char *, int, dt_node_t *, dt_node_t *);
 214  230  extern dt_node_t *dt_node_provider(char *, dt_node_t *);
 215  231  extern dt_node_t *dt_node_program(dt_node_t *);
      232 +extern dt_node_t *dt_node_if(dt_node_t *, dt_node_t *, dt_node_t *);
 216  233  
 217  234  extern dt_node_t *dt_node_link(dt_node_t *, dt_node_t *);
 218  235  extern dt_node_t *dt_node_cook(dt_node_t *, uint_t);
 219  236  
 220  237  extern dt_node_t *dt_node_xalloc(dtrace_hdl_t *, int);
 221  238  extern void dt_node_free(dt_node_t *);
 222  239  
 223  240  extern dtrace_attribute_t dt_node_list_cook(dt_node_t **, uint_t);
 224  241  extern void dt_node_list_free(dt_node_t **);
 225  242  extern void dt_node_link_free(dt_node_t **);
↓ open down ↓ 4 lines elided ↑ open up ↑
 230  247  extern const char *dt_node_type_name(const dt_node_t *, char *, size_t);
 231  248  extern size_t dt_node_type_size(const dt_node_t *);
 232  249  
 233  250  extern dt_ident_t *dt_node_resolve(const dt_node_t *, uint_t);
 234  251  extern size_t dt_node_sizeof(const dt_node_t *);
 235  252  extern void dt_node_promote(dt_node_t *, dt_node_t *, dt_node_t *);
 236  253  
 237  254  extern void dt_node_diftype(dtrace_hdl_t *,
 238  255      const dt_node_t *, dtrace_diftype_t *);
 239  256  extern void dt_node_printr(dt_node_t *, FILE *, int);
      257 +extern void dt_printd(dt_node_t *, FILE *, int);
 240  258  extern const char *dt_node_name(const dt_node_t *, char *, size_t);
 241  259  extern int dt_node_root(dt_node_t *);
 242  260  
 243  261  struct dtrace_typeinfo; /* see <dtrace.h> */
 244  262  struct dt_pcb;          /* see <dt_impl.h> */
 245  263  
 246  264  #define IS_CHAR(e) \
 247  265          (((e).cte_format & (CTF_INT_CHAR | CTF_INT_SIGNED)) == \
 248  266          (CTF_INT_CHAR | CTF_INT_SIGNED) && (e).cte_bits == NBBY)
 249  267  
↓ open down ↓ 38 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX