Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp695830pxb; Thu, 23 Sep 2021 08:48:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMngA1XrDC5ApYecF3U77nrJhCsywE39DIOwbGLoTXYvDkLsgKL85lUb05vGMAVa4XiV6h X-Received: by 2002:a05:6602:340a:: with SMTP id n10mr4435373ioz.188.1632412120973; Thu, 23 Sep 2021 08:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632412120; cv=none; d=google.com; s=arc-20160816; b=NUjF93eI77ChhZ7I1PZe4CT6sV98xBVstMbU1Q7oTktITvnzzYQfayCCc+6d8RXC6u ZzQNjP+dAfgWHH/B0ir12hbqO0JsiqZLyyRIMwOiEjeEjAGAd/l/hToURcgfzrizG1wW EfUZDEGtppeEfPD9KulUQbdVOW5hWa3dVvLqCWCRG30G8Vq+zvwmiqNZLmIXWnGV0Edz Fvi3CwZYIfIInwnQqBAZui1q12+Fe5yCrW2sSBnolnHiE/daU2YWim9CQyB6xnqNGck3 nhWOAc6waIKZFJuIE/IpqE1AoOEk5g3zTr/cTcBdvtskF9UbcgwpZq0WtOXc4SFCU2VU 2adQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sfRtJl4AG4lrAXgSQ/M3NhW9+Ucq7KPdX6F8ImokDLk=; b=0CoWKOePAdqg5pZsOpmg1HRB0PMJ/XuR6tBoYlgVbW/sdTTebUQi6knZW4zT6+Jg/9 zTV21XtIl3raoSv3px1XcDuIzI9Al0PPkUM9UOQ621TZMtp7RhqOfpdMNFlLsdNXXkCC g50OBhZfj62y7UB9kDRvYLUWvIB4e+L/hf7emngedZtK0isJXFs/ntkkU2QNcNs+IbN9 Ft5V37K/uSCsdtETADU+sH0i02xaZlycmm7f4jakAMifb1GqOnEH0e2VrFLQL7Ad2CDj wlzuKEgUu3+H539E9kNnSYVwbktUrygZncjs3kANKyoRDnVSWAcqCs1lOAfYZ4vJDsHy Y81Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q5GvFtut; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si5919535ilp.149.2021.09.23.08.48.27; Thu, 23 Sep 2021 08:48:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q5GvFtut; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242179AbhIWPs0 (ORCPT + 99 others); Thu, 23 Sep 2021 11:48:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:38348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242092AbhIWPnF (ORCPT ); Thu, 23 Sep 2021 11:43:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6973A60EE4; Thu, 23 Sep 2021 15:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632411693; bh=RmbGsIzi9OFhRBsPwEMh0AUPi8dAARxCMykBCofHklM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5GvFtutjvfrAtrEjL0GKjYit9jsJ6fAdJAwlUDlVACVKbAHpii/i2gWHeKk/qzYo nBZf/B9HXTp1+qEoiZjceTSbtQngx8pu/mYsgRvDR9nZC82dJQf8D0rBf5E41LD9Df XLTXYVqQc+op+C+TDVX18HDSq6PyXIxuutQrfrIsp+cpNxOfTcrsfJu8wcvcnE1Skf vlqmb+c8JjgbcObzAMGZ86WMJMDvDOMByeXjmTW6SN3zNE/CPHfljYiYV7h2XtcsRw 1JWohu2xsm4ZDjSISjwmdD4TVGyRg/7NwlId1wfTxlJXGwc7WgqSBfFBI53wWh2VGi qrpg7bWxPBtXw== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mTQqp-000p6G-O0; Thu, 23 Sep 2021 17:41:31 +0200 From: Mauro Carvalho Chehab To: #@kernel.org, YUyICHTRdfL8Ul7X@kroah.com, Linux Doc Mailing List , Greg Kroah-Hartman Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , linux-kernel@vger.kernel.org Subject: [PATCH 3/8] scripts: get_abi.pl: improve debug logic Date: Thu, 23 Sep 2021 17:41:14 +0200 Message-Id: <0203416c6c418abb4fc20577a5f48d0d2a41bae7.1632411447.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a level for debug, in order to allow it to be extended to debug other parts of the script. Signed-off-by: Mauro Carvalho Chehab --- scripts/get_abi.pl | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl index 9eb8a033d363..bb80303fea22 100755 --- a/scripts/get_abi.pl +++ b/scripts/get_abi.pl @@ -9,6 +9,7 @@ use Getopt::Long; use File::Find; use Fcntl ':mode'; use Cwd 'abs_path'; +use Data::Dumper; my $help = 0; my $hint = 0; @@ -20,13 +21,18 @@ my $prefix="Documentation/ABI"; my $sysfs_prefix="/sys"; my $search_string; +# Debug options +my $dbg_what_parsing = 1; +my $dbg_what_open = 2; +my $dbg_dump_abi_structs = 4; + # # If true, assumes that the description is formatted with ReST # my $description_is_rst = 1; GetOptions( - "debug|d+" => \$debug, + "debug=i" => \$debug, "enable-lineno" => \$enable_lineno, "rst-source!" => \$description_is_rst, "dir=s" => \$prefix, @@ -46,7 +52,7 @@ my ($cmd, $arg) = @ARGV; pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate" && $cmd ne "undefined"); pod2usage(2) if ($cmd eq "search" && !$arg); -require Data::Dumper if ($debug); +require Data::Dumper if ($debug & $dbg_dump_abi_structs); my %data; my %symbols; @@ -106,7 +112,7 @@ sub parse_abi { my @labels; my $label = ""; - print STDERR "Opening $file\n" if ($debug > 1); + print STDERR "Opening $file\n" if ($debug & $dbg_what_open); open IN, $file; while() { $ln++; @@ -178,7 +184,7 @@ sub parse_abi { $data{$what}->{filepath} .= " " . $file; } } - print STDERR "\twhat: $what\n" if ($debug > 1); + print STDERR "\twhat: $what\n" if ($debug & $dbg_what_parsing); $data{$what}->{line_no} = $ln; } else { $data{$what}->{line_no} = $ln if (!defined($data{$what}->{line_no})); @@ -827,7 +833,7 @@ if ($cmd eq "undefined" || $cmd eq "search") { # find({wanted =>\&parse_abi, no_chdir => 1}, $prefix); -print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug); +print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug & $dbg_dump_abi_structs); # # Handles the command @@ -860,7 +866,7 @@ abi_book.pl - parse the Linux ABI files and produce a ReST book. =head1 SYNOPSIS -B [--debug] [--enable-lineno] [--man] [--help] +B [--debug ] [--enable-lineno] [--man] [--help] [--(no-)rst-source] [--dir=] [--show-hints] [--search-string ] [] @@ -900,10 +906,14 @@ logic (--no-rst-source). Enable output of #define LINENO lines. -=item B<--debug> +=item B<--debug> I -Put the script in verbose mode, useful for debugging. Can be called multiple -times, to increase verbosity. +Print debug information according with the level, which is given by the +following bitmask: + + - 1: Debug parsing What entries from ABI files; + - 2: Shows what files are opened from ABI files; + - 4: Dump the structs used to store the contents of the ABI files. =item B<--show-hints> -- 2.31.1