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_ident.c
          +++ new/usr/src/lib/libdtrace/common/dt_ident.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  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  /*
  23   23   * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright (c) 2013 by Delphix. All rights reserved.
       25 + * Copyright (c) 2013 Joyent, Inc. All rights reserved.
  24   26   */
  25   27  
  26   28  #include <sys/sysmacros.h>
  27   29  #include <strings.h>
  28   30  #include <stdlib.h>
  29   31  #include <alloca.h>
  30   32  #include <assert.h>
  31   33  #include <errno.h>
  32   34  #include <ctype.h>
  33   35  #include <sys/procfs_isa.h>
↓ open down ↓ 54 lines elided ↑ open up ↑
  88   90                              "prototype:\n\tprototype: %s\n\t%9s: %s\n",
  89   91                              prefix, idp->di_name, suffix,
  90   92                              iskey ? "key" : "argument", i + 1,
  91   93                              dt_node_type_name(&isp->dis_args[i], n1,
  92   94                              sizeof (n1)),
  93   95                              iskey ? "key" : "argument",
  94   96                              dt_node_type_name(args, n2, sizeof (n2)));
  95   97                  }
  96   98          }
  97   99  
  98      -        dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
      100 +        dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type, B_FALSE);
  99  101  }
 100  102  
 101  103  /*
 102  104   * Cook an associative array identifier.  If this is the first time we are
 103  105   * cooking this array, create its signature based on the argument list.
 104  106   * Otherwise validate the argument list against the existing signature.
 105  107   */
 106  108  static void
 107  109  dt_idcook_assc(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
 108  110  {
↓ open down ↓ 38 lines elided ↑ open up ↑
 147  149                                      dt_idkind_name(idp->di_kind), i + 1);
 148  150                          }
 149  151  
 150  152                          dt_node_type_propagate(args, &isp->dis_args[i]);
 151  153                          isp->dis_args[i].dn_list = &isp->dis_args[i + 1];
 152  154                  }
 153  155  
 154  156                  if (argc != 0)
 155  157                          isp->dis_args[argc - 1].dn_list = NULL;
 156  158  
 157      -                dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
      159 +                dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type, B_FALSE);
 158  160  
 159  161          } else {
 160  162                  dt_idcook_sign(dnp, idp, argc, args,
 161  163                      idp->di_kind == DT_IDENT_AGG ? "@" : "", "[ ]");
 162  164          }
 163  165  }
 164  166  
 165  167  /*
 166  168   * Cook a function call.  If this is the first time we are cooking this
 167  169   * identifier, create its type signature based on predefined prototype stored
↓ open down ↓ 119 lines elided ↑ open up ↑
 287  289                                      isp->dis_optargs + 1);
 288  290                          }
 289  291  
 290  292                          if (dt_type_lookup(p1, &dtt) == -1) {
 291  293                                  xyerror(D_UNKNOWN, "failed to resolve type of "
 292  294                                      "%s arg#%d (%s): %s\n", idp->di_name, i + 1,
 293  295                                      p1, dtrace_errmsg(dtp, dtrace_errno(dtp)));
 294  296                          }
 295  297  
 296  298                          dt_node_type_assign(&isp->dis_args[i],
 297      -                            dtt.dtt_ctfp, dtt.dtt_type);
      299 +                            dtt.dtt_ctfp, dtt.dtt_type, B_FALSE);
 298  300                  }
 299  301          }
 300  302  
 301  303          dt_idcook_sign(dnp, idp, argc, args, "", "( )");
 302  304  }
 303  305  
 304  306  /*
 305  307   * Cook a reference to the dynamically typed args[] array.  We verify that the
 306  308   * reference is using a single integer constant, and then construct a new ident
 307  309   * representing the appropriate type or translation specifically for this node.
↓ open down ↓ 66 lines elided ↑ open up ↑
 374  376              nnp == xnp || dt_node_is_argcompat(nnp, xnp))) {
 375  377                  dnp->dn_ident = dt_ident_create(idp->di_name, idp->di_kind,
 376  378                      idp->di_flags | DT_IDFLG_ORPHAN, idp->di_id, idp->di_attr,
 377  379                      idp->di_vers, idp->di_ops, idp->di_iarg, idp->di_gen);
 378  380  
 379  381                  if (dnp->dn_ident == NULL)
 380  382                          longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
 381  383  
 382  384                  dt_node_type_assign(dnp,
 383  385                      prp->pr_argv[ap->dn_value].dtt_ctfp,
 384      -                    prp->pr_argv[ap->dn_value].dtt_type);
      386 +                    prp->pr_argv[ap->dn_value].dtt_type,
      387 +                    prp->pr_argv[ap->dn_value].dtt_flags & DTT_FL_USER ?
      388 +                    B_TRUE : B_FALSE);
 385  389  
 386  390          } else if ((dxp = dt_xlator_lookup(dtp,
 387  391              nnp, xnp, DT_XLATE_FUZZY)) != NULL || (
 388  392              dxp = dt_xlator_lookup(dtp, dt_probe_tag(prp, ap->dn_value, &tag),
 389  393              xnp, DT_XLATE_EXACT | DT_XLATE_EXTERN)) != NULL) {
 390  394  
 391  395                  xidp = dt_xlator_ident(dxp, xnp->dn_ctfp, xnp->dn_type);
 392  396  
 393  397                  dnp->dn_ident = dt_ident_create(idp->di_name, xidp->di_kind,
 394  398                      xidp->di_flags | DT_IDFLG_ORPHAN, idp->di_id, idp->di_attr,
↓ open down ↓ 7 lines elided ↑ open up ↑
 402  406  
 403  407                  /*
 404  408                   * Propagate relevant members from the translator's internal
 405  409                   * dt_ident_t.  This code must be kept in sync with the state
 406  410                   * that is initialized for idents in dt_xlator_create().
 407  411                   */
 408  412                  dnp->dn_ident->di_data = xidp->di_data;
 409  413                  dnp->dn_ident->di_ctfp = xidp->di_ctfp;
 410  414                  dnp->dn_ident->di_type = xidp->di_type;
 411  415  
 412      -                dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
      416 +                dt_node_type_assign(dnp, DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp),
      417 +                    B_FALSE);
 413  418  
 414  419          } else {
 415  420                  xyerror(D_ARGS_XLATOR, "translator for %s[%lld] from %s to %s "
 416  421                      "is not defined\n", idp->di_name, (longlong_t)ap->dn_value,
 417  422                      dt_node_type_name(nnp, n1, sizeof (n1)),
 418  423                      dt_node_type_name(xnp, n2, sizeof (n2)));
 419  424          }
 420  425  
 421  426          assert(dnp->dn_ident->di_flags & DT_IDFLG_ORPHAN);
 422  427          assert(dnp->dn_ident->di_id == idp->di_id);
