debug_linux_kernel_via_gdb

ISSUE

$ gdb vmlinux
Reading symbols from vmlinux...
(No debugging symbols found in vmlinux)
(gdb)

步骤

编译具有调试信息的vmlinux和*.ko

$ cd linux/
$ make ARCH=x86 x86_64_defconfig

## based on linux2.6.34 version
$ make menuconfig
Kernel hacking  --->
    [*] Compile the kernel with debug info      ## CONFIG_DEBUG_INFO

## based on linux5.4 version
$ make menuconfig
Kernel hacking  --->
    Compile-time checks and compiler options  --->
        [*] Compile the kernel with debug info  ## CONFIG_DEBUG_INFO
Processor type and features  --->
    [ ]   Randomize the address of the kernel image (KASLR)
## OR Turn off KASLR if necessary by adding `nokaslr` to the kernel command line

$ make                                          ## 默认编译生成bzImage, vmlinux, *.ko

查看是否已经具有调试符号

开始调试内核

参考网址

Debugging kernel and modules via gdb

Last updated

Was this helpful?