Skip to contentSkip to conversation

Kconfig.debug: split debug-level and DWARF-version into separate choices

PATCH In review Masahiro Yamada 3 participants 4 messages Sep 30, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Kconfig.debug: split debug-level and DWARF-version into separate choices

Commit f9b3cd245784 ("Kconfig.debug: make DEBUG_INFO selectable from a choice") added CONFIG_DEBUG_INFO_NONE into the DWARF version choice, but it should rather belong to the debug level choice.

This commit cosolidates CONFIG options into two choices:

- Debug info level (NONE / REDUCED / DEFAULT)

- DWARF format (DWARF_TOOLCHAIN_DEFAULT / DWARF4 / DWARF5)

This is more consistent with compilers' policy because the -g0 compiler flag means "no debug info".

GCC manual:

-g<level>

Request debugging information and also use level to specify how much information. The default level is 2.

Level 0 produces no debug information at all. Thus, -g0 negates -g.

Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.

Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.

Rustc Codegen manual:

debuginfo

This flag controls the generation of debug information. It takes one of the following values:

0: no debug info at all (the default).
1: line tables only.
2: full debug info.

I moved CONFIG_DEBUG_INFO_REDUCED into the debug level choice.

This change will make it easier to add another debug info level if necessary.

---

 lib/Kconfig.debug | 60 +++++++++++++++++++++++++++++------------------
 1 file changed, 37 insertions(+), 23 deletions(-)
lib/Kconfig.debug +37 -23
index d3e5f36bb01e..03e75a54be6c 100644
@@ -232,17 +232,11 @@ config DEBUG_INFO
 	  information will be generated for build targets.
 
 choice
-	prompt "Debug information"
+	prompt "Debug information level"
 	depends on DEBUG_KERNEL
 	help
 	  Selecting something other than "None" results in a kernel image
 	  that will include debugging info resulting in a larger kernel image.
-	  This adds debug symbols to the kernel and modules (gcc -g), and
-	  is needed if you intend to use kernel crashdump or binary object
-	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
-
-	  Choose which version of DWARF debug info to emit. If unsure,
-	  select "Toolchain default".
 
 config DEBUG_INFO_NONE
 	bool "Disable debug information"
@@ -250,9 +244,41 @@ config DEBUG_INFO_NONE
 	  Do not build the kernel with debugging information, which will
 	  result in a faster and smaller build.
 
+config DEBUG_INFO_REDUCED
+	bool "Reduced debugging information"
+	select DEBUG_INFO
+	help
+	  If you say Y here compiler is instructed to generate less debugging
+	  information for structure types. This means that tools that
+	  need full debugging information (like kgdb or systemtap) won't
+	  be happy. But if you merely need debugging information to
+	  resolve line numbers there is no loss. Advantage is that
+	  build directory object sizes shrink dramatically over a full
+	  DEBUG_INFO build and compile times are reduced too.
+	  Only works with newer gcc versions.
+
+config DEBUG_INFO_DEFAULT
+	bool "Default-level debugging information"
+	select DEBUG_INFO
+	help
+	  If you say Y here compiler is instructed to generate the default
+	  level of debugging information.
+
+	  This adds debug symbols to the kernel and modules (gcc -g), and
+	  is needed if you intend to use kernel crashdump or binary object
+	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
+
+endchoice # "Debug information level"
+
+choice
+	prompt "DWARF version"
+	depends on DEBUG_INFO
+	prompt "DWARF version"
+	help
+	  Which version of DWARF debug info to emit.
+
 config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 	bool "Rely on the toolchain's implicit default DWARF version"
-	select DEBUG_INFO
 	help
 	  The implicit default version of DWARF debug info produced by a
 	  toolchain changes over time.
@@ -261,9 +287,10 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
 	  support newer revisions, and prevent testing newer versions, but
 	  those should be less common scenarios.
 
+	  If unsure, say Y.
+
 config DEBUG_INFO_DWARF4
 	bool "Generate DWARF Version 4 debuginfo"
-	select DEBUG_INFO
 	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
 	help
 	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
@@ -275,7 +302,6 @@ config DEBUG_INFO_DWARF4
 
 config DEBUG_INFO_DWARF5
 	bool "Generate DWARF Version 5 debuginfo"
-	select DEBUG_INFO
 	depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
 	help
 	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
@@ -290,22 +316,10 @@ config DEBUG_INFO_DWARF5
 	  config if they rely on tooling that has not yet been updated to
 	  support DWARF Version 5.
 
-endchoice # "Debug information"
+endchoice # "DWARF version"
 
 if DEBUG_INFO
 
-config DEBUG_INFO_REDUCED
-	bool "Reduce debugging information"
-	help
-	  If you say Y here gcc is instructed to generate less debugging
-	  information for structure types. This means that tools that
-	  need full debugging information (like kgdb or systemtap) won't
-	  be happy. But if you merely need debugging information to
-	  resolve line numbers there is no loss. Advantage is that
-	  build directory object sizes shrink dramatically over a full
-	  DEBUG_INFO build and compile times are reduced too.
-	  Only works with newer gcc versions.
-
 config DEBUG_INFO_COMPRESSED
 	bool "Compressed debugging information"
 	depends on $(cc-option,-gz=zlib)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 101 lines · Masahiro Yamada

Commit f9b3cd245784 ("Kconfig.debug: make DEBUG_INFO selectable from a choice") added CONFIG_DEBUG_INFO_NONE into the DWARF version choice, but it should rather belong to the debug level choice.

This commit cosolidates CONFIG options into two choices:

- Debug info level (NONE / REDUCED / DEFAULT)

- DWARF format (DWARF_TOOLCHAIN_DEFAULT / DWARF4 / DWARF5)

This is more consistent with compilers' policy because the -g0 compiler flag means "no debug info".

GCC manual:

-g<level>

Request debugging information and also use level to specify how much information. The default level is 2.

Level 0 produces no debug information at all. Thus, -g0 negates -g.

Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.

Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.

Rustc Codegen manual:

debuginfo

This flag controls the generation of debug information. It takes one of the following values:

0: no debug info at all (the default).
1: line tables only.
2: full debug info.

I moved CONFIG_DEBUG_INFO_REDUCED into the debug level choice.

This change will make it easier to add another debug info level if necessary.

---

 lib/Kconfig.debug | 60 +++++++++++++++++++++++++++++------------------
 1 file changed, 37 insertions(+), 23 deletions(-)
lib/Kconfig.debug +21 -7
index d3e5f36bb01e..03e75a54be6c 100644
@@ -232,17 +232,11 @@ config DEBUG_INFO
          information will be generated for build targets.
 
 choice
-       prompt "Debug information"
+       prompt "Debug information level"
        depends on DEBUG_KERNEL
        help
          Selecting something other than "None" results in a kernel image
          that will include debugging info resulting in a larger kernel image.
-         This adds debug symbols to the kernel and modules (gcc -g), and
-         is needed if you intend to use kernel crashdump or binary object
-         tools like crash, kgdb, LKCD, gdb, etc on the kernel.
-
-         Choose which version of DWARF debug info to emit. If unsure,
-         select "Toolchain default".
 
 config DEBUG_INFO_NONE
        bool "Disable debug information"
@@ -250,9 +244,41 @@ config DEBUG_INFO_NONE
          Do not build the kernel with debugging information, which will
          result in a faster and smaller build.
 
+config DEBUG_INFO_REDUCED
+       bool "Reduced debugging information"
+       select DEBUG_INFO
+       help
+         If you say Y here compiler is instructed to generate less debugging
+         information for structure types. This means that tools that
+         need full debugging information (like kgdb or systemtap) won't
+         be happy. But if you merely need debugging information to
+         resolve line numbers there is no loss. Advantage is that
+         build directory object sizes shrink dramatically over a full
+         DEBUG_INFO build and compile times are reduced too.
+         Only works with newer gcc versions.
+
+config DEBUG_INFO_DEFAULT
+       bool "Default-level debugging information"
+       select DEBUG_INFO
+       help
+         If you say Y here compiler is instructed to generate the default
+         level of debugging information.
+

lib/Kconfig.debug config DEBUG_INFO_NONE · line 276

Quoted 10 lines
lib/Kconfig.debug +10 -0
+         This adds debug symbols to the kernel and modules (gcc -g), and
+         is needed if you intend to use kernel crashdump or binary object
+         tools like crash, kgdb, LKCD, gdb, etc on the kernel.
+
+endchoice # "Debug information level"
+
+choice
+       prompt "DWARF version"
+       depends on DEBUG_INFO
+       prompt "DWARF version"

Nit.
The same prompt appears twice.
I will drop one.

Signature · 2 lines
Best Regards
Masahiro Yamada
Reviewed-by on v1 1/1
#2 lore raw
In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

Commit f9b3cd245784 ("Kconfig.debug: make DEBUG_INFO selectable from a choice") added CONFIG_DEBUG_INFO_NONE into the DWARF version choice, but it should rather belong to the debug level choice.

This commit cosolidates CONFIG options into two choices:

s/cosolidates/consolidates/

Quoted 37 lines

- Debug info level (NONE / REDUCED / DEFAULT)

- DWARF format (DWARF_TOOLCHAIN_DEFAULT / DWARF4 / DWARF5)

This is more consistent with compilers' policy because the -g0 compiler flag means "no debug info".

GCC manual:

-g<level>

Request debugging information and also use level to specify how much information. The default level is 2.

Level 0 produces no debug information at all. Thus, -g0 negates -g.

Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.

Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.

Rustc Codegen manual:

debuginfo

This flag controls the generation of debug information. It takes one of the following values:

