scripts/cleanup-trace-events: Update for current practice

Emit comments with shortened file names (previous commit).

Limit search to the input file's directory.

Cope with properties tcg (commit b2b36c22bd) and vcpu (commit
3d211d9f4d).

Cope with capital letters in function names.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-id: 20190314180929.27722-4-armbru@redhat.com
Message-Id: <20190314180929.27722-4-armbru@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Markus Armbruster 2019-03-14 19:09:27 +01:00 committed by Stefan Hajnoczi
parent 500016e5db
commit a44cf524f8

View File

@ -13,6 +13,7 @@
use warnings; use warnings;
use strict; use strict;
use File::Basename;
my $buf = ''; my $buf = '';
my %seen = (); my %seen = ();
@ -23,12 +24,19 @@ sub out {
%seen = (); %seen = ();
} }
while (<>) { $#ARGV == 0 or die "usage: $0 FILE";
if (/^(disable )?([a-z_0-9]+)\(/) { my $in = $ARGV[0];
open GREP, '-|', 'git', 'grep', '-lw', "trace_$2" my $dir = dirname($in);
open(IN, $in) or die "open $in: $!";
chdir($dir) or die "chdir $dir: $!";
while (<IN>) {
if (/^(disable |(tcg) |vcpu )*([a-z_0-9]+)\(/i) {
my $pat = "trace_$3";
$pat .= '_tcg' if (defined $2);
open GREP, '-|', 'git', 'grep', '-lw', '--max-depth', '1', $pat
or die "run git grep: $!"; or die "run git grep: $!";
my $fname; while (my $fname = <GREP>) {
while ($fname = <GREP>) {
chomp $fname; chomp $fname;
next if $seen{$fname} || $fname eq 'trace-events'; next if $seen{$fname} || $fname eq 'trace-events';
$seen{$fname} = 1; $seen{$fname} = 1;
@ -49,3 +57,4 @@ while (<>) {
} }
out; out;
close(IN) or die "close $in: $!";