Kernel debugging in 2025

Hi!

I am just interesting, how do you really make a kernel debugging in 2025? The documentation describes connection by serial cable, but most of current PC are shipped without COM ports.
What is used? Special USB cable (USB-3 without some wires)? Or debug in a virtual machine - sounds logical, but I do not see any descriptions how to setup kernel for debug in VM environment.
 
If you have access to the physical machine, you might be able to access serial port connection on the motherboard. I would recommend buying a mini PC that provides a serial port if you are going to be debugging kernels.

If you have a serial port you can use a "null modem" (3 wires, tx,gnd,rx on one end to rx,gnd,tx on the other end) works. Years back, @$job[-n] we had a dumb "ethernet console" driver and we could debug a kernel from any machine connected to the same local net but no such driver seems to exist today in the open source world. It used local (limited) broadcast so it wouldn't cross the local net. Shouldn't be too hard to write.

If your machine has a firewire port you can use dcons but I haven't tried this.

One you setup your kernel with option GDB & assuming bhyve works for you, you can start it with option "-G 1234", where 1234 is a tcp port number (can be any other unused port as well). Now cd to /usr/obj/usr/src/amd64.amd64/sys/TEST (where the kernel .o files exist) and start kgdb there. Within it connect via "target remote :1234" etc.

I filed a bug about broken bhyve in 15.0-ALPHA5. Just now I discovered a NetBSD VM also makes bhyve crash the same way. But FreeBSD VMs seem to work fine.
 
Back
Top