From patchwork Fri Jun 22 19:27:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Gouders X-Patchwork-Id: 10482889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB36A60388 for ; Fri, 22 Jun 2018 19:32:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9224328F74 for ; Fri, 22 Jun 2018 19:32:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8729228F7B; Fri, 22 Jun 2018 19:32:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=2.0 tests=BAYES_00, DKIM_ADSP_DISCARD, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14F2C28F78 for ; Fri, 22 Jun 2018 19:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934096AbeFVTc2 (ORCPT ); Fri, 22 Jun 2018 15:32:28 -0400 Received: from services.gouders.net ([141.101.32.176]:45330 "EHLO services.gouders.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933382AbeFVTc1 (ORCPT ); Fri, 22 Jun 2018 15:32:27 -0400 Received: from lena.gouders.net (ipservice-047-071-023-039.pools.arcor-ip.net [47.71.23.39]) (authenticated bits=0) by services.gouders.net (8.14.8/8.14.8) with ESMTP id w5MJRqZG030825 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 22 Jun 2018 21:28:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gouders.net; s=gnet; t=1529695686; bh=Lc9PgGSQ2x5aixbTfpxTEguIM9QULRZl38/DMdSJhl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OlVyoVN23XCr9x3WtmKLQlxO/zUcIzT0zd/Sibl/D1brALB3lYzjyt/FQp5SVVdXu pUwlnn9gwk3vSGkxxSDvmB8aD87HyKr2wT4xBNTBHZcwN6l/DDnvHselgFgu4H5L3h FZMbyJkGH3KC2q55E33LWLsKS0p2OuF5sROidcsI= From: Dirk Gouders To: Masahiro Yamada , Linux Kbuild mailing list Cc: Dirk Gouders , Sam Ravnborg Subject: [PATCH 3/3] kconfig: add debugconfig target for debugging purposes Date: Fri, 22 Jun 2018 21:27:39 +0200 Message-Id: <20180622192739.5327-4-dirk@gouders.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180622192739.5327-1-dirk@gouders.net> References: <20180622192739.5327-1-dirk@gouders.net> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, we need to modify existing kconfig targets to generate debugging information from the parser. That information then has to be filtered somehow, automated tests are at least complicated to implement. Add a debugconfig target for pure debugging purposes; the initial version of this target dumps the menu tree and with the --debug option activates the parsers debugging output via it's global variable cdebug. The environment variable ZCONF_DEBUG can be used to generate even more detailed debugging information. Sample output for a simple Kconfig file: $ scripts/kconfig/dconf --debug Kconfig.dconfig Kconfig.dconfig:1:config a Kconfig.dconfig:2:type(1) Kconfig.dconfig:4:endconfig Kconfig.dconfig:5:if Kconfig.dconfig:5:config b Kconfig.dconfig:6:type(1) Kconfig.dconfig:7:endconfig Kconfig.dconfig:7:endif config a bool symbol a prompt "a" config b bool symbol b prompt "b" if a endmenu Signed-off-by: Dirk Gouders Cc: Sam Ravnborg --- scripts/kconfig/Makefile | 10 ++++++++- scripts/kconfig/dconf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 scripts/kconfig/dconf.c diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index a3ac2c91331c..19906ff25392 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -4,7 +4,7 @@ # These targets are used from top-level makefile PHONY += xconfig gconfig menuconfig config syncconfig \ - localmodconfig localyesconfig + localmodconfig localyesconfig debugconfig ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) @@ -34,6 +34,9 @@ config: $(obj)/conf nconfig: $(obj)/nconf $< $(silent) $(Kconfig) +debugconfig: $(obj)/dconf + $< $(silent) $(Kconfig) + # This has become an internal implementation detail and is now deprecated # for external use. syncconfig: $(obj)/conf @@ -149,6 +152,7 @@ help: @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' + @echo ' debugconfig - Debugging tool for developers' # =========================================================================== # Shared Makefile for the various kconfig executables: @@ -165,6 +169,10 @@ targets += zconf.lex.c HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) +# dconf: Used for kconfig debugging +hostprogs-y += dconf +dconf-objs := dconf.o zconf.tab.o + # nconf: Used for the nconfig target based on ncurses hostprogs-y += nconf nconf-objs := nconf.o zconf.tab.o nconf.gui.o diff --git a/scripts/kconfig/dconf.c b/scripts/kconfig/dconf.c new file mode 100644 index 000000000000..ed1edf607d80 --- /dev/null +++ b/scripts/kconfig/dconf.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 Dirk Gouders + +#include +#include +#include + +#include "lkc.h" + +extern int cdebug; + +void usage(const char *progname); +void usage(const char *progname) +{ + printf("Usage: %s --help | [--debug] \n", progname); +} + +int main(int argc, char *argv[]) +{ + int c; + int opt_index = 0; + char *filename; + + struct option long_opts[] = { + {"debug", no_argument, NULL, 0}, + {"help", no_argument, NULL, 1}, + {0, 0, 0, 0} + }; + + while (1 ) { + c = getopt_long(argc, argv, "", long_opts, &opt_index); + + if (c == -1) + break; + if (c == 0) { + cdebug = 0x02; + } + if (c == 1) { + usage(argv[0]); + exit(EXIT_SUCCESS); + } + } + + if (optind == argc) { + usage(argv[0]); + exit(EXIT_FAILURE); + } else + filename = argv[optind]; + + conf_parse(filename); + zconfdump(stdout); + + exit(EXIT_SUCCESS); +}