Print this page
INTRO-118 enabling USDT probes in zones should be more scalable


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011 by Delphix. All rights reserved.

  25  */
  26 
  27 #include <unistd.h>
  28 #include <strings.h>
  29 #include <stdlib.h>
  30 #include <errno.h>
  31 #include <assert.h>
  32 #include <ctype.h>
  33 #include <alloca.h>
  34 
  35 #include <dt_impl.h>
  36 #include <dt_program.h>
  37 #include <dt_printf.h>
  38 #include <dt_provider.h>
  39 
  40 dtrace_prog_t *
  41 dt_program_create(dtrace_hdl_t *dtp)
  42 {
  43         dtrace_prog_t *pgp = dt_zalloc(dtp, sizeof (dtrace_prog_t));
  44 


 137                                 continue;
 138 
 139                         if (ap->dtad_kind == DTRACEACT_DIFEXPR &&
 140                             ap->dtad_difo->dtdo_rtype.dtdt_kind ==
 141                             DIF_TYPE_CTF &&
 142                             ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
 143                                 continue;
 144 
 145                         pip->dpi_recgens++;
 146                 }
 147         }
 148 }
 149 
 150 int
 151 dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
 152     dtrace_proginfo_t *pip)
 153 {
 154         void *dof;
 155         int n, err;
 156 


















 157         dtrace_program_info(dtp, pgp, pip);
 158 
 159         if ((dof = dtrace_dof_create(dtp, pgp, DTRACE_D_STRIP)) == NULL)
 160                 return (-1);
 161 
 162         n = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof);
 163         dtrace_dof_destroy(dtp, dof);
 164 
 165         if (n == -1) {
 166                 switch (errno) {
 167                 case EINVAL:
 168                         err = EDT_DIFINVAL;
 169                         break;
 170                 case EFAULT:
 171                         err = EDT_DIFFAULT;
 172                         break;
 173                 case E2BIG:
 174                         err = EDT_DIFSIZE;
 175                         break;
 176                 case EBUSY:




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011 by Delphix. All rights reserved.
  25  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  26  */
  27 
  28 #include <unistd.h>
  29 #include <strings.h>
  30 #include <stdlib.h>
  31 #include <errno.h>
  32 #include <assert.h>
  33 #include <ctype.h>
  34 #include <alloca.h>
  35 
  36 #include <dt_impl.h>
  37 #include <dt_program.h>
  38 #include <dt_printf.h>
  39 #include <dt_provider.h>
  40 
  41 dtrace_prog_t *
  42 dt_program_create(dtrace_hdl_t *dtp)
  43 {
  44         dtrace_prog_t *pgp = dt_zalloc(dtp, sizeof (dtrace_prog_t));
  45 


 138                                 continue;
 139 
 140                         if (ap->dtad_kind == DTRACEACT_DIFEXPR &&
 141                             ap->dtad_difo->dtdo_rtype.dtdt_kind ==
 142                             DIF_TYPE_CTF &&
 143                             ap->dtad_difo->dtdo_rtype.dtdt_size == 0)
 144                                 continue;
 145 
 146                         pip->dpi_recgens++;
 147                 }
 148         }
 149 }
 150 
 151 int
 152 dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp,
 153     dtrace_proginfo_t *pip)
 154 {
 155         void *dof;
 156         int n, err;
 157 
 158         if (!dtp->dt_optset) {
 159                 /*
 160                  * If we have not yet ioctl'd down our options DOF, we'll
 161                  * do that before enabling any probes (some options will
 162                  * affect which probes we match).
 163                  */
 164                 if ((dof = dtrace_getopt_dof(dtp)) == NULL)
 165                         return (-1); /* dt_errno has been set for us */
 166 
 167                 err = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof);
 168                 dtrace_dof_destroy(dtp, dof);
 169 
 170                 if (err == -1)
 171                         return (-1);
 172 
 173                 dtp->dt_optset = B_TRUE;
 174         }
 175 
 176         dtrace_program_info(dtp, pgp, pip);
 177 
 178         if ((dof = dtrace_dof_create(dtp, pgp, DTRACE_D_STRIP)) == NULL)
 179                 return (-1);
 180 
 181         n = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof);
 182         dtrace_dof_destroy(dtp, dof);
 183 
 184         if (n == -1) {
 185                 switch (errno) {
 186                 case EINVAL:
 187                         err = EDT_DIFINVAL;
 188                         break;
 189                 case EFAULT:
 190                         err = EDT_DIFFAULT;
 191                         break;
 192                 case E2BIG:
 193                         err = EDT_DIFSIZE;
 194                         break;
 195                 case EBUSY: