Monday, February 22, 2010

Building a debug kernel on Ubuntu

I thought I would write this down before I forget it. It is quite important because without it you can't use systemtap. You can download a debug build of the Ubuntu (Debian) kernel here. Unfortunately, only the latest kernels are published, and these may not be compatible with your software. Also it is big. To build one from scratch takes time - lots of it, so don't make any mistakes! Have a cup of tea while you are waiting, and throw in some biscuits and a chat. Or go for a walk. Reckon on a hour or two, depending on your processor and disk speed.

First you have to download the kernel source tree. Then you configure it, compile it, and finally install it. The instructions are here. I used the 'Old-fashioned Debian Way' because it works. The only caveats I would add are firstly that the existing .config file you copy from /boot/config-`uname -r` already has debugging turned on, even though the kernel you are using does not! Check in the 'make menuconfig' step that the "Compile the kernel with debug info" option under "Kernel hacking"->"Kernel debugging" is turned ON if not already so. Secondly, I found that setting the number of processors as advised in the above link may have speeded it up somewhat, although contention for the hard disk may have slowed it down. I tried both and didn't notice much difference.

The only other step is to install systemtap. I recommend below that you do this from source, until the Ubuntu people rebuild the default package.

No comments:

Post a Comment