0a122b
From 5fde31188fab75d48e9a3d508ac8f9088e09bf3d Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <5fde31188fab75d48e9a3d508ac8f9088e09bf3d.1387276076.git.minovotn@redhat.com>
0a122b
In-Reply-To: <e610718166120379517e80d1a7aa12d60294209b.1387276076.git.minovotn@redhat.com>
0a122b
References: <e610718166120379517e80d1a7aa12d60294209b.1387276076.git.minovotn@redhat.com>
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Tue, 10 Dec 2013 15:12:50 +0100
0a122b
Subject: [PATCH 09/16] cleanup-trace-events.pl: New
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1386688376-29521-2-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 56112
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 1/7] cleanup-trace-events.pl: New
0a122b
Bugzilla: 997832
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
0a122b
Simple script to drop unused events and fix up source file comments.
0a122b
The next few commits put it to use.
0a122b
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit f0c03c8cf6184f25ba91449c1ff77e5e006ce514)
0a122b
---
0a122b
 scripts/cleanup-trace-events.pl | 51 +++++++++++++++++++++++++++++++++++++++++
0a122b
 1 file changed, 51 insertions(+)
0a122b
 create mode 100755 scripts/cleanup-trace-events.pl
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 scripts/cleanup-trace-events.pl | 51 +++++++++++++++++++++++++++++++++++++++++
0a122b
 1 file changed, 51 insertions(+)
0a122b
 create mode 100755 scripts/cleanup-trace-events.pl
0a122b
0a122b
diff --git a/scripts/cleanup-trace-events.pl b/scripts/cleanup-trace-events.pl
0a122b
new file mode 100755
0a122b
index 0000000..cffbf16
0a122b
--- /dev/null
0a122b
+++ b/scripts/cleanup-trace-events.pl
0a122b
@@ -0,0 +1,51 @@
0a122b
+#!/usr/bin/perl
0a122b
+# Copyright (C) 2013 Red Hat, Inc.
0a122b
+#
0a122b
+# Authors:
0a122b
+#  Markus Armbruster <armbru@redhat.com>
0a122b
+#
0a122b
+# This work is licensed under the terms of the GNU GPL, version 2 or
0a122b
+# later.  See the COPYING file in the top-level directory.
0a122b
+
0a122b
+# Usage: cleanup-trace-events.pl trace-events
0a122b
+#
0a122b
+# Print cleaned up trace-events to standard output.
0a122b
+
0a122b
+use warnings;
0a122b
+use strict;
0a122b
+
0a122b
+my $buf = '';
0a122b
+my %seen = ();
0a122b
+
0a122b
+sub out {
0a122b
+    print $buf;
0a122b
+    $buf = '';
0a122b
+    %seen = ();
0a122b
+}
0a122b
+
0a122b
+while (<>) {
0a122b
+    if (/^(disable )?([a-z_0-9]+)\(/) {
0a122b
+        open GREP, '-|', 'git', 'grep', '-l', "trace_$2"
0a122b
+            or die "run git grep: $!";
0a122b
+        my $fname;
0a122b
+        while ($fname = <GREP>) {
0a122b
+            chomp $fname;
0a122b
+            next if $seen{$fname} || $fname eq 'trace-events';
0a122b
+            $seen{$fname} = 1;
0a122b
+            $buf = "# $fname\n" . $buf;
0a122b
+        }
0a122b
+        unless (close GREP) {
0a122b
+            die "close git grep: $!"
0a122b
+                if $!;
0a122b
+            next;
0a122b
+        }
0a122b
+    } elsif (/^# ([^ ]*\.[ch])$/) {
0a122b
+        out;
0a122b
+        next;
0a122b
+    } elsif (!/^#|^$/) {
0a122b
+        warn "unintelligible line";
0a122b
+    }
0a122b
+    $buf .= $_;
0a122b
+}
0a122b
+
0a122b
+out;
0a122b
-- 
0a122b
1.7.11.7
0a122b