This document describes setting up a QEMU virtual machine with Ubuntu 20.04.1 to debug Linux kernel code using gdb. It has a 2-socket CPU configuration with 16GB of memory and disabled KASAN and ASLR. The QEMU VM can be used to run sample code and observe Linux kernel behavior under gdb, such as setting conditional breakpoints to analyze page fault behavior for mmap addresses by referencing a gdb debugging text file.
1 of 3
Downloaded 32 times
More Related Content
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel behavior
1. * Based on kernel 6.2 (x86_64) QEMU
* 2-socket CPUs (4 cores/socket)
* 16GB memory
* Kernel parameter: nokaslr norandmaps
* KASAN: disabled
* Userspace: ASLR is disabled
* Host OS: Ubuntu 20.04.1
qemu + gdb + sample_code: Run sample code in
QEMU OS and observe Linux Kernel behavior
Adrian Huang | Apr, 2023
2. qemu + gdb: The efficient way to
understand/debug Linux kernel code/data
structure
Refer this slide first:
3. Console #2: gdb console
Console #1: QEMU: Guest OS
Observe page fault behavior about mmap address:
Conditional breakpoint
gdb-files/gdb-linux-kernel-real-mode.txt
0x7ffff7ff9000 is the mmap address provide by Linux Kernel
Reference: Memory Mapping Implementation (mmap) in Linux Kernel
Sample code to trigger the conditional breakpoint: t_mmap.c
Note