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_cc.c
          +++ new/usr/src/lib/libdtrace/common/dt_cc.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) 2011, Joyent Inc. All rights reserved.
       24 + * Copyright (c) 2013, Joyent Inc. All rights reserved.
  25   25   * Copyright (c) 2012 by Delphix. All rights reserved.
  26   26   */
  27   27  
  28   28  /*
  29   29   * DTrace D Language Compiler
  30   30   *
  31   31   * The code in this source file implements the main engine for the D language
  32   32   * compiler.  The driver routine for the compiler is dt_compile(), below.  The
  33   33   * compiler operates on either stdio FILEs or in-memory strings as its input
  34   34   * and can produce either dtrace_prog_t structures from a D program or a single
↓ open down ↓ 620 lines elided ↑ open up ↑
 655  655                  ap = dt_stmt_action(dtp, sdp);
 656  656                  dt_cg(yypcb, anp);
 657  657                  ap->dtad_difo = dt_as(yypcb);
 658  658                  ap->dtad_kind = kind;
 659  659          }
 660  660  }
 661  661  
 662  662  static void
 663  663  dt_action_trace(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
 664  664  {
      665 +        int ctflib;
      666 +
 665  667          dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
 666  668          boolean_t istrace = (dnp->dn_ident->di_id == DT_ACT_TRACE);
 667  669          const char *act = istrace ?  "trace" : "print";
 668  670  
 669  671          if (dt_node_is_void(dnp->dn_args)) {
 670  672                  dnerror(dnp->dn_args, istrace ? D_TRACE_VOID : D_PRINT_VOID,
 671  673                      "%s( ) may not be applied to a void expression\n", act);
 672  674          }
 673  675  
 674  676          if (dt_node_resolve(dnp->dn_args, DT_IDENT_XLPTR) != NULL) {
↓ open down ↓ 11 lines elided ↑ open up ↑
 686  688  
 687  689          /*
 688  690           * The print() action behaves identically to trace(), except that it
 689  691           * stores the CTF type of the argument (if present) within the DOF for
 690  692           * the DIFEXPR action.  To do this, we set the 'dtsd_strdata' to point
 691  693           * to the fully-qualified CTF type ID for the result of the DIF
 692  694           * action.  We use the ID instead of the name to handles complex types
 693  695           * like arrays and function pointers that can't be resolved by
 694  696           * ctf_type_lookup().  This is later processed by dtrace_dof_create()
 695  697           * and turned into a reference into the string table so that we can
 696      -         * get the type information when we process the data after the fact.
      698 +         * get the type information when we process the data after the fact.  In
      699 +         * the case where we are referring to userland CTF data, we also need to
      700 +         * to identify which ctf container in question we care about and encode
      701 +         * that within the name.
 697  702           */
 698  703          if (dnp->dn_ident->di_id == DT_ACT_PRINT) {
 699  704                  dt_node_t *dret;
 700  705                  size_t n;
 701  706                  dt_module_t *dmp;
 702  707  
 703  708                  dret = yypcb->pcb_dret;
 704  709                  dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp);
 705  710  
 706      -                n = snprintf(NULL, 0, "%s`%d", dmp->dm_name, dret->dn_type) + 1;
      711 +                if (dmp->dm_pid != 0) {
      712 +                        ctflib = dt_module_getlibid(dtp, dmp, dret->dn_ctfp);
      713 +                        assert(ctflib >= 0);
      714 +                        n = snprintf(NULL, 0, "%s`%d`%d", dmp->dm_name,
      715 +                            ctflib, dret->dn_type) + 1;
      716 +                } else {
      717 +                        n = snprintf(NULL, 0, "%s`%d", dmp->dm_name,
      718 +                            dret->dn_type) + 1;
      719 +                }
 707  720                  sdp->dtsd_strdata = dt_alloc(dtp, n);
 708  721                  if (sdp->dtsd_strdata == NULL)
 709  722                          longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
 710      -                (void) snprintf(sdp->dtsd_strdata, n, "%s`%d", dmp->dm_name,
 711      -                    dret->dn_type);
      723 +                if (dmp->dm_pid != 0) {
      724 +                        (void) snprintf(sdp->dtsd_strdata, n, "%s`%d`%d",
      725 +                            dmp->dm_name, ctflib, dret->dn_type);
      726 +                } else {
      727 +                        (void) snprintf(sdp->dtsd_strdata, n, "%s`%d",
      728 +                            dmp->dm_name, dret->dn_type);
      729 +                }
 712  730          }
 713  731  
 714  732          ap->dtad_difo = dt_as(yypcb);
 715  733          ap->dtad_kind = DTRACEACT_DIFEXPR;
 716  734  }
 717  735  
 718  736  static void
 719  737  dt_action_tracemem(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
 720  738  {
 721  739          dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
↓ open down ↓ 1792 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX