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_provider.c
          +++ new/usr/src/lib/libdtrace/common/dt_provider.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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 2006 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26      -
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       26 +/*
       27 + * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
       28 + */
  28   29  
  29   30  #include <sys/types.h>
  30   31  #include <sys/sysmacros.h>
  31   32  
  32   33  #include <assert.h>
  33   34  #include <limits.h>
  34   35  #include <strings.h>
  35   36  #include <stdlib.h>
  36   37  #include <alloca.h>
  37   38  #include <unistd.h>
  38   39  #include <errno.h>
  39   40  
  40   41  #include <dt_provider.h>
  41   42  #include <dt_module.h>
  42   43  #include <dt_string.h>
  43   44  #include <dt_list.h>
       45 +#include <dt_pid.h>
       46 +#include <dtrace.h>
  44   47  
  45   48  static dt_provider_t *
  46   49  dt_provider_insert(dtrace_hdl_t *dtp, dt_provider_t *pvp, uint_t h)
  47   50  {
  48   51          dt_list_append(&dtp->dt_provlist, pvp);
  49   52  
  50   53          pvp->pv_next = dtp->dt_provs[h];
  51   54          dtp->dt_provs[h] = pvp;
  52   55          dtp->dt_nprovs++;
  53   56  
↓ open down ↓ 208 lines elided ↑ open up ↑
 262  265                  if (adp->dtargd_ndx == DTRACE_ARGNONE)
 263  266                          break; /* all argument descs have been retrieved */
 264  267  
 265  268                  nc = MAX(nc, adp->dtargd_mapping);
 266  269          }
 267  270  
 268  271          xc = i;
 269  272          nc++;
 270  273  
 271  274          /*
      275 +         * The pid provider believes in giving the kernel a break. No reason to
      276 +         * give the kernel all the ctf containers that we're keeping ourselves
      277 +         * just to get it back from it. So if we're coming from a pid provider
      278 +         * probe and the kernel gave us no argument information we'll get some
      279 +         * here. If for some crazy reason the kernel knows about our userland
      280 +         * types then we just ignore this.
      281 +         */
      282 +        if (xc == 0 && nc == 0 &&
      283 +            strncmp(pvp->pv_desc.dtvd_name, "pid", 3) == 0) {
      284 +                nc = adc;
      285 +                dt_pid_get_types(dtp, pdp, adv, &nc);
      286 +                xc = nc;
      287 +        }
      288 +
      289 +        /*
 272  290           * Now that we have discovered the number of native and translated
 273  291           * arguments from the argument descriptions, allocate a new probe ident
 274  292           * and corresponding dt_probe_t and hash it into the provider.
 275  293           */
 276  294          xargs = dt_probe_alloc_args(pvp, xc);
 277  295          nargs = dt_probe_alloc_args(pvp, nc);
 278  296  
 279  297          if ((xc != 0 && xargs == NULL) || (nc != 0 && nargs == NULL))
 280  298                  return (NULL); /* dt_errno is set for us */
 281  299  
↓ open down ↓ 25 lines elided ↑ open up ↑
 307  325                          dt_dprintf("failed to resolve input type %s "
 308  326                              "for %s:%s arg #%d: %s\n", adp->dtargd_native,
 309  327                              pvp->pv_desc.dtvd_name, name, i + 1,
 310  328                              dtrace_errmsg(dtp, dtrace_errno(dtp)));
 311  329  
 312  330                          dtt.dtt_object = NULL;
 313  331                          dtt.dtt_ctfp = NULL;
 314  332                          dtt.dtt_type = CTF_ERR;
 315  333                  } else {
 316  334                          dt_node_type_assign(prp->pr_nargv[adp->dtargd_mapping],
 317      -                            dtt.dtt_ctfp, dtt.dtt_type);
      335 +                            dtt.dtt_ctfp, dtt.dtt_type,
      336 +                            dtt.dtt_flags & DTT_FL_USER ? B_TRUE : B_FALSE);
 318  337                  }
 319  338  
 320  339                  if (dtt.dtt_type != CTF_ERR && (adp->dtargd_xlate[0] == '\0' ||
 321  340                      strcmp(adp->dtargd_native, adp->dtargd_xlate) == 0)) {
 322  341                          dt_node_type_propagate(prp->pr_nargv[
 323  342                              adp->dtargd_mapping], prp->pr_xargv[i]);
 324  343                  } else if (dtrace_type_strcompile(dtp,
 325  344                      adp->dtargd_xlate, &dtt) != 0) {
 326  345                          dt_dprintf("failed to resolve output type %s "
 327  346                              "for %s:%s arg #%d: %s\n", adp->dtargd_xlate,
 328  347                              pvp->pv_desc.dtvd_name, name, i + 1,
 329  348                              dtrace_errmsg(dtp, dtrace_errno(dtp)));
 330  349  
 331  350                          dtt.dtt_object = NULL;
 332  351                          dtt.dtt_ctfp = NULL;
 333  352                          dtt.dtt_type = CTF_ERR;
 334  353                  } else {
 335  354                          dt_node_type_assign(prp->pr_xargv[i],
 336      -                            dtt.dtt_ctfp, dtt.dtt_type);
      355 +                            dtt.dtt_ctfp, dtt.dtt_type, B_FALSE);
 337  356                  }
 338  357  
 339  358                  prp->pr_mapping[i] = adp->dtargd_mapping;
 340  359                  prp->pr_argv[i] = dtt;
 341  360          }
 342  361  
 343  362          return (prp);
 344  363  }
 345  364  
 346  365  /*
↓ open down ↓ 280 lines elided ↑ open up ↑
 627  646                  if (dtt.dtt_type == CTF_ERR ||
 628  647                      ctf_update(dtt.dtt_ctfp) == CTF_ERR) {
 629  648                          xyerror(D_UNKNOWN, "cannot define type %s: %s\n",
 630  649                              tag, ctf_errmsg(ctf_errno(dtt.dtt_ctfp)));
 631  650                  }
 632  651          }
 633  652  
 634  653          bzero(dnp, sizeof (dt_node_t));
 635  654          dnp->dn_kind = DT_NODE_TYPE;
 636  655  
 637      -        dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type);
      656 +        dt_node_type_assign(dnp, dtt.dtt_ctfp, dtt.dtt_type, B_FALSE);
 638  657          dt_node_attr_assign(dnp, _dtrace_defattr);
 639  658  
 640  659          return (dnp);
 641  660  }
 642  661  
 643  662  /*ARGSUSED*/
 644  663  static int
 645  664  dt_probe_desc(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp, void *arg)
 646  665  {
 647  666          if (((dtrace_probedesc_t *)arg)->dtpd_id == DTRACE_IDNONE) {
↓ open down ↓ 232 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX