linuxubuntulinux-kernelubuntu-12.04linux-device-driver

Kernel Code : where can I find and how to debug the kernel


Recently I have installed Ubuntu 12.04 LTS ISO image in my desktop. Below is the output of the kernel version I have installed:

# uname -r
3.5.0-41-generic

I am trying to develop a VFS and want the kernel source code version '3.5.0-41-generic' for reference purpose - where can I find the same?

What are the excellent kernel debugging options looking at logs and mapping them to kernel code?

How and which debugger I can use to debug a live kernel flow execution?

Are there ways I can add more printk methods and re-modify the modules? Say I want to know how a FS mount method works - I can modify the required FS code (adding more printk functions) re-compile and reload the modules. Now with aid of my new printk functions I can understand the flow


Solution

  • Find and download kernel source code:

    sudo apt-get install linux-source
    

    This fetches the generic kernel source.

    To fetch specific version use:

    sudo apt-get source linux-image-6.11.8-generic
    

    Kernel debugging options:

    Live kernel debugging options:

    Adding printk and reloading modules:

    Note: Live kernel debugging means inspecting and modifying the Linux kernel while it is actively running.