+#if defined(__APPLE__)
+ /*
+ * A provider may call dtrace_probe_error() in lieu of dtrace_probe() in some circumstances.
+ * See, e.g. fasttrap_isa.c. However the provider has no access to ECB context, so passes
+ * NULL through "arg0" and the probe_id of the ovedrriden probe as arg1. Detect that here
+ * and cons up a viable state (from the probe_id).
+ */
+ if (dtrace_probeid_error == id && NULL == arg0) {
+ dtrace_id_t ftp_id = (dtrace_id_t)arg1;
+ dtrace_probe_t *ftp_probe = dtrace_probes[ftp_id - 1];
+ dtrace_ecb_t *ftp_ecb = ftp_probe->dtpr_ecb;
+
+ if (NULL != ftp_ecb) {
+ dtrace_state_t *ftp_state = ftp_ecb->dte_state;
+
+ arg0 = (uint64_t)(uintptr_t)ftp_state;
+ arg1 = ftp_ecb->dte_epid;
+ /*
+ * args[2-4] established by caller.
+ */
+ ftp_state->dts_arg_error_illval = -1; /* arg5 */
+ }
+ }
+#endif /* __APPLE__ */
+