ThomasLovén.com

Debug Printing

31 Jan 2014

I still haven't quite caught up with all the stuff I wanted to write
about back in August, but at some point
when I started to write little userspace programs that wrote stuff to
the screen, I thought my kernel debug messages started to get in the
way.

I'm still not ready to give up debug messages from the kernel, so the
best alternative seemed to be to output them to something else, such as
a serial port.

Writing to a serial port is rather
easy, so there's no need for me to
go into detail there. I made a few changes to my emulation setup,
though, that made showing the debug messages a bit nicer.

Tmux

I've described how I use tmux with qemu, gdb and telnet
before. It was easy to add another
pane which displays the debug information, but one thing at a time.
Here's what I did in a bash script:

This opens a new tmux pane with qemu running my kernel and loading
tarfs.tar as a multiboot module. The -monitor flag starts a telnet
server for controlling the emulator. -s starts a gdb server at tcp
port 1234 and -S makes the emulator wait for a command before it
starts running the kernel. Finally, the -serial flag saves all output
from serial port 1 to a file.

The next step is:

tmux split-window -v 'tail -f serial.out | util/colorize.sh'

which opens up another tmux pane that displays the serial output using
the auto-updating feature of tail. The script colorize.sh colorizes
certain words of the output: