4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
25 static int dtrace_verbose_ioctl;
26 SYSCTL_INT(_debug_dtrace, OID_AUTO, verbose_ioctl, CTLFLAG_RW,
27 &dtrace_verbose_ioctl, 0, "log DTrace ioctls");
29 #define DTRACE_IOCTL_PRINTF(fmt, ...) if (dtrace_verbose_ioctl) printf(fmt, ## __VA_ARGS__ )
32 dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
36 dof_helper_t *dhp = NULL;
37 dof_hdr_t *dof = NULL;
40 case DTRACEHIOC_ADDDOF:
41 dhp = (dof_helper_t *)addr;
42 /* XXX all because dofhp_dof is 64 bit */
44 addr = (caddr_t)(uint32_t)dhp->dofhp_dof;
46 addr = (caddr_t)dhp->dofhp_dof;
50 dof = dtrace_dof_copyin((intptr_t)addr, &rval);
55 mutex_enter(&dtrace_lock);
56 if ((rval = dtrace_helper_slurp((dof_hdr_t *)dof, dhp)) != -1) {
59 copyout(dhp, addr, sizeof(*dhp));
65 mutex_exit(&dtrace_lock);
67 case DTRACEHIOC_REMOVE:
68 mutex_enter(&dtrace_lock);
69 rval = dtrace_helper_destroygen((int)*addr);
70 mutex_exit(&dtrace_lock);
82 dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
83 int flags __unused, struct thread *td)
85 #if __FreeBSD_version < 800039
86 dtrace_state_t *state = dev->si_drv1;
88 dtrace_state_t *state;
89 devfs_get_cdevpriv((void **) &state);
95 if (state->dts_anon) {
96 ASSERT(dtrace_anon.dta_state == NULL);
97 state = state->dts_anon;
101 case DTRACEIOC_AGGDESC: {
102 dtrace_aggdesc_t **paggdesc = (dtrace_aggdesc_t **) addr;
103 dtrace_aggdesc_t aggdesc;
104 dtrace_action_t *act;
105 dtrace_aggregation_t *agg;
108 dtrace_recdesc_t *lrec;
113 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_AGGDESC\n",__func__,__LINE__);
115 if (copyin((void *) *paggdesc, &aggdesc, sizeof (aggdesc)) != 0)
118 mutex_enter(&dtrace_lock);
120 if ((agg = dtrace_aggid2agg(state, aggdesc.dtagd_id)) == NULL) {
121 mutex_exit(&dtrace_lock);
125 aggdesc.dtagd_epid = agg->dtag_ecb->dte_epid;
127 nrecs = aggdesc.dtagd_nrecs;
128 aggdesc.dtagd_nrecs = 0;
130 offs = agg->dtag_base;
131 lrec = &agg->dtag_action.dta_rec;
132 aggdesc.dtagd_size = lrec->dtrd_offset + lrec->dtrd_size - offs;
134 for (act = agg->dtag_first; ; act = act->dta_next) {
135 ASSERT(act->dta_intuple ||
136 DTRACEACT_ISAGG(act->dta_kind));
139 * If this action has a record size of zero, it
140 * denotes an argument to the aggregating action.
141 * Because the presence of this record doesn't (or
142 * shouldn't) affect the way the data is interpreted,
143 * we don't copy it out to save user-level the
144 * confusion of dealing with a zero-length record.
146 if (act->dta_rec.dtrd_size == 0) {
147 ASSERT(agg->dtag_hasarg);
151 aggdesc.dtagd_nrecs++;
153 if (act == &agg->dtag_action)
158 * Now that we have the size, we need to allocate a temporary
159 * buffer in which to store the complete description. We need
160 * the temporary buffer to be able to drop dtrace_lock()
161 * across the copyout(), below.
163 size = sizeof (dtrace_aggdesc_t) +
164 (aggdesc.dtagd_nrecs * sizeof (dtrace_recdesc_t));
166 buf = kmem_alloc(size, KM_SLEEP);
167 dest = (uintptr_t)buf;
169 bcopy(&aggdesc, (void *)dest, sizeof (aggdesc));
170 dest += offsetof(dtrace_aggdesc_t, dtagd_rec[0]);
172 for (act = agg->dtag_first; ; act = act->dta_next) {
173 dtrace_recdesc_t rec = act->dta_rec;
176 * See the comment in the above loop for why we pass
177 * over zero-length records.
179 if (rec.dtrd_size == 0) {
180 ASSERT(agg->dtag_hasarg);
187 rec.dtrd_offset -= offs;
188 bcopy(&rec, (void *)dest, sizeof (rec));
189 dest += sizeof (dtrace_recdesc_t);
191 if (act == &agg->dtag_action)
195 mutex_exit(&dtrace_lock);
197 if (copyout(buf, (void *) *paggdesc, dest - (uintptr_t)buf) != 0) {
198 kmem_free(buf, size);
202 kmem_free(buf, size);
205 case DTRACEIOC_AGGSNAP:
206 case DTRACEIOC_BUFSNAP: {
207 dtrace_bufdesc_t **pdesc = (dtrace_bufdesc_t **) addr;
208 dtrace_bufdesc_t desc;
210 dtrace_buffer_t *buf;
212 dtrace_debug_output();
214 if (copyin((void *) *pdesc, &desc, sizeof (desc)) != 0)
217 DTRACE_IOCTL_PRINTF("%s(%d): %s curcpu %d cpu %d\n",
219 cmd == DTRACEIOC_AGGSNAP ?
220 "DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP",
221 curcpu, desc.dtbd_cpu);
223 if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= NCPU)
225 if (pcpu_find(desc.dtbd_cpu) == NULL)
228 mutex_enter(&dtrace_lock);
230 if (cmd == DTRACEIOC_BUFSNAP) {
231 buf = &state->dts_buffer[desc.dtbd_cpu];
233 buf = &state->dts_aggbuffer[desc.dtbd_cpu];
236 if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) {
237 size_t sz = buf->dtb_offset;
239 if (state->dts_activity != DTRACE_ACTIVITY_STOPPED) {
240 mutex_exit(&dtrace_lock);
245 * If this buffer has already been consumed, we're
246 * going to indicate that there's nothing left here
249 if (buf->dtb_flags & DTRACEBUF_CONSUMED) {
250 mutex_exit(&dtrace_lock);
254 desc.dtbd_errors = 0;
255 desc.dtbd_oldest = 0;
258 if (copyout(&desc, (void *) *pdesc, sz) != 0)
265 * If this is a ring buffer that has wrapped, we want
266 * to copy the whole thing out.
268 if (buf->dtb_flags & DTRACEBUF_WRAPPED) {
269 dtrace_buffer_polish(buf);
273 if (copyout(buf->dtb_tomax, desc.dtbd_data, sz) != 0) {
274 mutex_exit(&dtrace_lock);
279 desc.dtbd_drops = buf->dtb_drops;
280 desc.dtbd_errors = buf->dtb_errors;
281 desc.dtbd_oldest = buf->dtb_xamot_offset;
282 desc.dtbd_timestamp = dtrace_gethrtime();
284 mutex_exit(&dtrace_lock);
286 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
289 buf->dtb_flags |= DTRACEBUF_CONSUMED;
294 if (buf->dtb_tomax == NULL) {
295 ASSERT(buf->dtb_xamot == NULL);
296 mutex_exit(&dtrace_lock);
300 cached = buf->dtb_tomax;
301 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
303 dtrace_xcall(desc.dtbd_cpu,
304 (dtrace_xcall_t)dtrace_buffer_switch, buf);
306 state->dts_errors += buf->dtb_xamot_errors;
309 * If the buffers did not actually switch, then the cross call
310 * did not take place -- presumably because the given CPU is
311 * not in the ready set. If this is the case, we'll return
314 if (buf->dtb_tomax == cached) {
315 ASSERT(buf->dtb_xamot != cached);
316 mutex_exit(&dtrace_lock);
320 ASSERT(cached == buf->dtb_xamot);
322 DTRACE_IOCTL_PRINTF("%s(%d): copyout the buffer snapshot\n",__func__,__LINE__);
325 * We have our snapshot; now copy it out.
327 if (copyout(buf->dtb_xamot, desc.dtbd_data,
328 buf->dtb_xamot_offset) != 0) {
329 mutex_exit(&dtrace_lock);
333 desc.dtbd_size = buf->dtb_xamot_offset;
334 desc.dtbd_drops = buf->dtb_xamot_drops;
335 desc.dtbd_errors = buf->dtb_xamot_errors;
336 desc.dtbd_oldest = 0;
337 desc.dtbd_timestamp = buf->dtb_switched;
339 mutex_exit(&dtrace_lock);
341 DTRACE_IOCTL_PRINTF("%s(%d): copyout buffer desc: size %zd drops %lu errors %lu\n",__func__,__LINE__,(size_t) desc.dtbd_size,(u_long) desc.dtbd_drops,(u_long) desc.dtbd_errors);
344 * Finally, copy out the buffer description.
346 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
351 case DTRACEIOC_CONF: {
354 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_CONF\n",__func__,__LINE__);
356 bzero(&conf, sizeof (conf));
357 conf.dtc_difversion = DIF_VERSION;
358 conf.dtc_difintregs = DIF_DIR_NREGS;
359 conf.dtc_diftupregs = DIF_DTR_NREGS;
360 conf.dtc_ctfmodel = CTF_MODEL_NATIVE;
362 *((dtrace_conf_t *) addr) = conf;
366 case DTRACEIOC_DOFGET: {
367 dof_hdr_t **pdof = (dof_hdr_t **) addr;
368 dof_hdr_t hdr, *dof = *pdof;
372 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_DOFGET\n",__func__,__LINE__);
374 if (copyin((void *)dof, &hdr, sizeof (hdr)) != 0)
377 mutex_enter(&dtrace_lock);
378 dof = dtrace_dof_create(state);
379 mutex_exit(&dtrace_lock);
381 len = MIN(hdr.dofh_loadsz, dof->dofh_loadsz);
382 rval = copyout(dof, (void *) *pdof, len);
383 dtrace_dof_destroy(dof);
385 return (rval == 0 ? 0 : EFAULT);
387 case DTRACEIOC_ENABLE: {
388 dof_hdr_t *dof = NULL;
389 dtrace_enabling_t *enab = NULL;
390 dtrace_vstate_t *vstate;
393 dtrace_enable_io_t *p = (dtrace_enable_io_t *) addr;
395 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_ENABLE\n",__func__,__LINE__);
398 * If a NULL argument has been passed, we take this as our
399 * cue to reevaluate our enablings.
401 if (p->dof == NULL) {
402 dtrace_enabling_matchall();
407 if ((dof = dtrace_dof_copyin((uintptr_t) p->dof, &rval)) == NULL)
410 mutex_enter(&cpu_lock);
411 mutex_enter(&dtrace_lock);
412 vstate = &state->dts_vstate;
414 if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) {
415 mutex_exit(&dtrace_lock);
416 mutex_exit(&cpu_lock);
417 dtrace_dof_destroy(dof);
421 if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) {
422 mutex_exit(&dtrace_lock);
423 mutex_exit(&cpu_lock);
424 dtrace_dof_destroy(dof);
428 if ((rval = dtrace_dof_options(dof, state)) != 0) {
429 dtrace_enabling_destroy(enab);
430 mutex_exit(&dtrace_lock);
431 mutex_exit(&cpu_lock);
432 dtrace_dof_destroy(dof);
436 if ((err = dtrace_enabling_match(enab, &p->n_matched)) == 0) {
437 err = dtrace_enabling_retain(enab);
439 dtrace_enabling_destroy(enab);
442 mutex_exit(&cpu_lock);
443 mutex_exit(&dtrace_lock);
444 dtrace_dof_destroy(dof);
448 case DTRACEIOC_EPROBE: {
449 dtrace_eprobedesc_t **pepdesc = (dtrace_eprobedesc_t **) addr;
450 dtrace_eprobedesc_t epdesc;
452 dtrace_action_t *act;
458 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_EPROBE\n",__func__,__LINE__);
460 if (copyin((void *)*pepdesc, &epdesc, sizeof (epdesc)) != 0)
463 mutex_enter(&dtrace_lock);
465 if ((ecb = dtrace_epid2ecb(state, epdesc.dtepd_epid)) == NULL) {
466 mutex_exit(&dtrace_lock);
470 if (ecb->dte_probe == NULL) {
471 mutex_exit(&dtrace_lock);
475 epdesc.dtepd_probeid = ecb->dte_probe->dtpr_id;
476 epdesc.dtepd_uarg = ecb->dte_uarg;
477 epdesc.dtepd_size = ecb->dte_size;
479 nrecs = epdesc.dtepd_nrecs;
480 epdesc.dtepd_nrecs = 0;
481 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
482 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
485 epdesc.dtepd_nrecs++;
489 * Now that we have the size, we need to allocate a temporary
490 * buffer in which to store the complete description. We need
491 * the temporary buffer to be able to drop dtrace_lock()
492 * across the copyout(), below.
494 size = sizeof (dtrace_eprobedesc_t) +
495 (epdesc.dtepd_nrecs * sizeof (dtrace_recdesc_t));
497 buf = kmem_alloc(size, KM_SLEEP);
498 dest = (uintptr_t)buf;
500 bcopy(&epdesc, (void *)dest, sizeof (epdesc));
501 dest += offsetof(dtrace_eprobedesc_t, dtepd_rec[0]);
503 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
504 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
510 bcopy(&act->dta_rec, (void *)dest,
511 sizeof (dtrace_recdesc_t));
512 dest += sizeof (dtrace_recdesc_t);
515 mutex_exit(&dtrace_lock);
517 if (copyout(buf, (void *) *pepdesc, dest - (uintptr_t)buf) != 0) {
518 kmem_free(buf, size);
522 kmem_free(buf, size);
525 case DTRACEIOC_FORMAT: {
526 dtrace_fmtdesc_t *fmt = (dtrace_fmtdesc_t *) addr;
530 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_FORMAT\n",__func__,__LINE__);
532 mutex_enter(&dtrace_lock);
534 if (fmt->dtfd_format == 0 ||
535 fmt->dtfd_format > state->dts_nformats) {
536 mutex_exit(&dtrace_lock);
541 * Format strings are allocated contiguously and they are
542 * never freed; if a format index is less than the number
543 * of formats, we can assert that the format map is non-NULL
544 * and that the format for the specified index is non-NULL.
546 ASSERT(state->dts_formats != NULL);
547 str = state->dts_formats[fmt->dtfd_format - 1];
550 len = strlen(str) + 1;
552 if (len > fmt->dtfd_length) {
553 fmt->dtfd_length = len;
555 if (copyout(str, fmt->dtfd_string, len) != 0) {
556 mutex_exit(&dtrace_lock);
561 mutex_exit(&dtrace_lock);
566 processorid_t *cpuid = (processorid_t *) addr;
568 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_GO\n",__func__,__LINE__);
570 rval = dtrace_state_go(state, cpuid);
574 case DTRACEIOC_PROBEARG: {
575 dtrace_argdesc_t *desc = (dtrace_argdesc_t *) addr;
576 dtrace_probe_t *probe;
577 dtrace_provider_t *prov;
579 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROBEARG\n",__func__,__LINE__);
581 if (desc->dtargd_id == DTRACE_IDNONE)
584 if (desc->dtargd_ndx == DTRACE_ARGNONE)
587 mutex_enter(&dtrace_provider_lock);
589 mutex_enter(&mod_lock);
591 mutex_enter(&dtrace_lock);
593 if (desc->dtargd_id > dtrace_nprobes) {
594 mutex_exit(&dtrace_lock);
596 mutex_exit(&mod_lock);
598 mutex_exit(&dtrace_provider_lock);
602 if ((probe = dtrace_probes[desc->dtargd_id - 1]) == NULL) {
603 mutex_exit(&dtrace_lock);
605 mutex_exit(&mod_lock);
607 mutex_exit(&dtrace_provider_lock);
611 mutex_exit(&dtrace_lock);
613 prov = probe->dtpr_provider;
615 if (prov->dtpv_pops.dtps_getargdesc == NULL) {
617 * There isn't any typed information for this probe.
618 * Set the argument number to DTRACE_ARGNONE.
620 desc->dtargd_ndx = DTRACE_ARGNONE;
622 desc->dtargd_native[0] = '\0';
623 desc->dtargd_xlate[0] = '\0';
624 desc->dtargd_mapping = desc->dtargd_ndx;
626 prov->dtpv_pops.dtps_getargdesc(prov->dtpv_arg,
627 probe->dtpr_id, probe->dtpr_arg, desc);
631 mutex_exit(&mod_lock);
633 mutex_exit(&dtrace_provider_lock);
637 case DTRACEIOC_PROBEMATCH:
638 case DTRACEIOC_PROBES: {
639 dtrace_probedesc_t *p_desc = (dtrace_probedesc_t *) addr;
640 dtrace_probe_t *probe = NULL;
641 dtrace_probekey_t pkey;
648 DTRACE_IOCTL_PRINTF("%s(%d): %s\n",__func__,__LINE__,
649 cmd == DTRACEIOC_PROBEMATCH ?
650 "DTRACEIOC_PROBEMATCH":"DTRACEIOC_PROBES");
652 p_desc->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
653 p_desc->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
654 p_desc->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
655 p_desc->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
658 * Before we attempt to match this probe, we want to give
659 * all providers the opportunity to provide it.
661 if (p_desc->dtpd_id == DTRACE_IDNONE) {
662 mutex_enter(&dtrace_provider_lock);
663 dtrace_probe_provide(p_desc, NULL);
664 mutex_exit(&dtrace_provider_lock);
668 if (cmd == DTRACEIOC_PROBEMATCH) {
669 dtrace_probekey(p_desc, &pkey);
670 pkey.dtpk_id = DTRACE_IDNONE;
673 dtrace_cred2priv(td->td_ucred, &priv, &uid, &zoneid);
675 mutex_enter(&dtrace_lock);
677 if (cmd == DTRACEIOC_PROBEMATCH) {
678 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
679 if ((probe = dtrace_probes[i - 1]) != NULL &&
680 (m = dtrace_match_probe(probe, &pkey,
681 priv, uid, zoneid)) != 0)
686 mutex_exit(&dtrace_lock);
691 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
692 if ((probe = dtrace_probes[i - 1]) != NULL &&
693 dtrace_match_priv(probe, priv, uid, zoneid))
699 mutex_exit(&dtrace_lock);
703 dtrace_probe_description(probe, p_desc);
704 mutex_exit(&dtrace_lock);
708 case DTRACEIOC_PROVIDER: {
709 dtrace_providerdesc_t *pvd = (dtrace_providerdesc_t *) addr;
710 dtrace_provider_t *pvp;
712 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROVIDER\n",__func__,__LINE__);
714 pvd->dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0';
715 mutex_enter(&dtrace_provider_lock);
717 for (pvp = dtrace_provider; pvp != NULL; pvp = pvp->dtpv_next) {
718 if (strcmp(pvp->dtpv_name, pvd->dtvd_name) == 0)
722 mutex_exit(&dtrace_provider_lock);
727 bcopy(&pvp->dtpv_priv, &pvd->dtvd_priv, sizeof (dtrace_ppriv_t));
728 bcopy(&pvp->dtpv_attr, &pvd->dtvd_attr, sizeof (dtrace_pattr_t));
732 case DTRACEIOC_REPLICATE: {
733 dtrace_repldesc_t *desc = (dtrace_repldesc_t *) addr;
734 dtrace_probedesc_t *match = &desc->dtrpd_match;
735 dtrace_probedesc_t *create = &desc->dtrpd_create;
738 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_REPLICATE\n",__func__,__LINE__);
740 match->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
741 match->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
742 match->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
743 match->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
745 create->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
746 create->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
747 create->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
748 create->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
750 mutex_enter(&dtrace_lock);
751 err = dtrace_enabling_replicate(state, match, create);
752 mutex_exit(&dtrace_lock);
756 case DTRACEIOC_STATUS: {
757 dtrace_status_t *stat = (dtrace_status_t *) addr;
758 dtrace_dstate_t *dstate;
762 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STATUS\n",__func__,__LINE__);
765 * See the comment in dtrace_state_deadman() for the reason
766 * for setting dts_laststatus to INT64_MAX before setting
767 * it to the correct value.
769 state->dts_laststatus = INT64_MAX;
770 dtrace_membar_producer();
771 state->dts_laststatus = dtrace_gethrtime();
773 bzero(stat, sizeof (*stat));
775 mutex_enter(&dtrace_lock);
777 if (state->dts_activity == DTRACE_ACTIVITY_INACTIVE) {
778 mutex_exit(&dtrace_lock);
782 if (state->dts_activity == DTRACE_ACTIVITY_DRAINING)
783 stat->dtst_exiting = 1;
785 nerrs = state->dts_errors;
786 dstate = &state->dts_vstate.dtvs_dynvars;
788 for (i = 0; i < NCPU; i++) {
790 if (pcpu_find(i) == NULL)
793 dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i];
795 stat->dtst_dyndrops += dcpu->dtdsc_drops;
796 stat->dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops;
797 stat->dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops;
799 if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL)
802 nerrs += state->dts_buffer[i].dtb_errors;
804 for (j = 0; j < state->dts_nspeculations; j++) {
805 dtrace_speculation_t *spec;
806 dtrace_buffer_t *buf;
808 spec = &state->dts_speculations[j];
809 buf = &spec->dtsp_buffer[i];
810 stat->dtst_specdrops += buf->dtb_xamot_drops;
814 stat->dtst_specdrops_busy = state->dts_speculations_busy;
815 stat->dtst_specdrops_unavail = state->dts_speculations_unavail;
816 stat->dtst_stkstroverflows = state->dts_stkstroverflows;
817 stat->dtst_dblerrors = state->dts_dblerrors;
819 (state->dts_activity == DTRACE_ACTIVITY_KILLED);
820 stat->dtst_errors = nerrs;
822 mutex_exit(&dtrace_lock);
826 case DTRACEIOC_STOP: {
828 processorid_t *cpuid = (processorid_t *) addr;
830 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STOP\n",__func__,__LINE__);
832 mutex_enter(&dtrace_lock);
833 rval = dtrace_state_stop(state, cpuid);
834 mutex_exit(&dtrace_lock);