2 # -*- coding: utf-8 -*-
5 Ftrace built-in backend.
8 __author__ = "Eiichi Tsukata <eiichi.tsukata.xh@hitachi.com>"
9 __copyright__ = "Copyright (C) 2013 Hitachi, Ltd."
10 __license__ = "GPL version 2 or (at your option) any later version"
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@redhat.com"
16 from tracetool import out
26 out('#include "trace/ftrace.h"',
27 '#include "trace/control.h"',
32 argnames = ", ".join(e.args.names())
34 argnames = ", " + argnames
36 out('static inline void trace_%(name)s(%(args)s)',
38 ' char ftrace_buf[MAX_TRACE_STRLEN];',
39 ' int unused __attribute__ ((unused));',
41 ' bool _state = trace_event_get_state(%(event_id)s);',
43 ' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
44 ' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
45 ' trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
46 ' unused = write(trace_marker_fd, ftrace_buf, trlen);',
51 event_id = "TRACE_" + e.name.upper(),
52 fmt = e.fmt.rstrip("\n"),