How to live debug a FreeBSD kernel module?

From: <quail5101os_at_use.startmail.com>
Date: Mon, 29 Jul 2024 05:10:53 UTC
Estimated FreeBSD mailing list,  

  

I am following Joseph Kong's FreeBSD device driver's: A guide for the
intrepid. Now I am at the chapter 4, where rather than copy the example from
the bug I wrote a examples the day later which follows the same ioctl calls as
those which the books gives, except that they are named differently, but every
time that I try to run the command line utility that interacts with my ioctl
calls I get a broken ssh connection to my development Virtual Machine.
Therefore, how can I debug my kernel module?  

  

Note, that I had tried to consult the manpage ddb, kgdb, and also have tried
to run ``sysctl debug.kdb.enter=1`` from
<https://docs.freebsd.org/en/books/developers-handbook/kerneldebug/>, and
nothing have worked in my ssh session. This last may be because it is not
enabled, but the handbook page
<https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-
building> is not clear in how to compile a kernel.  

  

For <https://docs.freebsd.org/en/books/developers-
handbook/kerneldebug/#kerneldebug-online-gdb> I cannot imagine the pain of
setting from the virtual machine to the Linux Host and back to another virtual
machine, it certainly could be done with the FreeBSD guest doing nested
virtualization with bhyve, and doing the procedure with that, but no idea of
how to setup it, likewise not idea of how to setup
<https://docs.freebsd.org/en/books/developers-
handbook/kerneldebug/#kerneldebug-dcons> with bhyve.  

  

Cordially, Quail5101.