linux-image-debugパッケージの問題

昨日気づいたのですが、Ubuntuカーネルデバッグ情報パッケージ(kernel-image-debug)には、カーネル自体のデバッグ情報は入っていますが、カーネルのドライバ(モジュール)のデバッグ情報は入っていないようです。

$ dpkg -L linux-image-debug-2.6.24-21-386
/.
/boot
/boot/vmlinux-debug-2.6.24-21-386
/usr
/usr/share
/usr/share/doc
/usr/share/doc/linux-image-debug-2.6.24-21-386
/usr/share/doc/linux-image-debug-2.6.24-21-386/copyright
/usr/share/doc/linux-image-debug-2.6.24-21-386/changelog.Debian.gz

一応、SystemtapWiki上でもDebianについてはないことが明言されていました。

Debian kernels do not contain debug information and there is no automatic way of installing or producing separate -dbg packages as RedHat has. Thus, there is no escape: you will have to manually configure and build a new kernel image package.

仕方がないので、Ubuntuドキュメントなどを参考に、カーネルコンパイルします。上記ドキュメントでは、

If you re-used the existing configuration, note that Ubuntu kernels build with debugging information on, which makes the resulting kernel modules (*.ko files) much larger than they would otherwise be. To turn this off, go into "Kernel hacking"; then, under "Kernel debugging", turn OFF "Compile the kernel with debug info".

と、書かれていますが、今欲しいのはまさにこの"debug info"なので、コンフィグは変えずに、そのままmake-kpkgコマンドを使って再構築しました。

$ sudo aptitude install kernel-package
$ sudo apt-get build-dep linux-image-generic
$ apt-get source linux-image-2.6.24-21-generic
$ cd linux-2.6.24/
$ UBUNTUBUILD=1 DEBIAN_SRCTOP=~/linux-2.6.24/ sudo make-kpkg --subarch i686 --arch-in-name --initrd kernel-image
$ sudo dpkg -i ../linux-image-2.6.24.3-i686_2.6.24-21.42_i386.deb

とりあえず、いろいろ試行錯誤したら、上記のようにしてパッケージは作れました。
ただ、残念なことに手元のPCはNvidiaビデオチップを使っているので、このままだとまともに動いてくれませんでした。

そこで無理を承知で、ドライバだけを入れ替えることにしました。

$ cd linux-2.6.24/
$ make -C "/lib/modules/2.6.24-21-generic/build" M="$PWD/net/bluetooth/" modules

例えばこのようにすると、bluetooth関連のモジュールをすべて現在のカーネル(2.6.24-21-generic)向けに作り直してくれます。作り直したモジュールはデバッグ情報をもっていますので、あとは元々インストールされているモジュールを置き換えてやればOKです。