+#if DEBUG
+/*
+ * For the DEBUG kernel, support the following:
+ * sysctl -w debug.kprint_syscall=<syscall_mask>
+ * sysctl -w debug.kprint_syscall_process=<p_comm>
+ * <syscall_mask> should be an OR of the masks below
+ * for UNIX, MACH, MDEP, or IPC. This debugging aid
+ * assumes the task/process is locked/wired and will
+ * not go away during evaluation. If no process is
+ * specified, all processes will be traced
+ */
+extern int debug_kprint_syscall;
+extern int debug_kprint_current_process(const char **namep);
+#define DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, namep) \
+ ( (debug_kprint_syscall & (mask)) && debug_kprint_current_process(namep) )
+#define DEBUG_KPRINT_SYSCALL_MASK(mask, fmt, args...) do { \
+ const char *dks_name = NULL; \
+ if (DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, &dks_name)) { \
+ kprintf("[%s%s%p]" fmt, dks_name ? dks_name : "", \
+ dks_name ? "@" : "", current_thread(), args); \
+ } \
+ } while (0)
+#else /* !DEBUG */
+#define DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, namep) (0)
+#define DEBUG_KPRINT_SYSCALL_MASK(mask, fmt, args...) do { } while(0)
+#endif /* !DEBUG */
+
+enum {
+ DEBUG_KPRINT_SYSCALL_UNIX_MASK = 1 << 0,
+ DEBUG_KPRINT_SYSCALL_MACH_MASK = 1 << 1,
+ DEBUG_KPRINT_SYSCALL_MDEP_MASK = 1 << 2,
+ DEBUG_KPRINT_SYSCALL_IPC_MASK = 1 << 3
+};
+
+#define DEBUG_KPRINT_SYSCALL_PREDICATE(mask) \
+ DEBUG_KPRINT_SYSCALL_PREDICATE_INTERNAL(mask, NULL)
+#define DEBUG_KPRINT_SYSCALL_UNIX(fmt, args...) \
+ DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_UNIX_MASK,fmt,args)
+#define DEBUG_KPRINT_SYSCALL_MACH(fmt, args...) \
+ DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_MACH_MASK,fmt,args)
+#define DEBUG_KPRINT_SYSCALL_MDEP(fmt, args...) \
+ DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_MDEP_MASK,fmt,args)
+#define DEBUG_KPRINT_SYSCALL_IPC(fmt, args...) \
+ DEBUG_KPRINT_SYSCALL_MASK(DEBUG_KPRINT_SYSCALL_IPC_MASK,fmt,args)