From: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
To: masahiroy@kernel.org
Cc: akpm@linux-foundation.org, dan.j.williams@intel.com,
edumazet@google.com, isabbasso@riseup.net, jpoimboe@kernel.org,
keescook@chromium.org, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk,
dmitrii.bundin.a@gmail.com, maskray@google.com,
michal.lkml@markovi.net, nathan@kernel.org,
ndesaulniers@google.com, peterz@infradead.org, vbabka@suse.cz
Subject: [PATCH v3] kbuild: add debug level and macro defs options
Date: Mon, 15 Aug 2022 04:33:17 +0300 [thread overview]
Message-ID: <20220815013317.26121-1-dmitrii.bundin.a@gmail.com> (raw)
In-Reply-To: <CANXV_XwgZMCGXijfoUyZ9+KyM6Rgeqiq-sCfubyj_16d-2CN=A@mail.gmail.com>
Adds config options to control debug info level and producing of macro
definitions for GCC/Clang.
Option DEBUG_INFO_LEVEL is responsible for controlling debug info level.
Before GCC 11 and Clang 12 -gsplit-dwarf implicitly uses -g2. To provide
a way to override the setting with, e.g. -g1, DEBUG_INFO_LEVEL is set
independently from DEBUG_INFO_SPLIT.
Option DEBUG_MACRO_DEFINITIONS is responsible for controlling inclusion
of macro definitions. Since Clang uses -fdebug-macro to control if macro
definitions are produced which is different from GCC, provides a
compiler-specific way of handling macro inclusion. The option is handled
after DEBUG_INFO_LEVEL since -g3 -g2 implies -g2, but -g2 -g3 implies
-g3 and GCC uses -g3 to produce macro definitions.
Signed-off-by: Dmitrii Bundin <dmitrii.bundin.a@gmail.com>
---
Changes in v2: https://lore.kernel.org/all/20220804223504.4739-1-dmitrii.bundin.a@gmail.com/
- Replace hardcoded -g3 with a configurable debug info level
Changes in v3: https://lore.kernel.org/all/20220814002021.16990-1-dmitrii.bundin.a@gmail.com/
- Make -g<level> and -gdwarf-split to be set independently
- Add a separate option to control macro definitions for GCC/Clang
lib/Kconfig.debug | 20 ++++++++++++++++++++
scripts/Makefile.debug | 12 ++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2e24db4bff19..ace6f2eddb56 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -304,6 +304,26 @@ config DEBUG_INFO_REDUCED
DEBUG_INFO build and compile times are reduced too.
Only works with newer gcc versions.
+config DEBUG_INFO_LEVEL
+ int "Debug info level"
+ range 1 3
+ default "2"
+ help
+ Sets the level of how much debug information to generate (-glevel).
+ Level 1 produces minimal debug information without including information
+ about local variables. Level 3 includes extra information like macro
+ definitions. Setting up level 3 will require significantly more disk
+ space and increase built time.
+
+config DEBUG_MACRO_DEFINITIONS
+ bool "Add macro definitions to debug info"
+ default n
+ help
+ Generates macro definitions to provide a way to expand macros right
+ in the debugging session. This information can be used with macro expand,
+ info macro in gdb. This option is equivalent to setting -g3 in GCC and
+ -fdebug-macro in Clang.
+
config DEBUG_INFO_COMPRESSED
bool "Compressed debugging information"
depends on $(cc-option,-gz=zlib)
diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug
index 9f39b0130551..29cd04234e75 100644
--- a/scripts/Makefile.debug
+++ b/scripts/Makefile.debug
@@ -2,8 +2,6 @@ DEBUG_CFLAGS :=
ifdef CONFIG_DEBUG_INFO_SPLIT
DEBUG_CFLAGS += -gsplit-dwarf
-else
-DEBUG_CFLAGS += -g
endif
ifndef CONFIG_AS_IS_LLVM
@@ -16,6 +14,16 @@ dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y)
endif
+DEBUG_CFLAGS += -g$(CONFIG_DEBUG_INFO_LEVEL)
+ifdef CONFIG_DEBUG_MACRO_DEFINITIONS
+ifdef CONFIG_CC_IS_GCC
+DEBUG_CFLAGS += -g3
+endif
+ifdef CONFIG_CC_IS_CLANG
+DEBUG_CFLAGS += -fdebug-macro
+endif
+endif
+
ifdef CONFIG_DEBUG_INFO_REDUCED
DEBUG_CFLAGS += -fno-var-tracking
ifdef CONFIG_CC_IS_GCC
--
2.17.1
next prev parent reply other threads:[~2022-08-15 1:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-14 0:20 [PATCH v2] kbuild: add configurable debug info level Dmitrii Bundin
2022-08-14 2:01 ` Masahiro Yamada
2022-08-14 5:31 ` Fangrui Song
2022-08-14 18:58 ` Masahiro Yamada
2022-08-14 19:17 ` Dmitrii Bundin
2022-08-15 1:33 ` Dmitrii Bundin [this message]
2022-08-18 4:13 ` [PATCH v3] kbuild: add debug level and macro defs options Masahiro Yamada
2022-08-18 18:57 ` Dmitrii Bundin
2022-08-19 17:42 ` Nick Desaulniers
2022-08-19 22:52 ` Dmitrii Bundin
2022-08-22 16:45 ` Nick Desaulniers
2022-08-22 21:36 ` Nick Desaulniers
2022-08-22 22:42 ` Dmitrii Bundin
2022-08-24 23:25 ` Nick Desaulniers
2022-09-29 21:06 ` Masahiro Yamada
2022-09-30 9:11 ` Masahiro Yamada
2022-10-08 7:24 ` Dmitrii Bundin
2022-08-23 6:06 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220815013317.26121-1-dmitrii.bundin.a@gmail.com \
--to=dmitrii.bundin.a@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=edumazet@google.com \
--cc=isabbasso@riseup.net \
--cc=jpoimboe@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=masahiroy@kernel.org \
--cc=maskray@google.com \
--cc=michal.lkml@markovi.net \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).