Linux Kernel 01 - Debug the Linux Kernel
# Prerequisites
# Preface
# Debug with GDB
TBD.
echo "add-auto-load-safe-path path/to/linux-v.x.y/vmlinux-gdb.py" >> ~/.gdbinit
# Debug with VSCode
Create the file linux-5.15.57/.vscode/launch.json
and fill in the following code :
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "kernel-debug",
"type": "cppdbg",
"request": "launch",
"miDebuggerServerAddress": ":1234", // fill in the port corresponding to gdb
"program": "${workspaceFolder}/vmlinux",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"logging": {
"engineLogging": false
},
"MIMode": "gdb",
}
]
}
# References
Linux Kernel Documentation - Debugging kernel and modules via gdb (opens new window)
Debugging Linux kernels with Qemu and GDB (opens new window)
Teach you how to debug Linux kernel with VSCode + Qemu + GDB (opens new window)