Skip to content

Commit 61439c4

Browse files
mchehabgregkh
authored andcommitted
scripts: get_abi.pl: Allow optionally record from where a line came from
The get_abi.pl reads a lot of files and can join them on a single output file. Store where each "What:" output came from, in order to be able to optionally display it. This is useful for the Sphinx extension, with can now be able to blame what ABI file has issues, and on what line the What: description with problems begin. Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/befc387011c5e3c6febd285b7f27610e41c90260.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e9bca89 commit 61439c4

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

scripts/get_abi.pl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
my $help;
1111
my $man;
1212
my $debug;
13+
my $enable_lineno;
1314
my $prefix="Documentation/ABI";
1415

1516
#
@@ -19,6 +20,7 @@
1920

2021
GetOptions(
2122
"debug|d+" => \$debug,
23+
"enable-lineno" => \$enable_lineno,
2224
"rst-source!" => \$description_is_rst,
2325
"dir=s" => \$prefix,
2426
'help|?' => \$help,
@@ -67,6 +69,7 @@ sub parse_abi {
6769
$data{$nametag}->{file} = $name;
6870
$data{$nametag}->{filepath} = $file;
6971
$data{$nametag}->{is_file} = 1;
72+
$data{$nametag}->{line_no} = 1;
7073

7174
my $type = $file;
7275
$type =~ s,.*/(.*)/.*,$1,;
@@ -126,6 +129,8 @@ sub parse_abi {
126129
if ($tag ne "" && $new_tag) {
127130
$tag = $new_tag;
128131

132+
$data{$what}->{line_no} = $ln;
133+
129134
if ($new_what) {
130135
@{$data{$what}->{label}} = @labels if ($data{$nametag}->{what});
131136
@labels = ();
@@ -221,6 +226,12 @@ sub output_rest {
221226
my $file = $data{$what}->{file};
222227
my $filepath = $data{$what}->{filepath};
223228

229+
if ($enable_lineno) {
230+
printf "#define LINENO %s%s#%s\n\n",
231+
$prefix, $data{$what}->{file},
232+
$data{$what}->{line_no};
233+
}
234+
224235
my $w = $what;
225236
$w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
226237

@@ -369,6 +380,10 @@ sub search_symbols {
369380
}
370381
}
371382

383+
# Ensure that the prefix will always end with a slash
384+
# While this is not needed for find, it makes the patch nicer
385+
# with --enable-lineno
386+
$prefix =~ s,/?$,/,;
372387

373388
#
374389
# Parses all ABI files located at $prefix dir
@@ -395,7 +410,8 @@ =head1 NAME
395410
396411
=head1 SYNOPSIS
397412
398-
B<abi_book.pl> [--debug] [--man] [--help] --[(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>]
413+
B<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help]
414+
[--(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>]
399415
400416
Where <COMMAND> can be:
401417
@@ -425,6 +441,10 @@ =head1 OPTIONS
425441
plain text that may be violating ReST spec, so it requres some escaping
426442
logic (--no-rst-source).
427443
444+
=item B<--enable-lineno>
445+
446+
Enable output of #define LINENO lines.
447+
428448
=item B<--debug>
429449
430450
Put the script in verbose mode, useful for debugging. Can be called multiple

0 commit comments

Comments
 (0)