1. 07 3月, 2011 2 次提交
    • S
      simpletrace: Thread-safe tracing · 0b5538c3
      Stefan Hajnoczi 提交于
      Trace events outside the global mutex cannot be used with the simple
      trace backend since it is not thread-safe.  There is no check to prevent
      them being enabled so people sometimes learn this the hard way.
      
      This patch restructures the simple trace backend with a ring buffer
      suitable for multiple concurrent writers.  A writeout thread empties the
      trace buffer when threshold fill levels are reached.  Should the
      writeout thread be unable to keep up with trace generation, records will
      simply be dropped.
      
      Each time events are dropped a special record is written to the trace
      file indicating how many events were dropped.  The event ID is
      0xfffffffffffffffe and its signature is dropped(uint32_t count).
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      0b5538c3
    • S
      simpletrace: Make simpletrace.py a Python module · 59da6684
      Stefan Hajnoczi 提交于
      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: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
      59da6684
  2. 21 1月, 2011 1 次提交
  3. 21 10月, 2010 1 次提交
  4. 10 9月, 2010 1 次提交
    • S
      trace: Add simple built-in tracing backend · 26f7227b
      Stefan Hajnoczi 提交于
      This patch adds a simple tracer which produces binary trace files.  To
      try out the simple backend:
      
      $ ./configure --trace-backend=simple
      $ make
      
      After running QEMU you can pretty-print the trace:
      
      $ ./simpletrace.py trace-events trace.log
      
      The output of simpletrace.py looks like this:
      
        qemu_realloc 0.699 ptr=0x24363f0 size=0x3 newptr=0x24363f0
        qemu_free 0.768 ptr=0x24363f0
        ^           ^---- timestamp delta (us)
        |____ trace event name
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      
      trace: Make trace record fields 64-bit
      
      Explicitly use 64-bit fields in trace records so that timestamps and
      magic numbers work for 32-bit host builds.
      
      Includes fixes from Prerna Saxena <prerna@linux.vnet.ibm.com>.
      Signed-off-by: NPrerna Saxena <prerna@linux.vnet.ibm.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      26f7227b