#include "opt_kdb.h" #include #include #include #include #include SYSCTL_NODE(_debug, OID_AUTO, trace_errors, CTLFLAG_RW, 0, "TRACE_ERRORS config"); static int error2trace = 0; SYSCTL_UINT(_debug_trace_errors, OID_AUTO, error_to_trace, CTLFLAG_RW, &error2trace, 0, "Error value to trace (see errno.h)"); static int error2trace_once = 0; SYSCTL_UINT(_debug_trace_errors, OID_AUTO, error_to_trace_once, CTLFLAG_RW, &error2trace_once, 0, "Error value to trace once (see errno.h)"); static int syslog = 1; SYSCTL_UINT(_debug_trace_errors, OID_AUTO, syslog, CTLFLAG_RW, &syslog, 0, "Log traced error via log(9)"); #ifdef KDB static int backtrace = 0; SYSCTL_UINT(_debug_trace_errors, OID_AUTO, backtrace, CTLFLAG_RW, &backtrace, 0, "Print backtrace upon error"); #endif int __kern_trace_error(const int error, const char *file, const int line) { if (error != error2trace && error != error2trace_once) return (error); if (error == error2trace_once) error2trace_once = 0; if (syslog) log(LOG_DEBUG, "Error %d at %s:%u\n", error, file, line); #ifdef KDB if (backtrace) kdb_backtrace(); #endif return (error); }