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