↓ open down ↓ 25 lines elided ↑ open up ↑
 448  453          }
 449  454  
 450  455          if (dt_type_lookup("uint64_t", &dtt) == -1) {
 451  456                  xyerror(D_UNKNOWN, "failed to resolve type of %s: %s\n",
 452  457                      idp->di_name, dtrace_errmsg(dtp, dtrace_errno(dtp)));
 453  458          }
 454  459  
 455  460          idp->di_ctfp = dtt.dtt_ctfp;
 456  461          idp->di_type = dtt.dtt_type;
 457  462  
 458      -        dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
      463 +        dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type, B_FALSE);
 459  464  }
 460  465  
 461  466  /*ARGSUSED*/
 462  467  static void
 463  468  dt_idcook_type(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
 464  469  {
 465  470          if (idp->di_type == CTF_ERR) {
 466  471                  dtrace_hdl_t *dtp = yypcb->pcb_hdl;
 467  472                  dtrace_typeinfo_t dtt;
 468  473  
↓ open down ↓ 1 lines elided ↑ open up ↑
 470  475                          xyerror(D_UNKNOWN,
 471  476                              "failed to resolve type %s for identifier %s: %s\n",
 472  477                              (const char *)idp->di_iarg, idp->di_name,
 473  478                              dtrace_errmsg(dtp, dtrace_errno(dtp)));
 474  479                  }
 475  480  
 476  481                  idp->di_ctfp = dtt.dtt_ctfp;
 477  482                  idp->di_type = dtt.dtt_type;
 478  483          }
 479  484  
 480      -        dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
      485 +        dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type, B_FALSE);
 481  486  }
 482  487  
 483  488  /*ARGSUSED*/
 484  489  static void
 485  490  dt_idcook_thaw(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
 486  491  {
 487  492          if (idp->di_ctfp != NULL && idp->di_type != CTF_ERR)
 488      -                dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type);
      493 +                dt_node_type_assign(dnp, idp->di_ctfp, idp->di_type, B_FALSE);
 489  494  }
 490  495  
 491  496  static void
 492  497  dt_idcook_inline(dt_node_t *dnp, dt_ident_t *idp, int argc, dt_node_t *args)
 493  498  {
 494  499          if (idp->di_kind == DT_IDENT_ARRAY)
 495  500                  dt_idcook_assc(dnp, idp, argc, args);
 496  501          else
 497  502                  dt_idcook_thaw(dnp, idp, argc, args);
 498  503  }
↓ open down ↓ 539 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX