target/i386: Fix bad patch application to translate.c
[qemu/ar7.git] / scripts / cleanup-trace-events.pl
blob7e808efb6ac152089732d3f5387a60bd67d9ba65
1 #!/usr/bin/perl
2 # Copyright (C) 2013 Red Hat, Inc.
4 # Authors:
5 # Markus Armbruster <armbru@redhat.com>
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.
10 # Usage: cleanup-trace-events.pl trace-events
12 # Print cleaned up trace-events to standard output.
14 use warnings;
15 use strict;
17 my $buf = '';
18 my %seen = ();
20 sub out {
21 print $buf;
22 $buf = '';
23 %seen = ();
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;
37 unless (close GREP) {
38 die "close git grep: $!"
39 if $!;
40 next;
42 } elsif (/^# ([^ ]*\.[ch])$/) {
43 out;
44 next;
45 } elsif (!/^#|^$/) {
46 warn "unintelligible line";
48 $buf .= $_;
51 out;