This tutorial shows how to prepare your a RedHat-based (e.g. Fedora, CentOS) Linux machine for kernel debugging without rebuilding the kernel.
Note that if you are using VisualKernel, this will be done automatically by the VisualKernel project wizard. This page provides instructions on doing it manually in order to help diagnosing common problems.
As the kernel provided by the distribution does not include sources and symbols, we will need to install the corresponding packages manually. This page provides step-by-step instructions on doing that:
- Determine the exact release and version of your kernel by running the following commands:
12uname -runame -v
In this example the release is 3.9.5 and the version number is #1.
- Before we can download the kernel symbol package we need to enable the debug repository in the system repository list. Go to the /etc/yum.repos.d directory to find out the name of your repository list file:
- Edit the file (e.g. sudo nano fedora.repo) to enable the debuginfo repository:
- Install the kernel debug package by running the following command:
1yum install kernel-debuginfo-<release>
Note that if you are running a debug kernel (installed via the kernel-debug package), you need to install the kernel-debug-debuginfo-xxx package instead.
- Find the directory with your kernel symbols under /usr/lib/debug/lib/modules and use gdb to check that the version recorded in the symbols matches the kernel version you are running:
- Find the kernel source directory for your kernel version under /usr/src/debug:
Now that you have installed and checked both symbols and sources you can use gdb to debug the kernel on your machine.
Note that if you are using VisualKernel, the symbols and sources will be automatically installed by the project wizard. See this tutorial for a detailed example.