2012-04-04 02:47:55 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Stderr built-in backend.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
|
|
|
|
__copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
|
|
|
|
__license__ = "GPL version 2 or (at your option) any later version"
|
|
|
|
|
|
|
|
__maintainer__ = "Stefan Hajnoczi"
|
|
|
|
__email__ = "stefanha@linux.vnet.ibm.com"
|
|
|
|
|
|
|
|
|
|
|
|
from tracetool import out
|
|
|
|
|
|
|
|
|
2013-03-05 21:47:26 +08:00
|
|
|
PUBLIC = True
|
|
|
|
|
|
|
|
|
2012-04-04 02:47:55 +08:00
|
|
|
def c(events):
|
2013-03-05 21:48:00 +08:00
|
|
|
pass
|
2012-04-04 02:47:55 +08:00
|
|
|
|
|
|
|
def h(events):
|
|
|
|
out('#include <stdio.h>',
|
2013-03-05 21:48:00 +08:00
|
|
|
'#include "trace/control.h"',
|
2012-04-04 02:47:55 +08:00
|
|
|
'',
|
2013-03-05 21:48:00 +08:00
|
|
|
)
|
2012-04-04 02:47:55 +08:00
|
|
|
|
2013-03-05 21:48:00 +08:00
|
|
|
for e in events:
|
2012-04-04 02:47:55 +08:00
|
|
|
argnames = ", ".join(e.args.names())
|
|
|
|
if len(e.args) > 0:
|
|
|
|
argnames = ", " + argnames
|
|
|
|
|
|
|
|
out('static inline void trace_%(name)s(%(args)s)',
|
|
|
|
'{',
|
2013-03-05 21:48:00 +08:00
|
|
|
' bool _state = trace_event_get_state(%(event_id)s);',
|
|
|
|
' if (_state) {',
|
2012-04-04 02:47:55 +08:00
|
|
|
' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
|
|
|
|
' }',
|
|
|
|
'}',
|
|
|
|
name = e.name,
|
|
|
|
args = e.args,
|
2013-03-05 21:48:00 +08:00
|
|
|
event_id = "TRACE_" + e.name.upper(),
|
|
|
|
fmt = e.fmt.rstrip("\n"),
|
2012-04-04 02:47:55 +08:00
|
|
|
argnames = argnames,
|
|
|
|
)
|