WARN_ON() and BUG_ON() macros for run-time assertions.dump_stack().Makefile to enable pr_debug(), dev_dbg() and friends based output in kernel ring buffer:CFLAGS_<basename>.o := -DDEBUG
ccflags-y += -DDEBUG
See this Wiki page how to show such messages.
preempt_disable().irqs_disabled() and in_interrupt() are very helpful regarding protection of non-preemptive code (see also the comments at Stack Overflow).