Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp576725pxb; Thu, 23 Sep 2021 06:32:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz16B6omIWWMAY10vH1V8FGjSPP55JSt8eZAOS56opn5ouvF9ok4NXOwnb1netcuW9qHsjE X-Received: by 2002:a05:6402:389:: with SMTP id o9mr5434419edv.213.1632403939640; Thu, 23 Sep 2021 06:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632403939; cv=none; d=google.com; s=arc-20160816; b=cFadMHHNmSDenphpnGPoVU8CrPdQ6rEjKF68WOAJJiOk9LYk+Ag5OwNlWSe8kJfONm N6YNT26BIu0naX0O1BIJk0IaMwhuyiWLSAAB2cXylhFSELzP6K1xRzqWEGfE/AmHv54G GaBrAiKgu181JmobafVKXezoIh0q5UZ7BQCOaVvNXImcI/HFItefEknGpul2N1D4DZQp lukjMs/bTHG7mJknz04MkqLJzk/owefC1WcPNsF56VhjZroqQjVvVlcqIm4CVyDTjhM8 JzgFIm7zuRNzfDFFoqDMi2bud2pmiHt1maDoW/uwX5Jrx+1ro1LzRSKP3U19VrpX+Wq8 hTqw== 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=badNOPtSAmz5kjFWOffv8okwap0tA5TVOnYgDtWgy6hM0oalb/aIuqTL2D3HJGEYac kkYR/ycyV4Ds9Pna2x31B9GW9dTd85nD7zn/aqRKKh55H5QJV0FV0gJqRMvxYDU4j43u 3AT31w4ZKrynekyZq1kGMKeR4GkusolvVas3dqwHy4m+3PEE/QBPMnxZSrWh+hYZ+Kv8 5u5chgNDm9jFvWrVbx6/P93ZMwpCR06tHgM4TO93ZEqZrtW+H6K0ZRvn52Ux783tf9Vk GnoRuxISSojuL3cFCLNUQimMCaDlkuZ1xR3vJ4R/yHT8lRrVaOW6uFC77JwRyWplO717 ksRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KC31KWbc; 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 t18si7763742edc.393.2021.09.23.06.31.54; Thu, 23 Sep 2021 06:32:19 -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=KC31KWbc; 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 S241363AbhIWNbt (ORCPT + 99 others); Thu, 23 Sep 2021 09:31:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:43972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbhIWNbq (ORCPT ); Thu, 23 Sep 2021 09:31:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B01DA6124C; Thu, 23 Sep 2021 13:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632403814; bh=RmbGsIzi9OFhRBsPwEMh0AUPi8dAARxCMykBCofHklM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KC31KWbcrvESgzS7MdKj9FQqeugaZwQ6UPml51GFYpFyWCN+Cqh6iZYvHByjcEJgu 4IxqV4cPczJWOes6sD+gQ/aUFwfNMEacg0gieXe8zfn9CQhDb2kCr1u2pcBrRsJKCz EFfzcub/EC72FjNlCEMk8/F0KZLxqBzkiSq4l6NzzpG0ltPMiKxUdl8FxP+ZRlczMI wEOdqh2/bjva9avQDHzQKmJdn+sP9uCEhyOS/JfxEaXB6WPdWOnor9oMg4ZeFsORkZ JERHjohtCguC9S9hjawwGw/KJ3Pkhl9QqxuZQFbUGiITv0Zq64nA2Ti5nInDKmCfyE AU0/fkOGvYEtQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mTOnk-000neI-VC; Thu, 23 Sep 2021 15:30:12 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Greg Kroah-Hartman Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , linux-kernel@vger.kernel.org Subject: [PATCH 08/13] scripts: get_abi.pl: improve debug logic Date: Thu, 23 Sep 2021 15:30:06 +0200 Message-Id: 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