Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Debugging Linux Kernel in Deep - Part 2
Rating: 4.6 out of 5(135 ratings)
2,695 students

Debugging Linux Kernel in Deep - Part 2

KGDB, KDB, GDB
Created byLinux Trainer
Last updated 9/2021
English
English [Auto],

What you'll learn

  • Debugging Linux Kernel Using KGDB
  • KGDB on Raspberry Pi3

Course content

4 sections41 lectures3h 5m total length
  • Introduction1:51

    Learn remote debugging of the Linux kernel via a client-server setup, using a gdb server on the target and a development machine running Jilib to set breakpoints and inspect memory.

  • Hardware Requirements for Running Kgdb2:42

    Configure two machines, a host development machine and a target VM running Linux with symbols and debug info, to run kgdb via gdb; ensure kernel patch for mainline support.

  • Hardware Setup7:51

    Set up two virtual machines (development host and target) with a serial port connection, start the target first, and verify bidirectional serial communication.

  • Installing Kernel on Target9:52

    Set up two connected virtual machines, compile the kernel with cagily support, configure the target for debug mode, and connect from the development host to the target.

  • Copying Kernel from Target to Development Machine4:35

    Copy kernel and debug symbols from the target to development machine after downloading the source on both machines. Ensure network connectivity and set the target to run in debug mode.

  • Booting with gdb support4:13

    Enable gdb support in the boot process, attach to the target via gdb, set breakpoints, and verify the boot sequence and driver startup using the chosen bootloader.

  • Connecting to Target1:58

    Connect to the target or serial port using the target command, then continue execution on the remote target to perform a backtrace and debug the kernel.

  • Disabling Kernel Address Layout Randomization3:21

    Disable kernel address space layout randomization to reveal function addresses during debugging. Use the no casula flag on the target machine, observe backtrace and breakpoint behavior.

  • Adding breakpoint1:51

    Add and verify breakpoints in kernel debugging, step through read operations, observe buffer and file descriptor values, inspect breakpoint hits, and continue to completion.

  • Switching to debugging mode5:07

    Switch back into debugging mode by sending the sissako sequence or invoking the exported break point function, enabling breakpoint execution and live kernel debugging.

Requirements

  • Should have basic knowledge of Linux Kernel

Description

User space processes can be debugged using gdb. With gdb you can

  • single-step,

  • stop,

  • resume,

  • put break-points,

  • inspect memory and variables,

  • look through call stack information

What if we can use gdb on running Linux Kernel.

Problem:

How can a gdb debug running kernel as it is just a user space process.

Solution:

Client/Server Architecture

User space programs can be debugged remotely using the combination of gdbserver on the target machine and gdb on the host machine/development machine.

The Linux kernel has a GDB Server implementation called KGDB. It communicates with a GDB client over network or serial port connection

In this course we will learn:

  • How to setup KGDB

  • Various ways of getting the target into development machine

  • Setting Breakpoints

  • Printing and Setting Variables

  • Using a single serial port for both kgdb and console messages

  • Getting the kernel messages in gdb window

  • Debugging Linux Kernel Modules (In-Tree, out of tree)

  • Use of GDB Scripts present in the Linux Kernel

Who this course is for:

  • Kernel developers interested to learn various debugging techniques