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 */
43 addr = (caddr_t)(vm_offset_t)dhp->dofhp_dof;
46 dof = dtrace_dof_copyin((intptr_t)addr, &rval);
51 mutex_enter(&dtrace_lock);
52 if ((rval = dtrace_helper_slurp((dof_hdr_t *)dof, dhp)) != -1) {
55 copyout(dhp, addr, sizeof(*dhp));
61 mutex_exit(&dtrace_lock);
63 case DTRACEHIOC_REMOVE:
64 mutex_enter(&dtrace_lock);
65 rval = dtrace_helper_destroygen((int)*addr);
66 mutex_exit(&dtrace_lock);
78 dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
79 int flags __unused, struct thread *td)
81 #if __FreeBSD_version < 800039
82 dtrace_state_t *state = dev->si_drv1;
84 dtrace_state_t *state;
85 devfs_get_cdevpriv((void **) &state);
91 if (state->dts_anon) {
92 ASSERT(dtrace_anon.dta_state == NULL);
93 state = state->dts_anon;
97 case DTRACEIOC_AGGDESC: {
98 dtrace_aggdesc_t **paggdesc = (dtrace_aggdesc_t **) addr;
99 dtrace_aggdesc_t aggdesc;
100 dtrace_action_t *act;
101 dtrace_aggregation_t *agg;
104 dtrace_recdesc_t *lrec;
109 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_AGGDESC\n",__func__,__LINE__);
111 if (copyin((void *) *paggdesc, &aggdesc, sizeof (aggdesc)) != 0)
114 mutex_enter(&dtrace_lock);
116 if ((agg = dtrace_aggid2agg(state, aggdesc.dtagd_id)) == NULL) {
117 mutex_exit(&dtrace_lock);
121 aggdesc.dtagd_epid = agg->dtag_ecb->dte_epid;
123 nrecs = aggdesc.dtagd_nrecs;
124 aggdesc.dtagd_nrecs = 0;
126 offs = agg->dtag_base;
127 lrec = &agg->dtag_action.dta_rec;
128 aggdesc.dtagd_size = lrec->dtrd_offset + lrec->dtrd_size - offs;
130 for (act = agg->dtag_first; ; act = act->dta_next) {
131 ASSERT(act->dta_intuple ||
132 DTRACEACT_ISAGG(act->dta_kind));
135 * If this action has a record size of zero, it
136 * denotes an argument to the aggregating action.
137 * Because the presence of this record doesn't (or
138 * shouldn't) affect the way the data is interpreted,
139 * we don't copy it out to save user-level the
140 * confusion of dealing with a zero-length record.
142 if (act->dta_rec.dtrd_size == 0) {
143 ASSERT(agg->dtag_hasarg);
147 aggdesc.dtagd_nrecs++;
149 if (act == &agg->dtag_action)
154 * Now that we have the size, we need to allocate a temporary
155 * buffer in which to store the complete description. We need
156 * the temporary buffer to be able to drop dtrace_lock()
157 * across the copyout(), below.
159 size = sizeof (dtrace_aggdesc_t) +
160 (aggdesc.dtagd_nrecs * sizeof (dtrace_recdesc_t));
162 buf = kmem_alloc(size, KM_SLEEP);
163 dest = (uintptr_t)buf;
165 bcopy(&aggdesc, (void *)dest, sizeof (aggdesc));
166 dest += offsetof(dtrace_aggdesc_t, dtagd_rec[0]);
168 for (act = agg->dtag_first; ; act = act->dta_next) {
169 dtrace_recdesc_t rec = act->dta_rec;
172 * See the comment in the above loop for why we pass
173 * over zero-length records.
175 if (rec.dtrd_size == 0) {
176 ASSERT(agg->dtag_hasarg);
183 rec.dtrd_offset -= offs;
184 bcopy(&rec, (void *)dest, sizeof (rec));
185 dest += sizeof (dtrace_recdesc_t);
187 if (act == &agg->dtag_action)
191 mutex_exit(&dtrace_lock);
193 if (copyout(buf, (void *) *paggdesc, dest - (uintptr_t)buf) != 0) {
194 kmem_free(buf, size);
198 kmem_free(buf, size);
201 case DTRACEIOC_AGGSNAP:
202 case DTRACEIOC_BUFSNAP: {
203 dtrace_bufdesc_t **pdesc = (dtrace_bufdesc_t **) addr;
204 dtrace_bufdesc_t desc;
206 dtrace_buffer_t *buf;
208 dtrace_debug_output();
210 if (copyin((void *) *pdesc, &desc, sizeof (desc)) != 0)
213 DTRACE_IOCTL_PRINTF("%s(%d): %s curcpu %d cpu %d\n",
215 cmd == DTRACEIOC_AGGSNAP ?
216 "DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP",
217 curcpu, desc.dtbd_cpu);
219 if (desc.dtbd_cpu >= NCPU)
221 if (pcpu_find(desc.dtbd_cpu) == NULL)
224 mutex_enter(&dtrace_lock);
226 if (cmd == DTRACEIOC_BUFSNAP) {
227 buf = &state->dts_buffer[desc.dtbd_cpu];
229 buf = &state->dts_aggbuffer[desc.dtbd_cpu];
232 if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) {
233 size_t sz = buf->dtb_offset;
235 if (state->dts_activity != DTRACE_ACTIVITY_STOPPED) {
236 mutex_exit(&dtrace_lock);
241 * If this buffer has already been consumed, we're
242 * going to indicate that there's nothing left here
245 if (buf->dtb_flags & DTRACEBUF_CONSUMED) {
246 mutex_exit(&dtrace_lock);
250 desc.dtbd_errors = 0;
251 desc.dtbd_oldest = 0;
254 if (copyout(&desc, (void *) *pdesc, sz) != 0)
261 * If this is a ring buffer that has wrapped, we want
262 * to copy the whole thing out.
264 if (buf->dtb_flags & DTRACEBUF_WRAPPED) {
265 dtrace_buffer_polish(buf);
269 if (copyout(buf->dtb_tomax, desc.dtbd_data, sz) != 0) {
270 mutex_exit(&dtrace_lock);
275 desc.dtbd_drops = buf->dtb_drops;
276 desc.dtbd_errors = buf->dtb_errors;
277 desc.dtbd_oldest = buf->dtb_xamot_offset;
278 desc.dtbd_timestamp = dtrace_gethrtime();
280 mutex_exit(&dtrace_lock);
282 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
285 buf->dtb_flags |= DTRACEBUF_CONSUMED;
290 if (buf->dtb_tomax == NULL) {
291 ASSERT(buf->dtb_xamot == NULL);
292 mutex_exit(&dtrace_lock);
296 cached = buf->dtb_tomax;
297 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
299 dtrace_xcall(desc.dtbd_cpu,
300 (dtrace_xcall_t)dtrace_buffer_switch, buf);
302 state->dts_errors += buf->dtb_xamot_errors;
305 * If the buffers did not actually switch, then the cross call
306 * did not take place -- presumably because the given CPU is
307 * not in the ready set. If this is the case, we'll return
310 if (buf->dtb_tomax == cached) {
311 ASSERT(buf->dtb_xamot != cached);
312 mutex_exit(&dtrace_lock);
316 ASSERT(cached == buf->dtb_xamot);
318 DTRACE_IOCTL_PRINTF("%s(%d): copyout the buffer snapshot\n",__func__,__LINE__);
321 * We have our snapshot; now copy it out.
323 if (copyout(buf->dtb_xamot, desc.dtbd_data,
324 buf->dtb_xamot_offset) != 0) {
325 mutex_exit(&dtrace_lock);
329 desc.dtbd_size = buf->dtb_xamot_offset;
330 desc.dtbd_drops = buf->dtb_xamot_drops;
331 desc.dtbd_errors = buf->dtb_xamot_errors;
332 desc.dtbd_oldest = 0;
333 desc.dtbd_timestamp = buf->dtb_switched;
335 mutex_exit(&dtrace_lock);
337 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);
340 * Finally, copy out the buffer description.
342 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
347 case DTRACEIOC_CONF: {
350 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_CONF\n",__func__,__LINE__);
352 bzero(&conf, sizeof (conf));
353 conf.dtc_difversion = DIF_VERSION;
354 conf.dtc_difintregs = DIF_DIR_NREGS;
355 conf.dtc_diftupregs = DIF_DTR_NREGS;
356 conf.dtc_ctfmodel = CTF_MODEL_NATIVE;
358 *((dtrace_conf_t *) addr) = conf;
362 case DTRACEIOC_DOFGET: {
363 dof_hdr_t **pdof = (dof_hdr_t **) addr;
364 dof_hdr_t hdr, *dof = *pdof;
368 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_DOFGET\n",__func__,__LINE__);
370 if (copyin((void *)dof, &hdr, sizeof (hdr)) != 0)
373 mutex_enter(&dtrace_lock);
374 dof = dtrace_dof_create(state);
375 mutex_exit(&dtrace_lock);
377 len = MIN(hdr.dofh_loadsz, dof->dofh_loadsz);
378 rval = copyout(dof, (void *) *pdof, len);
379 dtrace_dof_destroy(dof);
381 return (rval == 0 ? 0 : EFAULT);
383 case DTRACEIOC_ENABLE: {
384 dof_hdr_t *dof = NULL;
385 dtrace_enabling_t *enab = NULL;
386 dtrace_vstate_t *vstate;
389 dtrace_enable_io_t *p = (dtrace_enable_io_t *) addr;
391 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_ENABLE\n",__func__,__LINE__);
394 * If a NULL argument has been passed, we take this as our
395 * cue to reevaluate our enablings.
397 if (p->dof == NULL) {
398 dtrace_enabling_matchall();
403 if ((dof = dtrace_dof_copyin((uintptr_t) p->dof, &rval)) == NULL)
406 mutex_enter(&cpu_lock);
407 mutex_enter(&dtrace_lock);
408 vstate = &state->dts_vstate;
410 if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) {
411 mutex_exit(&dtrace_lock);
412 mutex_exit(&cpu_lock);
413 dtrace_dof_destroy(dof);
417 if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) {
418 mutex_exit(&dtrace_lock);
419 mutex_exit(&cpu_lock);
420 dtrace_dof_destroy(dof);
424 if ((rval = dtrace_dof_options(dof, state)) != 0) {
425 dtrace_enabling_destroy(enab);
426 mutex_exit(&dtrace_lock);
427 mutex_exit(&cpu_lock);
428 dtrace_dof_destroy(dof);
432 if ((err = dtrace_enabling_match(enab, &p->n_matched)) == 0) {
433 err = dtrace_enabling_retain(enab);
435 dtrace_enabling_destroy(enab);
438 mutex_exit(&cpu_lock);
439 mutex_exit(&dtrace_lock);
440 dtrace_dof_destroy(dof);
444 case DTRACEIOC_EPROBE: {
445 dtrace_eprobedesc_t **pepdesc = (dtrace_eprobedesc_t **) addr;
446 dtrace_eprobedesc_t epdesc;
448 dtrace_action_t *act;
454 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_EPROBE\n",__func__,__LINE__);
456 if (copyin((void *)*pepdesc, &epdesc, sizeof (epdesc)) != 0)
459 mutex_enter(&dtrace_lock);
461 if ((ecb = dtrace_epid2ecb(state, epdesc.dtepd_epid)) == NULL) {
462 mutex_exit(&dtrace_lock);
466 if (ecb->dte_probe == NULL) {
467 mutex_exit(&dtrace_lock);
471 epdesc.dtepd_probeid = ecb->dte_probe->dtpr_id;
472 epdesc.dtepd_uarg = ecb->dte_uarg;
473 epdesc.dtepd_size = ecb->dte_size;
475 nrecs = epdesc.dtepd_nrecs;
476 epdesc.dtepd_nrecs = 0;
477 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
478 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
481 epdesc.dtepd_nrecs++;
485 * Now that we have the size, we need to allocate a temporary
486 * buffer in which to store the complete description. We need
487 * the temporary buffer to be able to drop dtrace_lock()
488 * across the copyout(), below.
490 size = sizeof (dtrace_eprobedesc_t) +
491 (epdesc.dtepd_nrecs * sizeof (dtrace_recdesc_t));
493 buf = kmem_alloc(size, KM_SLEEP);
494 dest = (uintptr_t)buf;
496 bcopy(&epdesc, (void *)dest, sizeof (epdesc));
497 dest += offsetof(dtrace_eprobedesc_t, dtepd_rec[0]);
499 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
500 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
506 bcopy(&act->dta_rec, (void *)dest,
507 sizeof (dtrace_recdesc_t));
508 dest += sizeof (dtrace_recdesc_t);
511 mutex_exit(&dtrace_lock);
513 if (copyout(buf, (void *) *pepdesc, dest - (uintptr_t)buf) != 0) {
514 kmem_free(buf, size);
518 kmem_free(buf, size);
521 case DTRACEIOC_FORMAT: {
522 dtrace_fmtdesc_t *fmt = (dtrace_fmtdesc_t *) addr;
526 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_FORMAT\n",__func__,__LINE__);
528 mutex_enter(&dtrace_lock);
530 if (fmt->dtfd_format == 0 ||
531 fmt->dtfd_format > state->dts_nformats) {
532 mutex_exit(&dtrace_lock);
537 * Format strings are allocated contiguously and they are
538 * never freed; if a format index is less than the number
539 * of formats, we can assert that the format map is non-NULL
540 * and that the format for the specified index is non-NULL.
542 ASSERT(state->dts_formats != NULL);
543 str = state->dts_formats[fmt->dtfd_format - 1];
546 len = strlen(str) + 1;
548 if (len > fmt->dtfd_length) {
549 fmt->dtfd_length = len;
551 if (copyout(str, fmt->dtfd_string, len) != 0) {
552 mutex_exit(&dtrace_lock);
557 mutex_exit(&dtrace_lock);
562 processorid_t *cpuid = (processorid_t *) addr;
564 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_GO\n",__func__,__LINE__);
566 rval = dtrace_state_go(state, cpuid);
570 case DTRACEIOC_PROBEARG: {
571 dtrace_argdesc_t *desc = (dtrace_argdesc_t *) addr;
572 dtrace_probe_t *probe;
573 dtrace_provider_t *prov;
575 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROBEARG\n",__func__,__LINE__);
577 if (desc->dtargd_id == DTRACE_IDNONE)
580 if (desc->dtargd_ndx == DTRACE_ARGNONE)
583 mutex_enter(&dtrace_provider_lock);
585 mutex_enter(&mod_lock);
587 mutex_enter(&dtrace_lock);
589 if (desc->dtargd_id > dtrace_nprobes) {
590 mutex_exit(&dtrace_lock);
592 mutex_exit(&mod_lock);
594 mutex_exit(&dtrace_provider_lock);
598 if ((probe = dtrace_probes[desc->dtargd_id - 1]) == NULL) {
599 mutex_exit(&dtrace_lock);
601 mutex_exit(&mod_lock);
603 mutex_exit(&dtrace_provider_lock);
607 mutex_exit(&dtrace_lock);
609 prov = probe->dtpr_provider;
611 if (prov->dtpv_pops.dtps_getargdesc == NULL) {
613 * There isn't any typed information for this probe.
614 * Set the argument number to DTRACE_ARGNONE.
616 desc->dtargd_ndx = DTRACE_ARGNONE;
618 desc->dtargd_native[0] = '\0';
619 desc->dtargd_xlate[0] = '\0';
620 desc->dtargd_mapping = desc->dtargd_ndx;
622 prov->dtpv_pops.dtps_getargdesc(prov->dtpv_arg,
623 probe->dtpr_id, probe->dtpr_arg, desc);
627 mutex_exit(&mod_lock);
629 mutex_exit(&dtrace_provider_lock);
633 case DTRACEIOC_PROBEMATCH:
634 case DTRACEIOC_PROBES: {
635 dtrace_probedesc_t *p_desc = (dtrace_probedesc_t *) addr;
636 dtrace_probe_t *probe = NULL;
637 dtrace_probekey_t pkey;
644 DTRACE_IOCTL_PRINTF("%s(%d): %s\n",__func__,__LINE__,
645 cmd == DTRACEIOC_PROBEMATCH ?
646 "DTRACEIOC_PROBEMATCH":"DTRACEIOC_PROBES");
648 p_desc->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
649 p_desc->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
650 p_desc->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
651 p_desc->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
654 * Before we attempt to match this probe, we want to give
655 * all providers the opportunity to provide it.
657 if (p_desc->dtpd_id == DTRACE_IDNONE) {
658 mutex_enter(&dtrace_provider_lock);
659 dtrace_probe_provide(p_desc, NULL);
660 mutex_exit(&dtrace_provider_lock);
664 if (cmd == DTRACEIOC_PROBEMATCH) {
665 dtrace_probekey(p_desc, &pkey);
666 pkey.dtpk_id = DTRACE_IDNONE;
669 dtrace_cred2priv(td->td_ucred, &priv, &uid, &zoneid);
671 mutex_enter(&dtrace_lock);
673 if (cmd == DTRACEIOC_PROBEMATCH) {
674 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
675 if ((probe = dtrace_probes[i - 1]) != NULL &&
676 (m = dtrace_match_probe(probe, &pkey,
677 priv, uid, zoneid)) != 0)
682 mutex_exit(&dtrace_lock);
687 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
688 if ((probe = dtrace_probes[i - 1]) != NULL &&
689 dtrace_match_priv(probe, priv, uid, zoneid))
695 mutex_exit(&dtrace_lock);
699 dtrace_probe_description(probe, p_desc);
700 mutex_exit(&dtrace_lock);
704 case DTRACEIOC_PROVIDER: {
705 dtrace_providerdesc_t *pvd = (dtrace_providerdesc_t *) addr;
706 dtrace_provider_t *pvp;
708 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROVIDER\n",__func__,__LINE__);
710 pvd->dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0';
711 mutex_enter(&dtrace_provider_lock);
713 for (pvp = dtrace_provider; pvp != NULL; pvp = pvp->dtpv_next) {
714 if (strcmp(pvp->dtpv_name, pvd->dtvd_name) == 0)
718 mutex_exit(&dtrace_provider_lock);
723 bcopy(&pvp->dtpv_priv, &pvd->dtvd_priv, sizeof (dtrace_ppriv_t));
724 bcopy(&pvp->dtpv_attr, &pvd->dtvd_attr, sizeof (dtrace_pattr_t));
728 case DTRACEIOC_REPLICATE: {
729 dtrace_repldesc_t *desc = (dtrace_repldesc_t *) addr;
730 dtrace_probedesc_t *match = &desc->dtrpd_match;
731 dtrace_probedesc_t *create = &desc->dtrpd_create;
734 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_REPLICATE\n",__func__,__LINE__);
736 match->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
737 match->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
738 match->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
739 match->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
741 create->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
742 create->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
743 create->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
744 create->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
746 mutex_enter(&dtrace_lock);
747 err = dtrace_enabling_replicate(state, match, create);
748 mutex_exit(&dtrace_lock);
752 case DTRACEIOC_STATUS: {
753 dtrace_status_t *stat = (dtrace_status_t *) addr;
754 dtrace_dstate_t *dstate;
758 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STATUS\n",__func__,__LINE__);
761 * See the comment in dtrace_state_deadman() for the reason
762 * for setting dts_laststatus to INT64_MAX before setting
763 * it to the correct value.
765 state->dts_laststatus = INT64_MAX;
766 dtrace_membar_producer();
767 state->dts_laststatus = dtrace_gethrtime();
769 bzero(stat, sizeof (*stat));
771 mutex_enter(&dtrace_lock);
773 if (state->dts_activity == DTRACE_ACTIVITY_INACTIVE) {
774 mutex_exit(&dtrace_lock);
778 if (state->dts_activity == DTRACE_ACTIVITY_DRAINING)
779 stat->dtst_exiting = 1;
781 nerrs = state->dts_errors;
782 dstate = &state->dts_vstate.dtvs_dynvars;
784 for (i = 0; i < NCPU; i++) {
786 if (pcpu_find(i) == NULL)
789 dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i];
791 stat->dtst_dyndrops += dcpu->dtdsc_drops;
792 stat->dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops;
793 stat->dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops;
795 if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL)
798 nerrs += state->dts_buffer[i].dtb_errors;
800 for (j = 0; j < state->dts_nspeculations; j++) {
801 dtrace_speculation_t *spec;
802 dtrace_buffer_t *buf;
804 spec = &state->dts_speculations[j];
805 buf = &spec->dtsp_buffer[i];
806 stat->dtst_specdrops += buf->dtb_xamot_drops;
810 stat->dtst_specdrops_busy = state->dts_speculations_busy;
811 stat->dtst_specdrops_unavail = state->dts_speculations_unavail;
812 stat->dtst_stkstroverflows = state->dts_stkstroverflows;
813 stat->dtst_dblerrors = state->dts_dblerrors;
815 (state->dts_activity == DTRACE_ACTIVITY_KILLED);
816 stat->dtst_errors = nerrs;
818 mutex_exit(&dtrace_lock);
822 case DTRACEIOC_STOP: {
824 processorid_t *cpuid = (processorid_t *) addr;
826 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STOP\n",__func__,__LINE__);
828 mutex_enter(&dtrace_lock);
829 rval = dtrace_state_stop(state, cpuid);
830 mutex_exit(&dtrace_lock);