]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/cleanup-trace-events.pl
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
[mirror_qemu.git] / scripts / cleanup-trace-events.pl
1 #!/usr/bin/perl
2 # Copyright (C) 2013 Red Hat, Inc.
3 #
4 # Authors:
5 # Markus Armbruster <armbru@redhat.com>
6 #
7 # This work is licensed under the terms of the GNU GPL, version 2 or
8 # later. See the COPYING file in the top-level directory.
9
10 # Usage: cleanup-trace-events.pl trace-events
11 #
12 # Print cleaned up trace-events to standard output.
13
14 use warnings;
15 use strict;
16
17 my $buf = '';
18 my %seen = ();
19
20 sub out {
21 print $buf;
22 $buf = '';
23 %seen = ();
24 }
25
26 while (<>) {
27 if (/^(disable )?([a-z_0-9]+)\(/) {
28 open GREP, '-|', 'git', 'grep', '-lw', "trace_$2"
29 or die "run git grep: $!";
30 my $fname;
31 while ($fname = <GREP>) {
32 chomp $fname;
33 next if $seen{$fname} || $fname eq 'trace-events';
34 $seen{$fname} = 1;
35 $buf = "# $fname\n" . $buf;
36 }
37 unless (close GREP) {
38 die "close git grep: $!"
39 if $!;
40 next;
41 }
42 } elsif (/^# ([^ ]*\.[ch])$/) {
43 out;
44 next;
45 } elsif (!/^#|^$/) {
46 warn "unintelligible line";
47 }
48 $buf .= $_;
49 }
50
51 out;