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, &dtrace_verbose_ioctl, 0, "");
28 #define DTRACE_IOCTL_PRINTF(fmt, ...) if (dtrace_verbose_ioctl) printf(fmt, ## __VA_ARGS__ )
31 dtrace_ioctl_helper(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
35 dof_helper_t *dhp = NULL;
36 dof_hdr_t *dof = NULL;
39 case DTRACEHIOC_ADDDOF:
40 dhp = (dof_helper_t *)addr;
41 /* XXX all because dofhp_dof is 64 bit */
43 addr = (caddr_t)(uint32_t)dhp->dofhp_dof;
45 addr = (caddr_t)dhp->dofhp_dof;
49 dof = dtrace_dof_copyin((intptr_t)addr, &rval);
54 mutex_enter(&dtrace_lock);
55 if ((rval = dtrace_helper_slurp((dof_hdr_t *)dof, dhp)) != -1) {
58 copyout(dhp, addr, sizeof(*dhp));
64 mutex_exit(&dtrace_lock);
66 case DTRACEHIOC_REMOVE:
67 mutex_enter(&dtrace_lock);
68 rval = dtrace_helper_destroygen((int)*addr);
69 mutex_exit(&dtrace_lock);
81 dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr,
82 int flags __unused, struct thread *td)
84 #if __FreeBSD_version < 800039
85 dtrace_state_t *state = dev->si_drv1;
87 dtrace_state_t *state;
88 devfs_get_cdevpriv((void **) &state);
94 if (state->dts_anon) {
95 ASSERT(dtrace_anon.dta_state == NULL);
96 state = state->dts_anon;
100 case DTRACEIOC_AGGDESC: {
101 dtrace_aggdesc_t **paggdesc = (dtrace_aggdesc_t **) addr;
102 dtrace_aggdesc_t aggdesc;
103 dtrace_action_t *act;
104 dtrace_aggregation_t *agg;
107 dtrace_recdesc_t *lrec;
112 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_AGGDESC\n",__func__,__LINE__);
114 if (copyin((void *) *paggdesc, &aggdesc, sizeof (aggdesc)) != 0)
117 mutex_enter(&dtrace_lock);
119 if ((agg = dtrace_aggid2agg(state, aggdesc.dtagd_id)) == NULL) {
120 mutex_exit(&dtrace_lock);
124 aggdesc.dtagd_epid = agg->dtag_ecb->dte_epid;
126 nrecs = aggdesc.dtagd_nrecs;
127 aggdesc.dtagd_nrecs = 0;
129 offs = agg->dtag_base;
130 lrec = &agg->dtag_action.dta_rec;
131 aggdesc.dtagd_size = lrec->dtrd_offset + lrec->dtrd_size - offs;
133 for (act = agg->dtag_first; ; act = act->dta_next) {
134 ASSERT(act->dta_intuple ||
135 DTRACEACT_ISAGG(act->dta_kind));
138 * If this action has a record size of zero, it
139 * denotes an argument to the aggregating action.
140 * Because the presence of this record doesn't (or
141 * shouldn't) affect the way the data is interpreted,
142 * we don't copy it out to save user-level the
143 * confusion of dealing with a zero-length record.
145 if (act->dta_rec.dtrd_size == 0) {
146 ASSERT(agg->dtag_hasarg);
150 aggdesc.dtagd_nrecs++;
152 if (act == &agg->dtag_action)
157 * Now that we have the size, we need to allocate a temporary
158 * buffer in which to store the complete description. We need
159 * the temporary buffer to be able to drop dtrace_lock()
160 * across the copyout(), below.
162 size = sizeof (dtrace_aggdesc_t) +
163 (aggdesc.dtagd_nrecs * sizeof (dtrace_recdesc_t));
165 buf = kmem_alloc(size, KM_SLEEP);
166 dest = (uintptr_t)buf;
168 bcopy(&aggdesc, (void *)dest, sizeof (aggdesc));
169 dest += offsetof(dtrace_aggdesc_t, dtagd_rec[0]);
171 for (act = agg->dtag_first; ; act = act->dta_next) {
172 dtrace_recdesc_t rec = act->dta_rec;
175 * See the comment in the above loop for why we pass
176 * over zero-length records.
178 if (rec.dtrd_size == 0) {
179 ASSERT(agg->dtag_hasarg);
186 rec.dtrd_offset -= offs;
187 bcopy(&rec, (void *)dest, sizeof (rec));
188 dest += sizeof (dtrace_recdesc_t);
190 if (act == &agg->dtag_action)
194 mutex_exit(&dtrace_lock);
196 if (copyout(buf, (void *) *paggdesc, dest - (uintptr_t)buf) != 0) {
197 kmem_free(buf, size);
201 kmem_free(buf, size);
204 case DTRACEIOC_AGGSNAP:
205 case DTRACEIOC_BUFSNAP: {
206 dtrace_bufdesc_t **pdesc = (dtrace_bufdesc_t **) addr;
207 dtrace_bufdesc_t desc;
209 dtrace_buffer_t *buf;
211 dtrace_debug_output();
213 if (copyin((void *) *pdesc, &desc, sizeof (desc)) != 0)
216 DTRACE_IOCTL_PRINTF("%s(%d): %s curcpu %d cpu %d\n",
218 cmd == DTRACEIOC_AGGSNAP ?
219 "DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP",
220 curcpu, desc.dtbd_cpu);
222 if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= NCPU)
224 if (pcpu_find(desc.dtbd_cpu) == NULL)
227 mutex_enter(&dtrace_lock);
229 if (cmd == DTRACEIOC_BUFSNAP) {
230 buf = &state->dts_buffer[desc.dtbd_cpu];
232 buf = &state->dts_aggbuffer[desc.dtbd_cpu];
235 if (buf->dtb_flags & (DTRACEBUF_RING | DTRACEBUF_FILL)) {
236 size_t sz = buf->dtb_offset;
238 if (state->dts_activity != DTRACE_ACTIVITY_STOPPED) {
239 mutex_exit(&dtrace_lock);
244 * If this buffer has already been consumed, we're
245 * going to indicate that there's nothing left here
248 if (buf->dtb_flags & DTRACEBUF_CONSUMED) {
249 mutex_exit(&dtrace_lock);
253 desc.dtbd_errors = 0;
254 desc.dtbd_oldest = 0;
257 if (copyout(&desc, (void *) *pdesc, sz) != 0)
264 * If this is a ring buffer that has wrapped, we want
265 * to copy the whole thing out.
267 if (buf->dtb_flags & DTRACEBUF_WRAPPED) {
268 dtrace_buffer_polish(buf);
272 if (copyout(buf->dtb_tomax, desc.dtbd_data, sz) != 0) {
273 mutex_exit(&dtrace_lock);
278 desc.dtbd_drops = buf->dtb_drops;
279 desc.dtbd_errors = buf->dtb_errors;
280 desc.dtbd_oldest = buf->dtb_xamot_offset;
281 desc.dtbd_timestamp = dtrace_gethrtime();
283 mutex_exit(&dtrace_lock);
285 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
288 buf->dtb_flags |= DTRACEBUF_CONSUMED;
293 if (buf->dtb_tomax == NULL) {
294 ASSERT(buf->dtb_xamot == NULL);
295 mutex_exit(&dtrace_lock);
299 cached = buf->dtb_tomax;
300 ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
302 dtrace_xcall(desc.dtbd_cpu,
303 (dtrace_xcall_t)dtrace_buffer_switch, buf);
305 state->dts_errors += buf->dtb_xamot_errors;
308 * If the buffers did not actually switch, then the cross call
309 * did not take place -- presumably because the given CPU is
310 * not in the ready set. If this is the case, we'll return
313 if (buf->dtb_tomax == cached) {
314 ASSERT(buf->dtb_xamot != cached);
315 mutex_exit(&dtrace_lock);
319 ASSERT(cached == buf->dtb_xamot);
321 DTRACE_IOCTL_PRINTF("%s(%d): copyout the buffer snapshot\n",__func__,__LINE__);
324 * We have our snapshot; now copy it out.
326 if (copyout(buf->dtb_xamot, desc.dtbd_data,
327 buf->dtb_xamot_offset) != 0) {
328 mutex_exit(&dtrace_lock);
332 desc.dtbd_size = buf->dtb_xamot_offset;
333 desc.dtbd_drops = buf->dtb_xamot_drops;
334 desc.dtbd_errors = buf->dtb_xamot_errors;
335 desc.dtbd_oldest = 0;
336 desc.dtbd_timestamp = buf->dtb_switched;
338 mutex_exit(&dtrace_lock);
340 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);
343 * Finally, copy out the buffer description.
345 if (copyout(&desc, (void *) *pdesc, sizeof (desc)) != 0)
350 case DTRACEIOC_CONF: {
353 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_CONF\n",__func__,__LINE__);
355 bzero(&conf, sizeof (conf));
356 conf.dtc_difversion = DIF_VERSION;
357 conf.dtc_difintregs = DIF_DIR_NREGS;
358 conf.dtc_diftupregs = DIF_DTR_NREGS;
359 conf.dtc_ctfmodel = CTF_MODEL_NATIVE;
361 *((dtrace_conf_t *) addr) = conf;
365 case DTRACEIOC_DOFGET: {
366 dof_hdr_t **pdof = (dof_hdr_t **) addr;
367 dof_hdr_t hdr, *dof = *pdof;
371 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_DOFGET\n",__func__,__LINE__);
373 if (copyin((void *)dof, &hdr, sizeof (hdr)) != 0)
376 mutex_enter(&dtrace_lock);
377 dof = dtrace_dof_create(state);
378 mutex_exit(&dtrace_lock);
380 len = MIN(hdr.dofh_loadsz, dof->dofh_loadsz);
381 rval = copyout(dof, (void *) *pdof, len);
382 dtrace_dof_destroy(dof);
384 return (rval == 0 ? 0 : EFAULT);
386 case DTRACEIOC_ENABLE: {
387 dof_hdr_t *dof = NULL;
388 dtrace_enabling_t *enab = NULL;
389 dtrace_vstate_t *vstate;
392 dtrace_enable_io_t *p = (dtrace_enable_io_t *) addr;
394 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_ENABLE\n",__func__,__LINE__);
397 * If a NULL argument has been passed, we take this as our
398 * cue to reevaluate our enablings.
400 if (p->dof == NULL) {
401 dtrace_enabling_matchall();
406 if ((dof = dtrace_dof_copyin((uintptr_t) p->dof, &rval)) == NULL)
409 mutex_enter(&cpu_lock);
410 mutex_enter(&dtrace_lock);
411 vstate = &state->dts_vstate;
413 if (state->dts_activity != DTRACE_ACTIVITY_INACTIVE) {
414 mutex_exit(&dtrace_lock);
415 mutex_exit(&cpu_lock);
416 dtrace_dof_destroy(dof);
420 if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) {
421 mutex_exit(&dtrace_lock);
422 mutex_exit(&cpu_lock);
423 dtrace_dof_destroy(dof);
427 if ((rval = dtrace_dof_options(dof, state)) != 0) {
428 dtrace_enabling_destroy(enab);
429 mutex_exit(&dtrace_lock);
430 mutex_exit(&cpu_lock);
431 dtrace_dof_destroy(dof);
435 if ((err = dtrace_enabling_match(enab, &p->n_matched)) == 0) {
436 err = dtrace_enabling_retain(enab);
438 dtrace_enabling_destroy(enab);
441 mutex_exit(&cpu_lock);
442 mutex_exit(&dtrace_lock);
443 dtrace_dof_destroy(dof);
447 case DTRACEIOC_EPROBE: {
448 dtrace_eprobedesc_t **pepdesc = (dtrace_eprobedesc_t **) addr;
449 dtrace_eprobedesc_t epdesc;
451 dtrace_action_t *act;
457 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_EPROBE\n",__func__,__LINE__);
459 if (copyin((void *)*pepdesc, &epdesc, sizeof (epdesc)) != 0)
462 mutex_enter(&dtrace_lock);
464 if ((ecb = dtrace_epid2ecb(state, epdesc.dtepd_epid)) == NULL) {
465 mutex_exit(&dtrace_lock);
469 if (ecb->dte_probe == NULL) {
470 mutex_exit(&dtrace_lock);
474 epdesc.dtepd_probeid = ecb->dte_probe->dtpr_id;
475 epdesc.dtepd_uarg = ecb->dte_uarg;
476 epdesc.dtepd_size = ecb->dte_size;
478 nrecs = epdesc.dtepd_nrecs;
479 epdesc.dtepd_nrecs = 0;
480 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
481 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
484 epdesc.dtepd_nrecs++;
488 * Now that we have the size, we need to allocate a temporary
489 * buffer in which to store the complete description. We need
490 * the temporary buffer to be able to drop dtrace_lock()
491 * across the copyout(), below.
493 size = sizeof (dtrace_eprobedesc_t) +
494 (epdesc.dtepd_nrecs * sizeof (dtrace_recdesc_t));
496 buf = kmem_alloc(size, KM_SLEEP);
497 dest = (uintptr_t)buf;
499 bcopy(&epdesc, (void *)dest, sizeof (epdesc));
500 dest += offsetof(dtrace_eprobedesc_t, dtepd_rec[0]);
502 for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
503 if (DTRACEACT_ISAGG(act->dta_kind) || act->dta_intuple)
509 bcopy(&act->dta_rec, (void *)dest,
510 sizeof (dtrace_recdesc_t));
511 dest += sizeof (dtrace_recdesc_t);
514 mutex_exit(&dtrace_lock);
516 if (copyout(buf, (void *) *pepdesc, dest - (uintptr_t)buf) != 0) {
517 kmem_free(buf, size);
521 kmem_free(buf, size);
524 case DTRACEIOC_FORMAT: {
525 dtrace_fmtdesc_t *fmt = (dtrace_fmtdesc_t *) addr;
529 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_FORMAT\n",__func__,__LINE__);
531 mutex_enter(&dtrace_lock);
533 if (fmt->dtfd_format == 0 ||
534 fmt->dtfd_format > state->dts_nformats) {
535 mutex_exit(&dtrace_lock);
540 * Format strings are allocated contiguously and they are
541 * never freed; if a format index is less than the number
542 * of formats, we can assert that the format map is non-NULL
543 * and that the format for the specified index is non-NULL.
545 ASSERT(state->dts_formats != NULL);
546 str = state->dts_formats[fmt->dtfd_format - 1];
549 len = strlen(str) + 1;
551 if (len > fmt->dtfd_length) {
552 fmt->dtfd_length = len;
554 if (copyout(str, fmt->dtfd_string, len) != 0) {
555 mutex_exit(&dtrace_lock);
560 mutex_exit(&dtrace_lock);
565 processorid_t *cpuid = (processorid_t *) addr;
567 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_GO\n",__func__,__LINE__);
569 rval = dtrace_state_go(state, cpuid);
573 case DTRACEIOC_PROBEARG: {
574 dtrace_argdesc_t *desc = (dtrace_argdesc_t *) addr;
575 dtrace_probe_t *probe;
576 dtrace_provider_t *prov;
578 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROBEARG\n",__func__,__LINE__);
580 if (desc->dtargd_id == DTRACE_IDNONE)
583 if (desc->dtargd_ndx == DTRACE_ARGNONE)
586 mutex_enter(&dtrace_provider_lock);
587 mutex_enter(&mod_lock);
588 mutex_enter(&dtrace_lock);
590 if (desc->dtargd_id > dtrace_nprobes) {
591 mutex_exit(&dtrace_lock);
592 mutex_exit(&mod_lock);
593 mutex_exit(&dtrace_provider_lock);
597 if ((probe = dtrace_probes[desc->dtargd_id - 1]) == NULL) {
598 mutex_exit(&dtrace_lock);
599 mutex_exit(&mod_lock);
600 mutex_exit(&dtrace_provider_lock);
604 mutex_exit(&dtrace_lock);
606 prov = probe->dtpr_provider;
608 if (prov->dtpv_pops.dtps_getargdesc == NULL) {
610 * There isn't any typed information for this probe.
611 * Set the argument number to DTRACE_ARGNONE.
613 desc->dtargd_ndx = DTRACE_ARGNONE;
615 desc->dtargd_native[0] = '\0';
616 desc->dtargd_xlate[0] = '\0';
617 desc->dtargd_mapping = desc->dtargd_ndx;
619 prov->dtpv_pops.dtps_getargdesc(prov->dtpv_arg,
620 probe->dtpr_id, probe->dtpr_arg, desc);
623 mutex_exit(&mod_lock);
624 mutex_exit(&dtrace_provider_lock);
628 case DTRACEIOC_PROBEMATCH:
629 case DTRACEIOC_PROBES: {
630 dtrace_probedesc_t *p_desc = (dtrace_probedesc_t *) addr;
631 dtrace_probe_t *probe = NULL;
632 dtrace_probekey_t pkey;
639 DTRACE_IOCTL_PRINTF("%s(%d): %s\n",__func__,__LINE__,
640 cmd == DTRACEIOC_PROBEMATCH ?
641 "DTRACEIOC_PROBEMATCH":"DTRACEIOC_PROBES");
643 p_desc->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
644 p_desc->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
645 p_desc->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
646 p_desc->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
649 * Before we attempt to match this probe, we want to give
650 * all providers the opportunity to provide it.
652 if (p_desc->dtpd_id == DTRACE_IDNONE) {
653 mutex_enter(&dtrace_provider_lock);
654 dtrace_probe_provide(p_desc, NULL);
655 mutex_exit(&dtrace_provider_lock);
659 if (cmd == DTRACEIOC_PROBEMATCH) {
660 dtrace_probekey(p_desc, &pkey);
661 pkey.dtpk_id = DTRACE_IDNONE;
664 dtrace_cred2priv(td->td_ucred, &priv, &uid, &zoneid);
666 mutex_enter(&dtrace_lock);
668 if (cmd == DTRACEIOC_PROBEMATCH) {
669 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
670 if ((probe = dtrace_probes[i - 1]) != NULL &&
671 (m = dtrace_match_probe(probe, &pkey,
672 priv, uid, zoneid)) != 0)
677 mutex_exit(&dtrace_lock);
682 for (i = p_desc->dtpd_id; i <= dtrace_nprobes; i++) {
683 if ((probe = dtrace_probes[i - 1]) != NULL &&
684 dtrace_match_priv(probe, priv, uid, zoneid))
690 mutex_exit(&dtrace_lock);
694 dtrace_probe_description(probe, p_desc);
695 mutex_exit(&dtrace_lock);
699 case DTRACEIOC_PROVIDER: {
700 dtrace_providerdesc_t *pvd = (dtrace_providerdesc_t *) addr;
701 dtrace_provider_t *pvp;
703 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_PROVIDER\n",__func__,__LINE__);
705 pvd->dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0';
706 mutex_enter(&dtrace_provider_lock);
708 for (pvp = dtrace_provider; pvp != NULL; pvp = pvp->dtpv_next) {
709 if (strcmp(pvp->dtpv_name, pvd->dtvd_name) == 0)
713 mutex_exit(&dtrace_provider_lock);
718 bcopy(&pvp->dtpv_priv, &pvd->dtvd_priv, sizeof (dtrace_ppriv_t));
719 bcopy(&pvp->dtpv_attr, &pvd->dtvd_attr, sizeof (dtrace_pattr_t));
723 case DTRACEIOC_REPLICATE: {
724 dtrace_repldesc_t *desc = (dtrace_repldesc_t *) addr;
725 dtrace_probedesc_t *match = &desc->dtrpd_match;
726 dtrace_probedesc_t *create = &desc->dtrpd_create;
729 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_REPLICATE\n",__func__,__LINE__);
731 match->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
732 match->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
733 match->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
734 match->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
736 create->dtpd_provider[DTRACE_PROVNAMELEN - 1] = '\0';
737 create->dtpd_mod[DTRACE_MODNAMELEN - 1] = '\0';
738 create->dtpd_func[DTRACE_FUNCNAMELEN - 1] = '\0';
739 create->dtpd_name[DTRACE_NAMELEN - 1] = '\0';
741 mutex_enter(&dtrace_lock);
742 err = dtrace_enabling_replicate(state, match, create);
743 mutex_exit(&dtrace_lock);
747 case DTRACEIOC_STATUS: {
748 dtrace_status_t *stat = (dtrace_status_t *) addr;
749 dtrace_dstate_t *dstate;
753 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STATUS\n",__func__,__LINE__);
756 * See the comment in dtrace_state_deadman() for the reason
757 * for setting dts_laststatus to INT64_MAX before setting
758 * it to the correct value.
760 state->dts_laststatus = INT64_MAX;
761 dtrace_membar_producer();
762 state->dts_laststatus = dtrace_gethrtime();
764 bzero(stat, sizeof (*stat));
766 mutex_enter(&dtrace_lock);
768 if (state->dts_activity == DTRACE_ACTIVITY_INACTIVE) {
769 mutex_exit(&dtrace_lock);
773 if (state->dts_activity == DTRACE_ACTIVITY_DRAINING)
774 stat->dtst_exiting = 1;
776 nerrs = state->dts_errors;
777 dstate = &state->dts_vstate.dtvs_dynvars;
779 for (i = 0; i < NCPU; i++) {
781 if (pcpu_find(i) == NULL)
784 dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i];
786 stat->dtst_dyndrops += dcpu->dtdsc_drops;
787 stat->dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops;
788 stat->dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops;
790 if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL)
793 nerrs += state->dts_buffer[i].dtb_errors;
795 for (j = 0; j < state->dts_nspeculations; j++) {
796 dtrace_speculation_t *spec;
797 dtrace_buffer_t *buf;
799 spec = &state->dts_speculations[j];
800 buf = &spec->dtsp_buffer[i];
801 stat->dtst_specdrops += buf->dtb_xamot_drops;
805 stat->dtst_specdrops_busy = state->dts_speculations_busy;
806 stat->dtst_specdrops_unavail = state->dts_speculations_unavail;
807 stat->dtst_stkstroverflows = state->dts_stkstroverflows;
808 stat->dtst_dblerrors = state->dts_dblerrors;
810 (state->dts_activity == DTRACE_ACTIVITY_KILLED);
811 stat->dtst_errors = nerrs;
813 mutex_exit(&dtrace_lock);
817 case DTRACEIOC_STOP: {
819 processorid_t *cpuid = (processorid_t *) addr;
821 DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STOP\n",__func__,__LINE__);
823 mutex_enter(&dtrace_lock);
824 rval = dtrace_state_stop(state, cpuid);
825 mutex_exit(&dtrace_lock);