2013-04-11 15:25:15 +04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Ftrace built-in backend.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Eiichi Tsukata <eiichi.tsukata.xh@hitachi.com>"
|
|
|
|
__copyright__ = "Copyright (C) 2013 Hitachi, Ltd."
|
|
|
|
__license__ = "GPL version 2 or (at your option) any later version"
|
|
|
|
|
|
|
|
__maintainer__ = "Stefan Hajnoczi"
|
|
|
|
__email__ = "stefanha@redhat.com"
|
|
|
|
|
|
|
|
|
2023-04-06 11:00:45 +03:00
|
|
|
import os.path
|
|
|
|
|
2013-04-11 15:25:15 +04:00
|
|
|
from tracetool import out
|
|
|
|
|
|
|
|
|
|
|
|
PUBLIC = True
|
|
|
|
|
|
|
|
|
2016-10-04 16:35:59 +03:00
|
|
|
def generate_h_begin(events, group):
|
2013-04-11 15:25:15 +04:00
|
|
|
out('#include "trace/ftrace.h"',
|
2014-02-23 23:37:40 +04:00
|
|
|
'')
|
|
|
|
|
|
|
|
|
2016-10-04 16:35:59 +03:00
|
|
|
def generate_h(event, group):
|
2014-02-23 23:37:40 +04:00
|
|
|
argnames = ", ".join(event.args.names())
|
|
|
|
if len(event.args) > 0:
|
|
|
|
argnames = ", " + argnames
|
|
|
|
|
2017-07-04 11:50:46 +03:00
|
|
|
out(' {',
|
|
|
|
' char ftrace_buf[MAX_TRACE_STRLEN];',
|
|
|
|
' int unused __attribute__ ((unused));',
|
|
|
|
' int trlen;',
|
|
|
|
' if (trace_event_get_state(%(event_id)s)) {',
|
2020-08-27 17:29:15 +03:00
|
|
|
'#line %(event_lineno)d "%(event_filename)s"',
|
2017-07-04 11:50:46 +03:00
|
|
|
' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
|
|
|
|
' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
|
2020-08-27 17:29:15 +03:00
|
|
|
'#line %(out_next_lineno)d "%(out_filename)s"',
|
2017-07-04 11:50:46 +03:00
|
|
|
' trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
|
|
|
|
' unused = write(trace_marker_fd, ftrace_buf, trlen);',
|
2014-02-23 23:37:40 +04:00
|
|
|
' }',
|
2017-07-04 11:50:46 +03:00
|
|
|
' }',
|
2014-02-23 23:37:40 +04:00
|
|
|
name=event.name,
|
|
|
|
args=event.args,
|
|
|
|
event_id="TRACE_" + event.name.upper(),
|
2020-08-27 17:29:15 +03:00
|
|
|
event_lineno=event.lineno,
|
2023-04-06 11:00:45 +03:00
|
|
|
event_filename=os.path.relpath(event.filename),
|
2014-02-23 23:37:40 +04:00
|
|
|
fmt=event.fmt.rstrip("\n"),
|
|
|
|
argnames=argnames)
|
2017-07-31 17:07:17 +03:00
|
|
|
|
|
|
|
|
|
|
|
def generate_h_backend_dstate(event, group):
|
|
|
|
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
|
|
|
event_id="TRACE_" + event.name.upper())
|