-#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
-__email__ = "stefanha@linux.vnet.ibm.com"
+__email__ = "stefanha@redhat.com"
import re
sys.exit(1)
+out_filename = '<none>'
+out_fobj = sys.stdout
+
+def out_open(filename):
+ global out_filename, out_fobj
+ out_filename = filename
+ out_fobj = open(filename, 'wt')
+
def out(*lines, **kwargs):
"""Write a set of output lines.
- You can use kwargs as a shorthand for mapping variables when formating all
+ You can use kwargs as a shorthand for mapping variables when formatting all
the strings in lines.
+
+ The 'out_filename' kwarg is automatically added with the output filename.
"""
- lines = [ l % kwargs for l in lines ]
- sys.stdout.writelines("\n".join(lines) + "\n")
+ output = []
+ for l in lines:
+ kwargs['out_filename'] = out_filename
+ output.append(l % kwargs)
+
+ out_fobj.writelines("\n".join(output) + "\n")
# We only want to allow standard C types or fixed sized
# integer types. We don't want QEMU specific types
"bool",
"unsigned",
"signed",
- "float",
- "double",
"int8_t",
"uint8_t",
"int16_t",
props = groups["props"].split()
fmt = groups["fmt"]
fmt_trans = groups["fmt_trans"]
+ if fmt.find("%m") != -1 or fmt_trans.find("%m") != -1:
+ raise ValueError("Event format '%m' is forbidden, pass the error "
+ "as an explicit trace argument")
+ if fmt.endswith(r'\n"'):
+ raise ValueError("Event format must not end with a newline "
+ "character")
+
if len(fmt_trans) > 0:
fmt = [fmt_trans, fmt]
args = Arguments.build(groups["args"])
events = []
for lineno, line in enumerate(fobj, 1):
+ if line[-1] != '\n':
+ raise ValueError("%s does not end with a new line" % fname)
if not line.strip():
continue
if line.lstrip().startswith('#'):
import tracetool
format = str(format)
- if len(format) is 0:
+ if len(format) == 0:
raise TracetoolError("format not set")
if not tracetool.format.exists(format):
raise TracetoolError("unknown format: %s" % format)
- if len(backends) is 0:
+ if len(backends) == 0:
raise TracetoolError("no backends specified")
for backend in backends:
if not tracetool.backend.exists(backend):