qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [Tracing] [PATCH 2/4] Add copyright and doc comments to sim


From: Stefan Hajnoczi
Subject: [Qemu-devel] [Tracing] [PATCH 2/4] Add copyright and doc comments to simpletrace.py
Date: Thu, 22 Jul 2010 16:58:44 +0100

Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 simpletrace.py |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/simpletrace.py b/simpletrace.py
index 2271860..c951023 100755
--- a/simpletrace.py
+++ b/simpletrace.py
@@ -1,4 +1,14 @@
 #!/usr/bin/env python
+#
+# Pretty-printer for simple trace backend binary trace files
+#
+# Copyright IBM, Corp. 2010
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+# For help see docs/tracing.txt
+
 import sys
 import struct
 import re
@@ -8,7 +18,10 @@ trace_len = struct.calcsize(trace_fmt)
 event_re  = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\)\s+"([^"]*)"')
 
 def parse_events(fobj):
+    """Parse a trace-events file."""
+
     def get_argnames(args):
+        """Extract argument names from a parameter list."""
         return tuple(arg.split()[-1].lstrip('*') for arg in args.split(','))
 
     events = {}
@@ -27,17 +40,21 @@ def parse_events(fobj):
     return events
 
 def read_record(fobj):
+    """Deserialize a trace record from a file."""
     s = fobj.read(trace_len)
     if len(s) != trace_len:
         return None
     return struct.unpack(trace_fmt, s)
 
 class Formatter(object):
+    """Trace record pretty-printer"""
+
     def __init__(self, events):
         self.events = events
         self.last_timestamp = None
 
     def format_record(self, rec):
+        """Return a string describing a given trace record."""
         if self.last_timestamp is None:
             self.last_timestamp = rec[1]
         delta_ns = rec[1] - self.last_timestamp
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]