From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Prerna Saxena <prerna@linux.vnet.ibm.com>
Subject: [Qemu-devel] [Tracing] [PATCH 2/4] Add copyright and doc comments to simpletrace.py
Date: Thu, 22 Jul 2010 16:58:44 +0100 [thread overview]
Message-ID: <1279814326-9422-2-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1279814326-9422-1-git-send-email-stefanha@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
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
next prev parent reply other threads:[~2010-07-22 15:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 15:58 [Qemu-devel] [Tracing] [PATCH 1/4] Move simple trace prototypes to header file Stefan Hajnoczi
2010-07-22 15:58 ` Stefan Hajnoczi [this message]
2010-07-22 15:58 ` [Qemu-devel] [Tracing] [PATCH 3/4] Add a header to the trace file format Stefan Hajnoczi
2010-07-22 15:58 ` [Qemu-devel] [Tracing] [PATCH 4/4] Disable posix_aio_process_queue by default Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1279814326-9422-2-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=prerna@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).