14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License, Version 1.0 only
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (the "License"). You may not use this file except in compliance
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma ident "%Z%%M% %I% %E% SMI"
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync#else /* VBOX */
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync//# include <stddef.h>
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync//# include <time.h>
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync#endif /* VBOX */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic const struct {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync { DTRACEOPT_STATUSRATE, offsetof(dtrace_hdl_t, dt_laststatus) },
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync { DTRACEOPT_AGGRATE, offsetof(dtrace_hdl_t, dt_lastagg) },
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync { DTRACEOPT_SWITCHRATE, offsetof(dtrace_hdl_t, dt_lastswitch) },
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_optval_t policy = dtp->dt_options[DTRACEOPT_BUFPOLICY];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync for (i = 0; _dtrace_sleeptab[i].dtslt_option < DTRACEOPT_MAX; i++) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uintptr_t a = (uintptr_t)dtp + _dtrace_sleeptab[i].dtslt_offs;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If the buffering policy is set to anything other than
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * "switch", we ignore the aggrate and switchrate -- they're
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * meaningless.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync _dtrace_sleeptab[i].dtslt_option != DTRACEOPT_STATUSRATE)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return; /* sleep duration has already past */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Wait for either 'tv' nanoseconds to pass or to receive notification
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * that a process is in an interesting state. Regardless of why we
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * awaken, iterate over any pending notifications and process them.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (void) pthread_cond_reltimedwait_np(&dph->dph_cv, &dph->dph_lock, &tv);
e3de7948c4ce365719e80faad164a0fad245bbbbvboxsync RTSemEventWait(dph->dph_event, (earliest - now) / RT_NS_1MS);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_optval_t interval = dtp->dt_options[DTRACEOPT_STATUSRATE];
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync if (now - dtp->dt_laststatus < VBDTCAST(hrtime_t)interval)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_ioctl(dtp, DTRACEIOC_STATUS, &dtp->dt_status[gen]) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_handle_status(dtp, &dtp->dt_status[dtp->dt_statusgen],
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtp->dt_options[DTRACEOPT_BUFPOLICY] != DTRACEOPT_BUFPOLICY_FILL)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If a dtrace:::ERROR program and callback are registered, enable the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * program before we start tracing. If this fails for a vector open
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * with ENOTTY, we permit dtrace_go() to succeed so that vector clients
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * such as mdb's dtrace module can execute the rest of dtrace_go() even
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * though they do not provide support for the DTRACEIOC_ENABLE ioctl.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_program_exec(dtp, dtp->dt_errprog, NULL) == -1 && (
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtp->dt_errno != ENOTTY || dtp->dt_vector == NULL))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (err == -1 && (errno != ENOTTY || dtp->dt_vector == NULL))
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_ioctl(dtp, DTRACEIOC_GO, &dtp->dt_beganon) == -1) {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_ioctl(dtp, DTRACEIOC_STOP, &dtp->dt_endedon) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Now that we're stopped, we're going to get status one final time.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_ioctl(dtp, DTRACEIOC_STATUS, &dtp->dt_status[gen]) == -1)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dt_handle_status(dtp, &dtp->dt_status[gen ^ 1],
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (-1);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_consume_probe_f *pfunc, dtrace_consume_rec_f *rfunc, void *arg)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_optval_t policy = dtp->dt_options[DTRACEOPT_BUFPOLICY];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Tracing is stopped. We now want to force dtrace_consume()
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and dtrace_aggregate_snap() to proceed, regardless of
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * switchrate and aggrate. We do this by clearing the times.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if ((status == DTRACE_STATUS_NONE || status == DTRACE_STATUS_OKAY) &&
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * There either isn't any status or things are fine -- and
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * this is a "ring" or "fill" buffer. We don't want to consume
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * any of the trace data or snapshot the aggregations; we just
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync if (dtrace_consume(dtp, fp, pfunc, rfunc, arg) == -1)