/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <assert.h>
#include <ctype.h>
#include <alloca.h>
#include <dt_impl.h>
/*
* We declare this here because (1) we need it and (2) we want to avoid a
* dependency on libm in libdtrace.
*/
static long double
dt_fabsl(long double x)
{
if (x < 0)
return (-x);
return (x);
}
/*
* 128-bit arithmetic functions needed to support the stddev() aggregating
* action.
*/
static int
{
return (a[1] > b[1] || (a[1] == b[1] && a[0] > b[0]));
}
static int
{
return (a[1] > b[1] || (a[1] == b[1] && a[0] >= b[0]));
}
static int
{
return (a[1] < b[1] || (a[1] == b[1] && a[0] <= b[0]));
}
/*
* Shift the 128-bit value in a by b. If b is positive, shift left.
* If b is negative, shift right.
*/
static void
{
if (b == 0)
return;
if (b < 0) {
b = -b;
if (b >= 64) {
a[0] = a[1] >> (b - 64);
a[1] = 0;
} else {
a[0] >>= b;
mask -= 1;
a[1] >>= b;
}
} else {
if (b >= 64) {
a[1] = a[0] << (b - 64);
a[0] = 0;
} else {
a[1] <<= b;
mask = a[0] >> (64 - b);
a[1] |= mask;
a[0] <<= b;
}
}
}
static int
{
int nbits = 0;
tmp[0] = a[0];
nbits++;
}
return (nbits);
}
static void
{
difference[0] = result[0];
}
static void
{
}
/*
* The basic idea is to break the 2 64-bit values into 4 32-bit values,
* use native multiplication on those, and then re-combine into the
* resulting 128-bit value.
*
* (hi1 << 32 + lo1) * (hi2 << 32 + lo2) =
* hi1 * hi2 << 64 +
* hi1 * lo2 << 32 +
* hi2 * lo1 << 32 +
* lo1 * lo2
*/
static void
{
tmp[1] = 0;
tmp[1] = 0;
}
/*
* This is long-hand division.
*
* We initialize subtrahend by shifting divisor left as far as possible. We
* loop, comparing subtrahend to dividend: if subtrahend is smaller, we
* subtract and set the appropriate bit in the result. We then shift
* subtrahend right by one bit for the next comparison.
*/
static void
{
int log = 0;
divisor_128[0] = divisor;
divisor_128[1] = 0;
subtrahend[0] = divisor;
subtrahend[1] = 0;
while (divisor > 0) {
log++;
divisor >>= 1;
}
}
}
}
/*
* This is the long-hand method of calculating a square root.
* The algorithm is as follows:
*
* 1. Group the digits by 2 from the right.
* 2. Over the leftmost group, find the largest single-digit number
* whose square is less than that group.
* 3. Subtract the result of the previous step (2 or 4, depending) and
* bring down the next two-digit group.
* 4. For the result R we have so far, find the largest single-digit number
* x such that 2 * R * 10 * x + x^2 is less than the result from step 3.
* (Note that this is doubling R and performing a decimal left-shift by 1
* and searching for the appropriate decimal to fill the one's place.)
* The value x is the next digit in the square root.
* Repeat steps 3 and 4 until the desired precision is reached. (We're
* dealing with integers, so the above is sufficient.)
*
* In decimal, the square root of 582,734 would be calculated as so:
*
* __7__6__3
* | 58 27 34
* -49 (7^2 == 49 => 7 is the first digit in the square root)
* --
* 9 27 (Subtract and bring down the next group.)
* 146 8 76 (2 * 7 * 10 * 6 + 6^2 == 876 => 6 is the next digit in
* ----- the square root)
* 51 34 (Subtract and bring down the next group.)
* 1523 45 69 (2 * 76 * 10 * 3 + 3^2 == 4569 => 3 is the next digit in
* ----- the square root)
* 5 65 (remainder)
*
* The above algorithm applies similarly in binary, but note that the
* only possible non-zero value for x in step 4 is 1, so step 4 becomes a
* simple decision: is 2 * R * 2 * 1 + 1^2 (aka R << 2 + 1) less than the
* preceding difference?
*
* In binary, the square root of 11011011 would be calculated as so:
*
* __1__1__1__0
* | 11 01 10 11
* 01 (0 << 2 + 1 == 1 < 11 => this bit is 1)
* --
* 10 01 10 11
* 101 1 01 (1 << 2 + 1 == 101 < 1001 => next bit is 1)
* -----
* 1 00 10 11
* 1101 11 01 (11 << 2 + 1 == 1101 < 10010 => next bit is 1)
* -------
* 1 01 11
* 11101 1 11 01 (111 << 2 + 1 == 11101 > 10111 => last bit is 0)
*
*/
static uint64_t
{
int i;
for (i = 0; i <= bit_pairs; i++) {
/*
* Bring down the next pair of bits.
*/
next_pair[0] &= 0x3;
next_pair[1] = 0;
/*
* next_try = R << 2 + 1
*/
} else {
}
pair_shift -= 2;
}
return (result[0]);
}
{
/*
* The standard approximation for standard deviation is
* sqrt(average(x**2) - average(x)**2), i.e. the square root
* of the average of the squares minus the square of the average.
*/
if (norm_avg < 0)
return (dt_sqrt_128(diff));
}
static int
{
int rval;
if (entlen == 0) {
}
/*
* If the name of the probe is "entry" or ends with "-entry", we
* treat it as an entry; if it is "return" or ends with "-return",
* we treat it as a return. (This allows application-provided probes
* like "method-entry" or "function-entry" to participate in flow
* indentation -- without accidentally misinterpreting popular probe
* names like "carpentry", "gentry" or "Coventry".)
*/
}
/*
* If we're going to indent this, we need to check the ID of our last
* call. If we're looking at the same probe ID but a different EPID,
* we _don't_ want to indent. (Yes, there are some minor holes in
* this scheme -- it's a heuristic.)
*/
if (flow == DTRACEFLOW_ENTRY) {
}
/*
* If we're going to unindent this, it's more difficult to see if
* we don't actually want to unindent it -- we need to look at the
* _next_ EPID.
*/
if (flow == DTRACEFLOW_RETURN) {
do {
/*
* We're at the end -- maybe. If the oldest
* record is non-zero, we need to wrap.
*/
if (buf->dtbd_oldest != 0) {
offs = 0;
} else {
goto out;
}
}
if (next == DTRACE_EPIDNONE)
} while (next == DTRACE_EPIDNONE);
return (rval);
}
out:
} else {
}
return (0);
}
static int
{
return (DTRACE_CONSUME_THIS);
}
static int
{
return (DTRACE_CONSUME_NEXT);
}
int
{
long double f;
if (!negatives) {
if (positives) {
} else {
depth = 0;
}
}
if (!positives) {
}
/*
* If we're here, we have both positive and negative bucket values.
* To express this graphically, we're going to generate both positive
* and negative bars separated by a centerline. These bars are half
* the size of normal quantize()/lquantize() bars, so we divide the
* length in half before calculating the bar length.
*/
len /= 2;
if (val <= 0) {
} else {
}
}
int
{
long double total = 0;
first_bin++;
/*
* There isn't any data. This is possible if (and only if)
* negative increment values have been used. In this case,
* we'll print the buckets around 0.
*/
} else {
if (first_bin > 0)
first_bin--;
last_bin--;
last_bin++;
}
}
"------------- Distribution -------------", "count") < 0)
return (-1);
(long long)DTRACE_QUANTIZE_BUCKETVAL(i)) < 0)
return (-1);
return (-1);
}
return (0);
}
int
{
long double total = 0;
first_bin = 0;
first_bin++;
first_bin = 0;
last_bin = 2;
} else {
if (first_bin > 0)
first_bin--;
last_bin--;
last_bin++;
}
}
"------------- Distribution -------------", "count") < 0)
return (-1);
char c[32];
int err;
if (i == 0) {
(void) snprintf(c, sizeof (c), "< %d",
} else if (i == levels + 1) {
(void) snprintf(c, sizeof (c), ">= %d",
} else {
}
return (-1);
}
return (0);
}
/*ARGSUSED*/
static int
{
/* LINTED - alignment */
}
/*ARGSUSED*/
static int
{
/* LINTED - alignment */
}
/*ARGSUSED*/
int
{
/*
* If the byte stream is a series of printable characters, followed by
* a terminating byte, we print it out as a string. Otherwise, we
* assume that it's something else and just print the bytes.
*/
char *c = (char *)addr;
if (nbytes == 0)
return (0);
goto raw;
for (i = 0; i < nbytes; i++) {
/*
* We define a "printable character" to be one for which
* isprint(3C) returns non-zero, isspace(3C) returns non-zero,
* or a character which is either backspace or the bell.
* Backspace and the bell are regrettably special because
* they fail the first two tests -- and yet they are entirely
* printable. These are the only two control characters that
* have meaning for the terminal and for which isprint(3C) and
* isspace(3C) return 0.
*/
c[i] == '\b' || c[i] == '\a')
continue;
if (c[i] == '\0' && i > 0) {
/*
* This looks like it might be a string. Before we
* assume that it is indeed a string, check the
* remainder of the byte range; if it contains
* additional non-nul characters, we'll assume that
* it's a binary stream that just happens to look like
* a string, and we'll print out the individual bytes.
*/
for (j = i + 1; j < nbytes; j++) {
if (c[j] != '\0')
break;
}
if (j != nbytes)
break;
if (quiet)
else
}
break;
}
if (i == nbytes) {
/*
* The byte range is all printable characters, but there is
* no trailing nul byte. We'll assume that it's a string and
* print it as such.
*/
s[nbytes] = '\0';
}
raw:
return (-1);
for (i = 0; i < 16; i++)
return (-1);
return (-1);
for (i = 0; i < nbytes; i += 16) {
return (-1);
for (j = i; j < i + 16 && j < nbytes; j++) {
return (-1);
}
while (j++ % 16) {
return (-1);
}
return (-1);
for (j = i; j < i + 16 && j < nbytes; j++) {
c[j] < ' ' || c[j] > '~' ? '.' : c[j]) < 0)
return (-1);
}
return (-1);
}
return (0);
}
int
{
int i, indent;
char c[PATH_MAX * 2];
return (-1);
format = "%s";
else
for (i = 0; i < depth; i++) {
switch (size) {
case sizeof (uint32_t):
/* LINTED - alignment */
break;
case sizeof (uint64_t):
/* LINTED - alignment */
break;
default:
}
break;
return (-1);
(void) snprintf(c, sizeof (c), "%s`%s+0x%llx",
} else {
(void) snprintf(c, sizeof (c), "%s`%s",
}
} else {
/*
* We'll repeat the lookup, but this time we'll specify
* a NULL GElf_Sym -- indicating that we're only
* interested in the containing module.
*/
(void) snprintf(c, sizeof (c), "%s`0x%llx",
} else {
}
}
return (-1);
return (-1);
}
return (0);
}
int
{
/* LINTED - alignment */
int err = 0;
struct ps_prochandle *P;
int i, indent;
if (depth == 0)
return (0);
return (-1);
format = "%s";
else
/*
* Ultimately, we need to add an entry point in the library vector for
* determining <symbol, offset> from <pid, address>. For now, if
* this is a vector open, we just print the raw address or string.
*/
else
P = NULL;
if (P != NULL)
break;
(void) snprintf(c, sizeof (c),
} else {
(void) snprintf(c, sizeof (c),
}
/*
* If the current string pointer in the string table
* does not point to an empty string _and_ the program
* counter falls in a writable region, we'll use the
* string from the string table instead of the raw
* address. This last condition is necessary because
* some (broken) ustack helpers will return a string
* even for a program counter that they can't
* identify. If we have a string for a program
* counter that falls in a segment that isn't
* writable, we assume that we have fallen into this
* case and we refuse to use the string.
*/
} else {
(void) snprintf(c, sizeof (c), "%s`0x%llx",
} else {
(void) snprintf(c, sizeof (c), "0x%llx",
(u_longlong_t)pc[i]);
}
}
break;
break;
/*
* If the first character of the string is an "at" sign,
* then the string is inferred to be an annotation --
* and it is printed out beneath the frame and offset
* with brackets.
*/
break;
break;
break;
}
}
}
if (P != NULL) {
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
}
return (err);
}
static int
{
/* LINTED - alignment */
/* LINTED - alignment */
char *s;
struct ps_prochandle *P;
dt_proc_lock(dtp, P);
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
}
}
do {
n = len;
s = alloca(n);
}
int
{
/* LINTED - alignment */
/* LINTED - alignment */
int err = 0;
struct ps_prochandle *P;
format = " %-50s";
/*
* See the comment in dt_print_ustack() for the rationale for
* printing raw addresses in the vectored case.
*/
else
P = NULL;
if (P != NULL)
} else {
}
if (P != NULL) {
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
}
return (err);
}
static int
{
/* LINTED - alignment */
char c[PATH_MAX * 2];
format = " %-50s";
(void) snprintf(c, sizeof (c), "%s`%s",
} else {
/*
* We'll repeat the lookup, but this time we'll specify a
* NULL GElf_Sym -- indicating that we're only interested in
* the containing module.
*/
(void) snprintf(c, sizeof (c), "%s`0x%llx",
} else {
(void) snprintf(c, sizeof (c), "0x%llx",
(u_longlong_t)pc);
}
}
return (-1);
return (0);
}
int
{
/* LINTED - alignment */
char c[PATH_MAX * 2];
format = " %-50s";
} else {
}
return (-1);
return (0);
}
typedef struct dt_normal {
} dt_normal_t;
static int
{
if (agg->dtagd_nrecs == 0)
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_NORMALIZE);
}
static int
{
/*
* We (should) have two records: the aggregation ID followed by the
* normalization value.
*/
/* LINTED - alignment */
rec++;
case sizeof (uint64_t):
/* LINTED - alignment */
break;
case sizeof (uint32_t):
/* LINTED - alignment */
break;
case sizeof (uint16_t):
/* LINTED - alignment */
break;
case sizeof (uint8_t):
break;
default:
}
return (0);
}
static int
{
if (agg->dtagd_nrecs == 0)
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_DENORMALIZE);
}
static int
{
if (agg->dtagd_nrecs == 0)
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_CLEAR);
}
typedef struct dt_trunc {
} dt_trunc_t;
static int
{
if (agg->dtagd_nrecs == 0)
return (DTRACE_AGGWALK_NEXT);
return (DTRACE_AGGWALK_NEXT);
if (trunc->dttd_remaining == 0)
return (DTRACE_AGGWALK_REMOVE);
trunc->dttd_remaining--;
return (DTRACE_AGGWALK_NEXT);
}
static int
{
/*
* We (should) have two records: the aggregation ID followed by the
* number of aggregation entries after which the aggregation is to be
* truncated.
*/
/* LINTED - alignment */
rec++;
case sizeof (uint64_t):
/* LINTED - alignment */
break;
case sizeof (uint32_t):
/* LINTED - alignment */
break;
case sizeof (uint16_t):
/* LINTED - alignment */
break;
case sizeof (uint8_t):
break;
default:
}
if (remaining < 0) {
} else {
}
return (0);
}
static int
{
int err;
switch (act) {
case DTRACEACT_STACK:
case DTRACEACT_USTACK:
case DTRACEACT_JSTACK:
case DTRACEACT_USYM:
case DTRACEACT_UADDR:
case DTRACEACT_UMOD:
case DTRACEACT_SYM:
case DTRACEACT_MOD:
case DTRACEAGG_QUANTIZE:
case DTRACEAGG_LQUANTIZE:
case DTRACEAGG_AVG:
case DTRACEAGG_STDDEV:
default:
break;
}
switch (size) {
case sizeof (uint64_t):
/* LINTED - alignment */
break;
case sizeof (uint32_t):
/* LINTED - alignment */
break;
case sizeof (uint16_t):
/* LINTED - alignment */
break;
case sizeof (uint8_t):
break;
default:
break;
}
return (err);
}
int
{
int i, aggact = 0;
/*
* Iterate over each record description in the key, printing the traced
* data, skipping the first datum (the tuple member created by the
* compiler).
*/
if (DTRACEACT_ISAGG(act)) {
aggact = i;
break;
}
return (-1);
DTRACE_BUFDATA_AGGKEY) < 0)
return (-1);
}
return (-1);
DTRACE_BUFDATA_AGGVAL) < 0)
return (-1);
if (!pd->dtpa_allunprint)
}
return (-1);
return (-1);
return (0);
}
int
{
if (pd->dtpa_allunprint) {
return (0);
} else {
/*
* If we're not printing all unprinted aggregations, then the
* aggregation variable ID denotes a specific aggregation
* variable that we should print -- skip any other aggregations
* that we encounter.
*/
if (agg->dtagd_nrecs == 0)
return (0);
return (0);
}
}
int
{
char *msg;
const char *errstr;
return (rval);
return (0);
}
return (0);
return (rval);
}
static int
{
int rval, i, n;
/*
* We're guaranteed to have an ID.
*/
if (id == DTRACE_EPIDNONE) {
/*
* This is filler to assure proper alignment of the
* next record; we simply ignore it.
*/
continue;
}
&data.dtpda_pdesc)) != 0)
return (rval);
if (rval == DTRACE_CONSUME_NEXT)
goto nextepid;
if (rval == DTRACE_CONSUME_ERROR)
return (-1);
}
if (flow)
if (flow) {
}
if (rval == DTRACE_CONSUME_NEXT)
goto nextepid;
if (rval == DTRACE_CONSUME_ABORT)
if (rval != DTRACE_CONSUME_THIS)
for (i = 0; i < epd->dtepd_nrecs; i++) {
if (act == DTRACEACT_LIBACT) {
switch (arg) {
case DT_ACT_CLEAR:
/* LINTED - alignment */
(void) dtrace_aggregate_walk(dtp,
dt_clear_agg, &id);
continue;
case DT_ACT_DENORMALIZE:
/* LINTED - alignment */
(void) dtrace_aggregate_walk(dtp,
dt_denormalize_agg, &id);
continue;
case DT_ACT_FTRUNCATE:
continue;
continue;
case DT_ACT_NORMALIZE:
return (dt_set_errno(dtp,
if (dt_normalize(dtp,
return (-1);
i++;
continue;
case DT_ACT_SETOPT: {
int rv;
return (dt_set_errno(dtp,
}
return (dt_set_errno(dtp,
}
} else {
val = "1";
}
if (rv != 0)
return (-1);
continue;
}
case DT_ACT_TRUNC:
return (dt_set_errno(dtp,
EDT_BADTRUNC));
return (-1);
i++;
continue;
default:
continue;
}
}
if (rval == DTRACE_CONSUME_NEXT)
continue;
if (rval == DTRACE_CONSUME_ABORT)
if (rval != DTRACE_CONSUME_THIS)
if (act == DTRACEACT_STACK) {
return (-1);
goto nextrec;
}
if (act == DTRACEACT_USTACK ||
act == DTRACEACT_JSTACK) {
return (-1);
goto nextrec;
}
if (act == DTRACEACT_SYM) {
return (-1);
goto nextrec;
}
if (act == DTRACEACT_MOD) {
return (-1);
goto nextrec;
}
return (-1);
goto nextrec;
}
if (act == DTRACEACT_UMOD) {
return (-1);
goto nextrec;
}
if (DTRACEACT_ISPRINTFLIKE(act)) {
void *fmtdata;
const dtrace_probedata_t *,
const dtrace_recdesc_t *, uint_t,
goto nofmt;
switch (act) {
case DTRACEACT_PRINTF:
break;
case DTRACEACT_PRINTA:
break;
case DTRACEACT_SYSTEM:
break;
case DTRACEACT_FREOPEN:
break;
}
if (n < 0)
return (-1); /* errno is set for us */
if (n > 0)
i += n - 1;
goto nextrec;
}
if (act == DTRACEACT_PRINTA) {
int j, naggvars = 0;
sizeof (dtrace_aggvarid_t));
return (-1);
/*
* This might be a printa() with multiple
* aggregation variables. We need to scan
* forward through the records until we find
* a record from a different statement.
*/
for (j = i; j < epd->dtepd_nrecs; j++) {
break;
return (dt_set_errno(dtp,
EDT_BADAGG));
}
/* LINTED - alignment */
*((dtrace_aggvarid_t *)naddr);
}
i = j - 1;
if (naggvars == 1) {
dt_print_agg, &pd) < 0)
return (-1);
goto nextrec;
}
return (-1);
}
goto nextrec;
}
case sizeof (uint64_t):
/* LINTED - alignment */
*((unsigned long long *)addr));
break;
case sizeof (uint32_t):
/* LINTED - alignment */
break;
case sizeof (uint16_t):
/* LINTED - alignment */
break;
case sizeof (uint8_t):
break;
default:
break;
}
if (n < 0)
return (-1); /* errno is set for us */
return (-1); /* errno is set for us */
}
/*
* Call the record callback with a NULL record to indicate
* that we're done processing this EPID.
*/
}
start = 0;
goto again;
}
return (0);
/*
* Explicitly zero the drops to prevent us from processing them again.
*/
buf->dtbd_drops = 0;
}
typedef struct dt_begin {
void *dtbgn_arg;
void *dtbgn_errarg;
int dtbgn_beginonly;
} dt_begin_t;
static int
{
if (begin->dtbgn_beginonly) {
return (DTRACE_CONSUME_NEXT);
} else {
return (DTRACE_CONSUME_NEXT);
}
/*
* We have a record that we're interested in. Now call the underlying
* probe function...
*/
}
static int
{
}
static int
{
if (begin->dtbgn_beginonly) {
return (DTRACE_HANDLE_OK);
} else {
return (DTRACE_HANDLE_OK);
}
}
static int
{
/*
* There's this idea that the BEGIN probe should be processed before
* everything else, and that the END probe should be processed after
* anything else. In the common case, this is pretty easy to deal
* with. However, a situation may arise where the BEGIN enabling and
* END enabling are on the same CPU, and some enabling in the middle
* occurred on a different CPU. To deal with this (blech!) we need to
* consume the BEGIN buffer up until the end of the BEGIN probe, and
* then set it aside. We will then process every other CPU, and then
* we'll return to the BEGIN CPU and process the rest of the data
* (which will inevitably include the END probe, if any). Making this
* even more complicated (!) is the library's ERROR enabling. Because
* this enabling is processed before we even get into the consume call
* back, any ERROR firing would result in the library's ERROR enabling
* being processed twice -- once in our first pass (for BEGIN probes),
* and again in our second pass (for everything but BEGIN probes). To
* deal with this, we interpose on the ERROR handler to assure that we
* only process ERROR enablings induced by BEGIN enablings in the
* first pass, and that we only process ERROR enablings _not_ induced
* by BEGIN enablings in the second pass.
*/
int rval, i;
static int max_ncpus;
/*
* We really don't expect this to fail, but it is at least
* technically possible for this to fail with ENOENT. In this
* case, we just drive on...
*/
return (0);
}
/*
* This is the simple case. We're either not stopped, or if
* we are, we actually processed any END probes on another
* CPU. We can simply consume this buffer and return.
*/
}
/*
* We need to interpose on the ERROR handler to be sure that we
* only process ERRORs induced by BEGIN.
*/
if (rval != 0)
return (rval);
/*
* Now allocate a new buffer. We'll use this to deal with every other
* CPU.
*/
if (max_ncpus == 0)
for (i = 0; i < max_ncpus; i++) {
if (i == cpu)
continue;
/*
* If we failed with ENOENT, it may be because the
* CPU was unconfigured -- this is okay. Any other
* error, however, is unexpected.
*/
continue;
}
return (rval);
}
}
/*
* Okay -- we're done with the other buffers. Now we want to
* reconsume the first buffer -- but this time we're looking for
* everything _but_ BEGIN. And of course, in order to only consume
* those ERRORs _not_ associated with BEGIN, we need to reinstall our
* ERROR interposition function...
*/
begin.dtbgn_beginonly = 0;
return (rval);
}
int
{
static int max_ncpus;
int i, rval;
if (dtp->dt_lastswitch != 0) {
return (0);
} else {
}
if (max_ncpus == 0)
}
/*
* If we have just begun, we want to first process the CPU that
* executed the BEGIN probe (if any).
*/
return (rval);
}
for (i = 0; i < max_ncpus; i++) {
/*
* If we have stopped, we want to process the CPU on which the
* END probe was processed only _after_ we have processed
* everything else.
*/
continue;
/*
* If we failed with ENOENT, it may be because the
* CPU was unconfigured -- this is okay. Any other
* error, however, is unexpected.
*/
continue;
}
return (rval);
}
if (!dtp->dt_stopped)
return (0);
/*
* This _really_ shouldn't fail, but it is strictly speaking
* possible for this to return ENOENT if the CPU that called
* the END enabling somehow managed to become unconfigured.
* It's unclear how the user can possibly expect anything
* rational to happen in this case -- the state has been thrown
* out along with the unconfigured CPU -- so we'll just drive
* on...
*/
return (0);
}
}