qemu/scripts
Stefan Hajnoczi 59da668492 simpletrace: Make simpletrace.py a Python module
The simpletrace.py script pretty-prints a binary trace file.  Most of
the code can be reused by trace file analysis scripts, so turn it into a
module.

Here is an example script that uses the new simpletrace module:

  #!/usr/bin/env python
  # Print virtqueue elements that were never returned to the guest.

  import simpletrace

  class VirtqueueRequestTracker(simpletrace.Analyzer):
      def __init__(self):
          self.elems = set()

      def virtqueue_pop(self, vq, elem, in_num, out_num):
          self.elems.add(elem)

      def virtqueue_fill(self, vq, elem, length, idx):
          self.elems.remove(elem)

      def end(self):
          for elem in self.elems:
              print hex(elem)

  simpletrace.run(VirtqueueRequestTracker())

The simpletrace API is based around the Analyzer class.  Users implement
an analyzer subclass and add methods for trace events they want to
process.  A catchall() method is invoked for trace events which do not
have dedicated methods.  Finally, there are also begin() and end()
methods like in sed that can be used to perform setup or print
statistics at the end.

A binary trace file is processed either with:

  simpletrace.run(analyzer) # uses command-line args

or with:

  simpletrace.process('path/to/trace-events',
                      'path/to/trace-file',
                      analyzer)

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-03-06 19:06:33 +01:00
..
checkpatch.pl checkpatch.pl: don't complain about old lines with tabs 2011-02-05 13:18:20 +00:00
create_config Add scripts directory 2011-01-20 20:54:21 +00:00
feature_to_c.sh gdbstub-xml: avoid a warning from sparse 2011-01-23 11:43:25 +00:00
hxtool Add scripts directory 2011-01-20 20:54:21 +00:00
make_device_config.sh Add scripts directory 2011-01-20 20:54:21 +00:00
qemu-binfmt-conf.sh Add scripts directory 2011-01-20 20:54:21 +00:00
signrom.sh Add scripts directory 2011-01-20 20:54:21 +00:00
simpletrace.py simpletrace: Make simpletrace.py a Python module 2011-03-06 19:06:33 +01:00
texi2pod.pl Add scripts directory 2011-01-20 20:54:21 +00:00
tracetool New trace-event backend: stderr 2011-01-29 22:52:00 +00:00