diff options
author | Mauro Carvalho Chehab | 2021-09-23 17:41:14 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2021-09-23 18:45:08 +0200 |
commit | 46f661fd0faf7f518b6760ac15f02fa36896c126 (patch) | |
tree | b89a6adca162143275e7a4733397d7cbf14ba5a9 /scripts | |
parent | 45495db9790fd9247f31a79c433e1723a1bdf039 (diff) |
scripts: get_abi.pl: improve debug logic
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 <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/0203416c6c418abb4fc20577a5f48d0d2a41bae7.1632411447.git.mchehab+huawei@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/get_abi.pl | 28 |
1 files 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(<IN>) { $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<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help] +B<abi_book.pl> [--debug <level>] [--enable-lineno] [--man] [--help] [--(no-)rst-source] [--dir=<dir>] [--show-hints] [--search-string <regex>] <COMAND> [<ARGUMENT>] @@ -900,10 +906,14 @@ logic (--no-rst-source). Enable output of #define LINENO lines. -=item B<--debug> +=item B<--debug> I<debug level> + +Print debug information according with the level, which is given by the +following bitmask: -Put the script in verbose mode, useful for debugging. Can be called multiple -times, to increase verbosity. + - 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> |