Search code examples
clinuxlinux-kernelkernelkgdb

How to Check Kgdb is enabled or not?


I have a kernel image and would like to debug with kgdb. The .config also not available, otherwise I could check the flags in it.

In /proc/sys/ folder also there is no entry about kgdb.

Is there any way to check whether that image is kgdb enabled or not?


Solution

  • If your kernel image was compiled with the options

    CONFIG_IKCONFIG=y
    CONFIG_IKCONFIG_PROC=y
    

    then you can get the kernel image's configuration from /proc/config.gz or by using

    /pathtokernelsource/scripts/extract-ikconfig pathtokernelimage > /tmp/config

    From there you can search for CONFIG_KGDB using grep or zgrep depending on whether you are viewing the compressed or uncompressed configuration file.

    /pathtokernelsource/scripts/extract-vmlinux pathtokernelimage > /tmp/vmlinux will also extract the vmlinux executable from the image.

    If this has symbols them you can search for kgdb_arch_init or kgdb_arch_* in either the output of nm on this file or in the System.map for your kernel image as Mats Petersson mentioned in the comments.