]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/cleanup-trace-events.pl
i386: Make unversioned CPU models be aliases
[mirror_qemu.git] / scripts / cleanup-trace-events.pl
CommitLineData
b7d5a9c2 1#!/usr/bin/env perl
f0c03c8c
MA
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
14use warnings;
15use strict;
a44cf524 16use File::Basename;
f0c03c8c
MA
17
18my $buf = '';
19my %seen = ();
20
21sub out {
22 print $buf;
23 $buf = '';
24 %seen = ();
25}
26
a44cf524
MA
27$#ARGV == 0 or die "usage: $0 FILE";
28my $in = $ARGV[0];
29my $dir = dirname($in);
30open(IN, $in) or die "open $in: $!";
31chdir($dir) or die "chdir $dir: $!";
32
33while (<IN>) {
34 if (/^(disable |(tcg) |vcpu )*([a-z_0-9]+)\(/i) {
35 my $pat = "trace_$3";
36 $pat .= '_tcg' if (defined $2);
37 open GREP, '-|', 'git', 'grep', '-lw', '--max-depth', '1', $pat
f0c03c8c 38 or die "run git grep: $!";
a44cf524 39 while (my $fname = <GREP>) {
f0c03c8c
MA
40 chomp $fname;
41 next if $seen{$fname} || $fname eq 'trace-events';
42 $seen{$fname} = 1;
43 $buf = "# $fname\n" . $buf;
44 }
45 unless (close GREP) {
46 die "close git grep: $!"
47 if $!;
48 next;
49 }
50 } elsif (/^# ([^ ]*\.[ch])$/) {
51 out;
52 next;
53 } elsif (!/^#|^$/) {
54 warn "unintelligible line";
55 }
56 $buf .= $_;
57}
58
59out;
a44cf524 60close(IN) or die "close $in: $!";