Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2008618rwb; Sun, 14 Aug 2022 18:48:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR57xcdB1REj7gMwpNaCWLQHHSfTXsHEnKIUPu6i+UC+6IqmszsiQ+Q7cwz1qtlsR3soSHEo X-Received: by 2002:a63:131c:0:b0:427:7f15:470f with SMTP id i28-20020a63131c000000b004277f15470fmr5890383pgl.232.1660528090990; Sun, 14 Aug 2022 18:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660528090; cv=none; d=google.com; s=arc-20160816; b=fSpOeG/Mt9pT7AdUcV+JezWn5sstPZ1r8ILZ91xDHH2wh2juXad8UsutPzVmf15iX2 9xqJZc9vJanBUf4/iGG5W8awL55dyq9vIeXYwSr8UcDVAG2FoFXInkJqVOpJxwYcMfPj Tczw2e3UO48VMo+DzZee3DPXa5NRxGqwrrZeJWEz6biHeFexuvze3BaUM1BDKgKxpwlT UR4bXZcv1I8b9T6hFvw6bmTdaoLW57et/EYkDEeP1nbiDoWdfO4dd28VAtqSYy6mt0O0 jw+vGdYJkAFan3C+DG8D2CWUx4+DFi81Z1l1N5jWEms2uJ6ldy5dvHPx7RI9byxorV9S vQNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=SUz1TqPyL7KJmvxJDlgGqvLb94MqI6W6P3Guvvw/hls=; b=BSRB9mK46lM+yn58YsiamPZG1iLO2tVOg+U8WxwxTmmaHzq810gwsEgszJdnSGIZMY EBhoHldr5A43uvlV843KR5Ir6dhBLaSmnU7GCyO+SzE/eU+X+KRy6iAsypVLIkITNdC3 JxuCdA84r4cKzlb5vwZD/JUqh4HOJjV9CRLMumDH2xQ8Idp3kBtBsOAagCG2Xq/VauMW 3zykhydSnsbWIyiLIdtLuEkHa672YTdGuBgAmXzSJ3cMOfZeSU3v5M2hwL+s1jBYdsSq 0xBUxd0AUC24m7GujW0bypAN0ewNzsevqVkOnUpYnbgXJoGvK0BNU5HWKUgwlJTQ/TjV uKBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kSVveydj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a621c11000000b0052f60f7e0a1si10418747pfc.5.2022.08.14.18.47.47; Sun, 14 Aug 2022 18:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kSVveydj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbiHOBej (ORCPT + 99 others); Sun, 14 Aug 2022 21:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiHOBeh (ORCPT ); Sun, 14 Aug 2022 21:34:37 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5069C5E; Sun, 14 Aug 2022 18:34:36 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id x10so6343934ljq.4; Sun, 14 Aug 2022 18:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc; bh=SUz1TqPyL7KJmvxJDlgGqvLb94MqI6W6P3Guvvw/hls=; b=kSVveydjmJOefsqBmiJ5KB4R6JWr/+FK1rl1S8263XwJ3mXjbw7kBW7K5OCyKY2AjV UOmeUQgx8+sxaXmhnQaNSquRfteVH0+QikmFQKYIBvDTRLYjph4FvDZVxIwaZVtSlRa9 BaKC2Zn/E8GiYqBZkEXOGGIDHF8Fi2ayOpjBSBprgXTnwygYHUvsAb8PkeXU0IW0c6/U mo9yfy8Ml7TVfoCwS52nnM8QqqOPhWuFuKlIChmbXh1DnfyACneEbd1lJ8QvE1Sarorg acZver1QBUEx76udAw6L6UBaqXAuCclABv4CGBYGV0FM40bySFi3S3qe/DBGrQrU6yR4 eC9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc; bh=SUz1TqPyL7KJmvxJDlgGqvLb94MqI6W6P3Guvvw/hls=; b=5UCsWnVsHDxVdptrvbr8BLL03/ekpqoWbxgnT+bYJpbgG/vcIPbz10qpxC81djo6GR nvLM1KgcXgiJSwL1drwESfo9p7J59DjQ0Zt3wONL+5QPKeoU4cBw4p++nqcrjnDwCQf5 ZWYdat+6byZ9UaJf1MExdj9jHgkHlhMMluS66KZbnkDvZorFM8ATqE8OJYGiBl6BahqC yPY9af670HVv9FObq3m6XoDmFXVxo2uxlbu3FAaadFJEZwZm2poX366AG2oNcG8A51G9 U3T9soimeLPgEQhdIgQPrUWgbl6s8iwpBqSm/X2NYCrBtczP0zbZx/xLL7CBut6hn2h9 Uwsg== X-Gm-Message-State: ACgBeo0s/GLE5gOdNbChPnk/bEWgiMEDXjYJ44mJucjVCauFHLmq7rVZ 5B0JLgi8906xKW0kZsclehI= X-Received: by 2002:a2e:b0ec:0:b0:25e:55ec:a9c with SMTP id h12-20020a2eb0ec000000b0025e55ec0a9cmr4088993ljl.226.1660527274877; Sun, 14 Aug 2022 18:34:34 -0700 (PDT) Received: from localhost.localdomain (37-145-44-55.broadband.corbina.ru. [37.145.44.55]) by smtp.gmail.com with ESMTPSA id u1-20020ac258c1000000b0047f7722b73csm946039lfo.142.2022.08.14.18.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 18:34:34 -0700 (PDT) From: Dmitrii Bundin 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 Message-Id: <20220815013317.26121-1-dmitrii.bundin.a@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 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