xref: /onnv-gate/usr/src/lib/libdtrace/common/dt_handle.c (revision 265:a968e4ece133)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <stddef.h>
300Sstevel@tonic-gate #include <stdlib.h>
310Sstevel@tonic-gate #include <strings.h>
320Sstevel@tonic-gate #include <errno.h>
330Sstevel@tonic-gate #include <unistd.h>
340Sstevel@tonic-gate #include <assert.h>
350Sstevel@tonic-gate #include <alloca.h>
360Sstevel@tonic-gate 
37*265Smws #include <dt_impl.h>
38*265Smws #include <dt_program.h>
39*265Smws 
400Sstevel@tonic-gate static const char _dt_errprog[] =
410Sstevel@tonic-gate "dtrace:::ERROR"
420Sstevel@tonic-gate "{"
430Sstevel@tonic-gate "	trace(arg1);"
440Sstevel@tonic-gate "	trace(arg2);"
450Sstevel@tonic-gate "	trace(arg3);"
460Sstevel@tonic-gate "	trace(arg4);"
470Sstevel@tonic-gate "	trace(arg5);"
480Sstevel@tonic-gate "}";
490Sstevel@tonic-gate 
500Sstevel@tonic-gate int
510Sstevel@tonic-gate dtrace_handle_err(dtrace_hdl_t *dtp, dtrace_handle_err_f *hdlr, void *arg)
520Sstevel@tonic-gate {
530Sstevel@tonic-gate 	dtrace_prog_t *pgp = NULL;
540Sstevel@tonic-gate 	dt_stmt_t *stp;
550Sstevel@tonic-gate 	dtrace_ecbdesc_t *edp;
560Sstevel@tonic-gate 
570Sstevel@tonic-gate 	/*
580Sstevel@tonic-gate 	 * We don't currently support multiple error handlers.
590Sstevel@tonic-gate 	 */
600Sstevel@tonic-gate 	if (dtp->dt_errhdlr != NULL)
610Sstevel@tonic-gate 		return (dt_set_errno(dtp, EALREADY));
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 	/*
640Sstevel@tonic-gate 	 * If the DTRACEOPT_GRABANON is enabled, the anonymous enabling will
650Sstevel@tonic-gate 	 * already have a dtrace:::ERROR probe enabled; save 'hdlr' and 'arg'
660Sstevel@tonic-gate 	 * but do not bother compiling and enabling _dt_errprog.
670Sstevel@tonic-gate 	 */
680Sstevel@tonic-gate 	if (dtp->dt_options[DTRACEOPT_GRABANON] != DTRACEOPT_UNSET)
690Sstevel@tonic-gate 		goto out;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	if ((pgp = dtrace_program_strcompile(dtp, _dt_errprog,
720Sstevel@tonic-gate 	    DTRACE_PROBESPEC_NAME, DTRACE_C_ZDEFS, 0, NULL)) == NULL)
730Sstevel@tonic-gate 		return (dt_set_errno(dtp, dtrace_errno(dtp)));
740Sstevel@tonic-gate 
750Sstevel@tonic-gate 	stp = dt_list_next(&pgp->dp_stmts);
760Sstevel@tonic-gate 	assert(stp != NULL);
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 	edp = stp->ds_desc->dtsd_ecbdesc;
790Sstevel@tonic-gate 	assert(edp != NULL);
800Sstevel@tonic-gate 	edp->dted_uarg = DT_ECB_ERROR;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate out:
830Sstevel@tonic-gate 	dtp->dt_errhdlr = hdlr;
840Sstevel@tonic-gate 	dtp->dt_errarg = arg;
850Sstevel@tonic-gate 	dtp->dt_errprog = pgp;
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 	return (0);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate 
900Sstevel@tonic-gate int
910Sstevel@tonic-gate dtrace_handle_drop(dtrace_hdl_t *dtp, dtrace_handle_drop_f *hdlr, void *arg)
920Sstevel@tonic-gate {
930Sstevel@tonic-gate 	if (dtp->dt_drophdlr != NULL)
940Sstevel@tonic-gate 		return (dt_set_errno(dtp, EALREADY));
950Sstevel@tonic-gate 
960Sstevel@tonic-gate 	dtp->dt_drophdlr = hdlr;
970Sstevel@tonic-gate 	dtp->dt_droparg = arg;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	return (0);
1000Sstevel@tonic-gate }
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate int
1030Sstevel@tonic-gate dtrace_handle_proc(dtrace_hdl_t *dtp, dtrace_handle_proc_f *hdlr, void *arg)
1040Sstevel@tonic-gate {
1050Sstevel@tonic-gate 	if (dtp->dt_prochdlr != NULL)
1060Sstevel@tonic-gate 		return (dt_set_errno(dtp, EALREADY));
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate 	dtp->dt_prochdlr = hdlr;
1090Sstevel@tonic-gate 	dtp->dt_procarg = arg;
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate 	return (0);
1120Sstevel@tonic-gate }
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate int
1150Sstevel@tonic-gate dtrace_handle_buffered(dtrace_hdl_t *dtp, dtrace_handle_buffered_f *hdlr,
1160Sstevel@tonic-gate     void *arg)
1170Sstevel@tonic-gate {
1180Sstevel@tonic-gate 	if (dtp->dt_bufhdlr != NULL)
1190Sstevel@tonic-gate 		return (dt_set_errno(dtp, EALREADY));
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate 	if (hdlr == NULL)
1220Sstevel@tonic-gate 		return (dt_set_errno(dtp, EINVAL));
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate 	dtp->dt_bufhdlr = hdlr;
1250Sstevel@tonic-gate 	dtp->dt_bufarg = arg;
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 	return (0);
1280Sstevel@tonic-gate }
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate #define	DT_REC(type, ndx) *((type *)((uintptr_t)data->dtpda_data + \
1310Sstevel@tonic-gate     epd->dtepd_rec[(ndx)].dtrd_offset))
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate static int
1340Sstevel@tonic-gate dt_handle_err(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
1350Sstevel@tonic-gate {
1360Sstevel@tonic-gate 	dtrace_eprobedesc_t *epd = data->dtpda_edesc, *errepd;
1370Sstevel@tonic-gate 	dtrace_probedesc_t *pd = data->dtpda_pdesc, *errpd;
1380Sstevel@tonic-gate 	dtrace_errdata_t err;
1390Sstevel@tonic-gate 	dtrace_epid_t epid;
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate 	char where[30];
1420Sstevel@tonic-gate 	char details[30];
1430Sstevel@tonic-gate 	char offinfo[30];
1440Sstevel@tonic-gate 	const int slop = 80;
1450Sstevel@tonic-gate 	const char *faultstr;
1460Sstevel@tonic-gate 	char *str;
1470Sstevel@tonic-gate 	int len;
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate 	assert(epd->dtepd_uarg == DT_ECB_ERROR);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 	if (epd->dtepd_nrecs != 5 || strcmp(pd->dtpd_provider, "dtrace") != 0 ||
1520Sstevel@tonic-gate 	    strcmp(pd->dtpd_name, "ERROR") != 0)
1530Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADERROR));
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate 	/*
1560Sstevel@tonic-gate 	 * This is an error.  We have the following items here:  EPID,
1570Sstevel@tonic-gate 	 * faulting action, DIF offset, fault code and faulting address.
1580Sstevel@tonic-gate 	 */
1590Sstevel@tonic-gate 	epid = (uint32_t)DT_REC(uint64_t, 0);
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate 	if (dt_epid_lookup(dtp, epid, &errepd, &errpd) != 0)
1620Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BADERROR));
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 	err.dteda_edesc = errepd;
1650Sstevel@tonic-gate 	err.dteda_pdesc = errpd;
1660Sstevel@tonic-gate 	err.dteda_cpu = data->dtpda_cpu;
1670Sstevel@tonic-gate 	err.dteda_action = (int)DT_REC(uint64_t, 1);
1680Sstevel@tonic-gate 	err.dteda_offset = (int)DT_REC(uint64_t, 2);
1690Sstevel@tonic-gate 	err.dteda_fault = (int)DT_REC(uint64_t, 3);
1700Sstevel@tonic-gate 	err.dteda_addr = DT_REC(uint64_t, 4);
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate 	faultstr = dtrace_faultstr(dtp, err.dteda_fault);
1730Sstevel@tonic-gate 	len = sizeof (where) + sizeof (offinfo) + strlen(faultstr) +
1740Sstevel@tonic-gate 	    strlen(errpd->dtpd_provider) + strlen(errpd->dtpd_mod) +
1750Sstevel@tonic-gate 	    strlen(errpd->dtpd_name) + strlen(errpd->dtpd_func) +
1760Sstevel@tonic-gate 	    slop;
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate 	str = (char *)alloca(len);
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 	if (err.dteda_action == 0) {
1810Sstevel@tonic-gate 		(void) sprintf(where, "predicate");
1820Sstevel@tonic-gate 	} else {
1830Sstevel@tonic-gate 		(void) sprintf(where, "action #%d", err.dteda_action);
1840Sstevel@tonic-gate 	}
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate 	if (err.dteda_offset != -1) {
1870Sstevel@tonic-gate 		(void) sprintf(offinfo, " at DIF offset %d", err.dteda_offset);
1880Sstevel@tonic-gate 	} else {
1890Sstevel@tonic-gate 		offinfo[0] = 0;
1900Sstevel@tonic-gate 	}
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate 	switch (err.dteda_fault) {
1930Sstevel@tonic-gate 	case DTRACEFLT_BADADDR:
1940Sstevel@tonic-gate 	case DTRACEFLT_BADALIGN:
1950Sstevel@tonic-gate 		(void) sprintf(details, " (0x%llx)",
1960Sstevel@tonic-gate 		    (u_longlong_t)err.dteda_addr);
1970Sstevel@tonic-gate 		break;
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate 	default:
2000Sstevel@tonic-gate 		details[0] = 0;
2010Sstevel@tonic-gate 	}
2020Sstevel@tonic-gate 
2030Sstevel@tonic-gate 	(void) snprintf(str, len, "error on enabled probe ID %u "
2040Sstevel@tonic-gate 	    "(ID %u: %s:%s:%s:%s): %s%s in %s%s\n",
2050Sstevel@tonic-gate 	    epid, errpd->dtpd_id, errpd->dtpd_provider,
2060Sstevel@tonic-gate 	    errpd->dtpd_mod, errpd->dtpd_func,
2070Sstevel@tonic-gate 	    errpd->dtpd_name, dtrace_faultstr(dtp, err.dteda_fault),
2080Sstevel@tonic-gate 	    details, where, offinfo);
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate 	err.dteda_msg = str;
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate 	if (dtp->dt_errhdlr == NULL)
2130Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_ERRABORT));
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate 	if ((*dtp->dt_errhdlr)(&err, dtp->dt_errarg) == DTRACE_HANDLE_ABORT)
2160Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_ERRABORT));
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate 	return (0);
2190Sstevel@tonic-gate }
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate int
2220Sstevel@tonic-gate dt_handle_liberr(dtrace_hdl_t *dtp, const dtrace_probedata_t *data,
2230Sstevel@tonic-gate     const char *faultstr)
2240Sstevel@tonic-gate {
2250Sstevel@tonic-gate 	dtrace_probedesc_t *errpd = data->dtpda_pdesc;
2260Sstevel@tonic-gate 	dtrace_errdata_t err;
2270Sstevel@tonic-gate 	const int slop = 80;
2280Sstevel@tonic-gate 	char *str;
2290Sstevel@tonic-gate 	int len;
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate 	err.dteda_edesc = data->dtpda_edesc;
2320Sstevel@tonic-gate 	err.dteda_pdesc = errpd;
2330Sstevel@tonic-gate 	err.dteda_cpu = data->dtpda_cpu;
2340Sstevel@tonic-gate 	err.dteda_action = -1;
2350Sstevel@tonic-gate 	err.dteda_offset = -1;
2360Sstevel@tonic-gate 	err.dteda_fault = DTRACEFLT_LIBRARY;
2370Sstevel@tonic-gate 	err.dteda_addr = NULL;
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate 	len = strlen(faultstr) +
2400Sstevel@tonic-gate 	    strlen(errpd->dtpd_provider) + strlen(errpd->dtpd_mod) +
2410Sstevel@tonic-gate 	    strlen(errpd->dtpd_name) + strlen(errpd->dtpd_func) +
2420Sstevel@tonic-gate 	    slop;
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate 	str = alloca(len);
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate 	(void) snprintf(str, len, "error on enabled probe ID %u "
2470Sstevel@tonic-gate 	    "(ID %u: %s:%s:%s:%s): %s\n",
2480Sstevel@tonic-gate 	    data->dtpda_edesc->dtepd_epid,
2490Sstevel@tonic-gate 	    errpd->dtpd_id, errpd->dtpd_provider,
2500Sstevel@tonic-gate 	    errpd->dtpd_mod, errpd->dtpd_func,
2510Sstevel@tonic-gate 	    errpd->dtpd_name, faultstr);
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate 	err.dteda_msg = str;
2540Sstevel@tonic-gate 
2550Sstevel@tonic-gate 	if (dtp->dt_errhdlr == NULL)
2560Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_ERRABORT));
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate 	if ((*dtp->dt_errhdlr)(&err, dtp->dt_errarg) == DTRACE_HANDLE_ABORT)
2590Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_ERRABORT));
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate 	return (0);
2620Sstevel@tonic-gate }
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate int
2650Sstevel@tonic-gate dt_handle_cpudrop(dtrace_hdl_t *dtp, processorid_t cpu,
2660Sstevel@tonic-gate     dtrace_dropkind_t what, uint64_t howmany)
2670Sstevel@tonic-gate {
2680Sstevel@tonic-gate 	dtrace_dropdata_t drop;
2690Sstevel@tonic-gate 	char str[80];
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate 	assert(what == DTRACEDROP_PRINCIPAL || what == DTRACEDROP_AGGREGATION);
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate 	bzero(&drop, sizeof (drop));
2740Sstevel@tonic-gate 	drop.dtdda_handle = dtp;
2750Sstevel@tonic-gate 	drop.dtdda_cpu = cpu;
2760Sstevel@tonic-gate 	drop.dtdda_kind = what;
2770Sstevel@tonic-gate 	drop.dtdda_drops = howmany;
2780Sstevel@tonic-gate 	drop.dtdda_msg = str;
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate 	(void) snprintf(str, sizeof (str), "%llu %sdrop%s on CPU %d\n",
2810Sstevel@tonic-gate 	    howmany, what == DTRACEDROP_PRINCIPAL ? "" : "aggregation ",
2820Sstevel@tonic-gate 	    howmany > 1 ? "s" : "", cpu);
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 	if (dtp->dt_drophdlr == NULL)
2850Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_DROPABORT));
2860Sstevel@tonic-gate 
2870Sstevel@tonic-gate 	if ((*dtp->dt_drophdlr)(&drop, dtp->dt_droparg) == DTRACE_HANDLE_ABORT)
2880Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_DROPABORT));
2890Sstevel@tonic-gate 
2900Sstevel@tonic-gate 	return (0);
2910Sstevel@tonic-gate }
2920Sstevel@tonic-gate 
2930Sstevel@tonic-gate static const struct {
2940Sstevel@tonic-gate 	dtrace_dropkind_t dtdrt_kind;
2950Sstevel@tonic-gate 	uintptr_t dtdrt_offset;
2960Sstevel@tonic-gate 	const char *dtdrt_str;
2970Sstevel@tonic-gate 	const char *dtdrt_msg;
2980Sstevel@tonic-gate } _dt_droptab[] = {
2990Sstevel@tonic-gate 	{ DTRACEDROP_DYNAMIC,
3000Sstevel@tonic-gate 	    offsetof(dtrace_status_t, dtst_dyndrops),
3010Sstevel@tonic-gate 	    "dynamic variable drop" },
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate 	{ DTRACEDROP_DYNRINSE,
3040Sstevel@tonic-gate 	    offsetof(dtrace_status_t, dtst_dyndrops_rinsing),
3050Sstevel@tonic-gate 	    "dynamic variable drop", " with non-empty rinsing list" },
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate 	{ DTRACEDROP_DYNDIRTY,
3080Sstevel@tonic-gate 	    offsetof(dtrace_status_t, dtst_dyndrops_dirty),
3090Sstevel@tonic-gate 	    "dynamic variable drop", " with non-empty dirty list" },
3100Sstevel@tonic-gate 
3110Sstevel@tonic-gate 	{ DTRACEDROP_SPEC,
3120Sstevel@tonic-gate 	    offsetof(dtrace_status_t, dtst_specdrops),
3130Sstevel@tonic-gate 	    "speculative drop" },
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate 	{ DTRACEDROP_SPECBUSY,
3160Sstevel@tonic-gate 	    offsetof(dtrace_status_t, dtst_specdrops_busy),
3170Sstevel@tonic-gate 	    "failed speculation", " (available buffer(s) still busy)" },
3180Sstevel@tonic-gate 
3190Sstevel@tonic-gate 	{ DTRACEDROP_SPECUNAVAIL,
3200Sstevel@tonic-gate 	    offsetof(dtrace_status_t, dtst_specdrops_unavail),
3210Sstevel@tonic-gate 	    "failed speculation", " (no speculative buffer available)" },
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate 	{ 0, 0, NULL }
3240Sstevel@tonic-gate };
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate int
3270Sstevel@tonic-gate dt_handle_status(dtrace_hdl_t *dtp, dtrace_status_t *old, dtrace_status_t *new)
3280Sstevel@tonic-gate {
3290Sstevel@tonic-gate 	dtrace_dropdata_t drop;
3300Sstevel@tonic-gate 	char str[80];
3310Sstevel@tonic-gate 	uintptr_t base = (uintptr_t)new, obase = (uintptr_t)old;
3320Sstevel@tonic-gate 	int i;
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate 	bzero(&drop, sizeof (drop));
3350Sstevel@tonic-gate 	drop.dtdda_handle = dtp;
3360Sstevel@tonic-gate 	drop.dtdda_cpu = DTRACE_CPUALL;
3370Sstevel@tonic-gate 	drop.dtdda_msg = str;
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 	/*
3400Sstevel@tonic-gate 	 * First, check to see if we've been killed -- in which case we abort.
3410Sstevel@tonic-gate 	 */
3420Sstevel@tonic-gate 	if (new->dtst_killed && !old->dtst_killed)
3430Sstevel@tonic-gate 		return (dt_set_errno(dtp, EDT_BRICKED));
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate 	for (i = 0; _dt_droptab[i].dtdrt_str != NULL; i++) {
3460Sstevel@tonic-gate 		uintptr_t naddr = base + _dt_droptab[i].dtdrt_offset;
3470Sstevel@tonic-gate 		uintptr_t oaddr = obase + _dt_droptab[i].dtdrt_offset;
3480Sstevel@tonic-gate 
3490Sstevel@tonic-gate 		uint64_t nval = *((uint64_t *)naddr);
3500Sstevel@tonic-gate 		uint64_t oval = *((uint64_t *)oaddr);
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate 		if (nval == oval)
3530Sstevel@tonic-gate 			continue;
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate 		(void) snprintf(str, sizeof (str), "%llu %s%s%s\n", nval - oval,
3560Sstevel@tonic-gate 		    _dt_droptab[i].dtdrt_str, (nval - oval > 1) ? "s" : "",
3570Sstevel@tonic-gate 		    _dt_droptab[i].dtdrt_msg != NULL ?
3580Sstevel@tonic-gate 		    _dt_droptab[i].dtdrt_msg : "");
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate 		drop.dtdda_kind = _dt_droptab[i].dtdrt_kind;
3610Sstevel@tonic-gate 		drop.dtdda_total = nval;
3620Sstevel@tonic-gate 		drop.dtdda_drops = nval - oval;
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 		if (dtp->dt_drophdlr == NULL)
3650Sstevel@tonic-gate 			return (dt_set_errno(dtp, EDT_DROPABORT));
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 		if ((*dtp->dt_drophdlr)(&drop,
3680Sstevel@tonic-gate 		    dtp->dt_droparg) == DTRACE_HANDLE_ABORT)
3690Sstevel@tonic-gate 			return (dt_set_errno(dtp, EDT_DROPABORT));
3700Sstevel@tonic-gate 	}
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate 	return (0);
3730Sstevel@tonic-gate }
3740Sstevel@tonic-gate 
3750Sstevel@tonic-gate int
3760Sstevel@tonic-gate dt_handle(dtrace_hdl_t *dtp, dtrace_probedata_t *data)
3770Sstevel@tonic-gate {
3780Sstevel@tonic-gate 	dtrace_eprobedesc_t *epd = data->dtpda_edesc;
3790Sstevel@tonic-gate 	int rval;
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate 	switch (epd->dtepd_uarg) {
3820Sstevel@tonic-gate 	case DT_ECB_ERROR:
3830Sstevel@tonic-gate 		rval = dt_handle_err(dtp, data);
3840Sstevel@tonic-gate 		break;
3850Sstevel@tonic-gate 
3860Sstevel@tonic-gate 	default:
3870Sstevel@tonic-gate 		return (DTRACE_CONSUME_THIS);
3880Sstevel@tonic-gate 	}
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate 	if (rval == 0)
3910Sstevel@tonic-gate 		return (DTRACE_CONSUME_NEXT);
3920Sstevel@tonic-gate 
3930Sstevel@tonic-gate 	return (DTRACE_CONSUME_ERROR);
3940Sstevel@tonic-gate }
395