0: no debug info at all (the default).
1: line tables only.
2: full debug info.

Quoted 6 lines

I moved CONFIG_DEBUG_INFO_REDUCED into the debug level choice.

This change will make it easier to add another debug info level if necessary.

SGTM; thanks for the patch!

Quoted 118 lines

---

 lib/Kconfig.debug | 60 +++++++++++++++++++++++++++++------------------
 1 file changed, 37 insertions(+), 23 deletions(-)
lib/Kconfig.debug +37 -24
index d3e5f36bb01e..03e75a54be6c 100644
@@ -232,17 +232,11 @@ config DEBUG_INFO
          information will be generated for build targets.
 
 choice
-       prompt "Debug information"
+       prompt "Debug information level"
        depends on DEBUG_KERNEL
        help
          Selecting something other than "None" results in a kernel image
          that will include debugging info resulting in a larger kernel image.
-         This adds debug symbols to the kernel and modules (gcc -g), and
-         is needed if you intend to use kernel crashdump or binary object
-         tools like crash, kgdb, LKCD, gdb, etc on the kernel.
-
-         Choose which version of DWARF debug info to emit. If unsure,
-         select "Toolchain default".
 
 config DEBUG_INFO_NONE
        bool "Disable debug information"
@@ -250,9 +244,41 @@ config DEBUG_INFO_NONE
          Do not build the kernel with debugging information, which will
          result in a faster and smaller build.
 
+config DEBUG_INFO_REDUCED
+       bool "Reduced debugging information"
+       select DEBUG_INFO
+       help
+         If you say Y here compiler is instructed to generate less debugging
+         information for structure types. This means that tools that
+         need full debugging information (like kgdb or systemtap) won't
+         be happy. But if you merely need debugging information to
+         resolve line numbers there is no loss. Advantage is that
+         build directory object sizes shrink dramatically over a full
+         DEBUG_INFO build and compile times are reduced too.
+         Only works with newer gcc versions.
+
+config DEBUG_INFO_DEFAULT
+       bool "Default-level debugging information"
+       select DEBUG_INFO
+       help
+         If you say Y here compiler is instructed to generate the default
+         level of debugging information.
+
+         This adds debug symbols to the kernel and modules (gcc -g), and
+         is needed if you intend to use kernel crashdump or binary object
+         tools like crash, kgdb, LKCD, gdb, etc on the kernel.
+
+endchoice # "Debug information level"
+
+choice
+       prompt "DWARF version"
+       depends on DEBUG_INFO
+       prompt "DWARF version"
+       help
+         Which version of DWARF debug info to emit.
+
 config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
        bool "Rely on the toolchain's implicit default DWARF version"
-       select DEBUG_INFO
        help
          The implicit default version of DWARF debug info produced by a
          toolchain changes over time.
@@ -261,9 +287,10 @@ config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
          support newer revisions, and prevent testing newer versions, but
          those should be less common scenarios.
 
+         If unsure, say Y.
+
 config DEBUG_INFO_DWARF4
        bool "Generate DWARF Version 4 debuginfo"
-       select DEBUG_INFO
        depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
        help
          Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
@@ -275,7 +302,6 @@ config DEBUG_INFO_DWARF4
 
 config DEBUG_INFO_DWARF5
        bool "Generate DWARF Version 5 debuginfo"
-       select DEBUG_INFO
        depends on !CC_IS_CLANG || (CC_IS_CLANG && (AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)))
        help
          Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
@@ -290,22 +316,10 @@ config DEBUG_INFO_DWARF5
          config if they rely on tooling that has not yet been updated to
          support DWARF Version 5.
 
-endchoice # "Debug information"
+endchoice # "DWARF version"
 
 if DEBUG_INFO
 
-config DEBUG_INFO_REDUCED
-       bool "Reduce debugging information"
-       help
-         If you say Y here gcc is instructed to generate less debugging
-         information for structure types. This means that tools that
-         need full debugging information (like kgdb or systemtap) won't
-         be happy. But if you merely need debugging information to
-         resolve line numbers there is no loss. Advantage is that
-         build directory object sizes shrink dramatically over a full
-         DEBUG_INFO build and compile times are reduced too.
-         Only works with newer gcc versions.
-
 config DEBUG_INFO_COMPRESSED
        bool "Compressed debugging information"
        depends on $(cc-option,-gz=zlib)
--

2.34.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
Acked-by on v1 1/1
#3 lore raw
In reply to Masahiro Yamada
Quoted 11 lines · Masahiro Yamada

Rustc Codegen manual:

debuginfo

This flag controls the generation of debug information. It takes one of the following values:

0: no debug info at all (the default).
1: line tables only.
2: full debug info.

Thanks for including Rust here! :)

Quoted 1 line

+ Only works with newer gcc versions.

Unrelated, but in a future patch it would be useful for users to say which versions.

Cheers,
Miguel