[Linux] How to Enable the CONFIG_DEBUG_INFO Option?

When compiling the Linux kernel, I usually enable the CONFIG_DEBUG_INFO option. This is because CONFIG_DEBUG_INFO ensures that the vmlinux file includes debug symbols, which are essential for debugging and analyzing the kernel.

In real-world projects, the CONFIG_DEBUG_INFO option is often enabled by development or operations engineers to help troubleshoot issues effectively. Without this option, the vmlinux file will not include the necessary debug symbols, making debugging more challenging.

Why Enable CONFIG_DEBUG_INFO?

Enabling CONFIG_DEBUG_INFO is straightforward. By applying a small patch, you can ensure this option is turned on. After applying the patch, you can verify its activation by checking the .config file.

Here is an example patch:

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index da5513cfc..ea666d7ee 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -249,12 +249,6 @@ choice
          Choose which version of DWARF debug info to emit. If unsure,
          select "Toolchain default".

-config DEBUG_INFO_NONE
-       bool "Disable debug information"
-       help
-         Do not build the kernel with debugging information, which will
-         result in a faster and smaller build.
-
config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
        bool "Rely on the toolchain's implicit default DWARF version"
        select DEBUG_INFO        

Key Details:

Purpose of the Patch:

The patch removes the option to disable debug information (DEBUG_INFO_NONE). This ensures that the kernel is built with debugging enabled by default.

How It Works:

After applying the patch, the .config file will include the necessary configuration to enable debugging.

Practical Use in Raspbian Kernel:

Note that this example is based on the Raspbian kernel source. If you are working on a Raspberry Pi, you can apply a similar approach.

Enabling CONFIG_DEBUG_INFO is a common practice that simplifies kernel debugging and helps engineers identify and resolve issues more effectively.

Sah Swapnil Agrawal

Senior Software Engineer at MIPS

3w

Sometime ago I tried to enable debug symbols in the defconfig file. So, I just went and enabled CONFIG_DEBUG_INFO in the defconfig file but still it did not have the debugging symbols. Issue was that I had not enabled another dwarf toolchain debug option as I was not aware about it. Earlier kernel version did not need that config option. But new one needed it. This would have not happened if I had used menuconfig as it already had that option. So, my takeaway from this issue is - always use menuconfig to prevent such issues.

Vijay Kumar Peshkar

Principal Engineering Manager at Qualcomm

4w

Austin Kim - good option. Adding couple of points- 1. Need to watch out for the additional memory needed especially if this is for a system with little freemem or big apps. Especially if testing for long runs 2. Performance numbers would be lower than the normal build.

To view or add a comment, sign in

Insights from the community

Others also viewed

Explore topics