use File::Find;
use Fcntl ':mode';
use Cwd 'abs_path';
+use Data::Dumper;
my $help = 0;
my $hint = 0;
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,
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;
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++;
$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}));
#
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
=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>]
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>