bhyve enables a very simple way to do kernel debugging by tunneling gdb frames between the kgdb client and the gdb stub in the kernel.
* Compile the kernel with the device bvmdebug option
* Supply the "-g <portnum>" option to the /usr/sbin/bhyve controlling process when starting the virtual machine (/usr/share/examples/bhyve/vmrun.sh supports the "-g" option as well).
* The bhyve process will bind to <portnum> and will listen for a connection from the kgdb client on that port
* When the guest enters the debugger type gdb at the DDB prompt. For example:
* Start kgdb and instruct it to connect to a remote target. For example, if you passed the "-g 6466" to bhyve then:
- (kgdb) target remote localhost:6466