There are many write-ups on the internet about debugging the kernel on macOS but many of them are outdated as hell and the NVRAM boot arguments they tell you to set are no longer working. At first, by hiding under lock and key the documentation about the debug boot arguments, and then by moving the Kernel Debug Kit under the Developer Account-only Downloads section. Unfortunately, it’s not an easy task nowadays and Apple seems to want to make it harder and harder.
Debugging the damn kernel is a very entertaining thing to do (until you provoke a serious exception, that is, and the kernel crawls into a corner from which it refuses to get out).