aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-02-26 18:38:39 +0000
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2011-03-07 15:34:17 +0000
commit0b5538c300a56c3cfb33022840fe0b4968147e7a (patch)
tree9b60b859d24881e2d032828c3788b2171f3ceaa6 /scripts
parent07bf23a77131668ef8db37e08d508b117655ce86 (diff)
downloadqemu-0b5538c300a56c3cfb33022840fe0b4968147e7a.zip
qemu-0b5538c300a56c3cfb33022840fe0b4968147e7a.tar.gz
qemu-0b5538c300a56c3cfb33022840fe0b4968147e7a.tar.bz2
simpletrace: Thread-safe tracing
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: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/simpletrace.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py
index 9fe3dda..2ad5699 100755
--- a/scripts/simpletrace.py
+++ b/scripts/simpletrace.py
@@ -16,6 +16,7 @@ import inspect
header_event_id = 0xffffffffffffffff
header_magic = 0xf2b177cb0aa429b4
header_version = 0
+dropped_event_id = 0xfffffffffffffffe
trace_fmt = '=QQQQQQQQ'
trace_len = struct.calcsize(trace_fmt)
@@ -28,7 +29,7 @@ def parse_events(fobj):
"""Extract argument names from a parameter list."""
return tuple(arg.split()[-1].lstrip('*') for arg in args.split(','))
- events = {}
+ events = {dropped_event_id: ('dropped', 'count')}
event_num = 0
for line in fobj:
m = event_re.match(line.strip())