“Explore how to remotely debug a FreeBSD kernel that is running on a target machine without affecting system performance. In this article, examine setting up the debug environment using serial communication port, compiling modified kernel code, debugging, and troubleshooting tips.”
Remote Kernel Debugging in FreeBSD Using Serial Communication
Submitted by anonymous 2007-03-11 FreeBSD 3 Comments
Article provides very general info about that, in depth info and documentation can be found in FreeBSD Handbook if someone is more interested:
Also the article describes old generally unused method of building kernel:
# make depend
# make install
Now this schema is preferred:
# cd /usr/src
# make buildkernel
# make installkernel KODIR=/boot/TESTING
# nextboot -k TESTING
Edited 2007-03-11 21:25
personally, I found the article very interesting, but I think the author is not up to date regarding kernel compilation in FreeBSD. The section “Modifying kernel files” leaves no evidence which FreeBSD version he refers to.
While his suggestions still work with any FreeBSD from 4 up to 6, the procedure he introduced is from the FreeBSD 4 era and is not usually used today (with FreeBSD 6).
Don’t get me wrong, I like the article, but I also would like to make a few notes.
1. The author mentiones only vi and emacs as my favourite editor, but my favourite editor is the mcedit from the Midnight Commander suite. 🙂
2. Regarding the the serial port communication for kernel debugging, the author suggests to enter the following line:
device sio0 at isa? port IO_COM1 flags 0x80
This does not conform to the kernel config file layout in FreeBSD since version 5. Furthermore, the serial driver sio is part of the GENERIC kernel profile and does not need to be added.
since FreeBSD 5, the appendix
at isa? port IO_COM1 flags 0x80
does no longer reside in the kernel config file. It can be set dnamically in /boot/device.hints or statically in /sys/i386/conf/MYKERNEL.hints as follows:
Judging from the standard installation, only a change in flags from 0x10 to 0x80 appears.
3. The call of config, make depend etc. is no longer needed. This mechanism is controlled by the Makefile in /usr/src.
$ cd /usr/src/sys/i386/conf/
$ config -g MYKERNEL
$ cd /usr/src/sys/compile/MYKERNEL/
$ make depend
$ make install[/i]
the new way is:
# cd /usr/src
# make buildkernel KERNCONF=MYKERNEL
# make installkernel KERNCONF=MYKERNEL
This will perform the config and depend steps as well. The only thing I don’t know exactly is how to set the “config -g” effect, maybe there’s a special macro or option for this.
Please remember: The procedure the author provided will still work. See the FreeBSD handbook sections at http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelcon… for more information.
4. Note that all operations above need root privileges because there are write operations inside /usr/src.