acpi unit-test: resolved iasl crash
[qemu/cris-port.git] / scripts / cleanup-trace-events.pl
blobcffbf165dcf718f1089d978edc372dafe5619da1
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', '-l', "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;