summary refs log tree commit diff stats
path: root/scripts/tracetool/backend/syslog.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-09-06 12:41:24 +0100
committerPeter Maydell <peter.maydell@linaro.org>2016-09-06 12:41:24 +0100
commit30e7d092b26146eb2abb77e0a0952aea012e36bf (patch)
tree8188256de4bf74dde49d9f048c4af3b4212b70ea /scripts/tracetool/backend/syslog.py
parent1fd66154fdf8305e6668a96046a22b863b4d7320 (diff)
parent8eb1b9db559e243043aaeac3a0aa97e1f4a403c4 (diff)
downloadfocaccia-qemu-30e7d092b26146eb2abb77e0a0952aea012e36bf.tar.gz
focaccia-qemu-30e7d092b26146eb2abb77e0a0952aea012e36bf.zip
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
# gpg: Signature made Mon 05 Sep 2016 20:41:04 BST
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/tracing-pull-request:
  trace: Avoid implicit bool->integer conversions
  trace: Remove 'trace_events_dstate_init'
  trace: add syslog tracing backend

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/tracetool/backend/syslog.py')
-rw-r--r--scripts/tracetool/backend/syslog.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
new file mode 100644
index 0000000000..89019bc759
--- /dev/null
+++ b/scripts/tracetool/backend/syslog.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+Syslog built-in backend.
+"""
+
+__author__     = "Paul Durrant <paul.durrant@citrix.com>"
+__copyright__  = "Copyright 2016, Citrix Systems Inc."
+__license__    = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__      = "stefanha@redhat.com"
+
+
+from tracetool import out
+
+
+PUBLIC = True
+
+
+def generate_h_begin(events):
+    out('#include <syslog.h>',
+        '#include "trace/control.h"',
+        '')
+
+
+def generate_h(event):
+    argnames = ", ".join(event.args.names())
+    if len(event.args) > 0:
+        argnames = ", " + argnames
+
+    if "vcpu" in event.properties:
+        # already checked on the generic format code
+        cond = "true"
+    else:
+        cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
+
+    out('        if (%(cond)s) {',
+        '            syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
+        '        }',
+        cond=cond,
+        name=event.name,
+        fmt=event.fmt.rstrip("\n"),
+        argnames=argnames)