7fb48c0ee1
The compiler encounters trace event format strings in generated code. Format strings are error-prone and therefore clear compiler errors are important. Use the #line directive to show the trace-events filename and line number in format string errors: https://gcc.gnu.org/onlinedocs/gcc-10.2.0/cpp/Line-Control.html For example, if the cpu_in trace event's %u is changed to %p the following error is reported: trace-events:29:18: error: format ‘%p’ expects argument of type ‘void *’, but argument 7 has type ‘unsigned int’ [-Werror=format=] Line 29 in trace-events is where cpu_in is defined. This works for any trace-events file in the QEMU source tree and the correct path is displayed. Unfortunately there does not seem to be a way to set the column, so "18" is not the right character on that line. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20200827142915.108730-5-stefanha@redhat.com>
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
# -*- 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"
|
|
|
|
|
|
from tracetool import out
|
|
|
|
|
|
PUBLIC = True
|
|
|
|
|
|
def generate_h_begin(events, group):
|
|
out('#include "trace/ftrace.h"',
|
|
'')
|
|
|
|
|
|
def generate_h(event, group):
|
|
argnames = ", ".join(event.args.names())
|
|
if len(event.args) > 0:
|
|
argnames = ", " + argnames
|
|
|
|
out(' {',
|
|
' char ftrace_buf[MAX_TRACE_STRLEN];',
|
|
' int unused __attribute__ ((unused));',
|
|
' int trlen;',
|
|
' if (trace_event_get_state(%(event_id)s)) {',
|
|
'#line %(event_lineno)d "%(event_filename)s"',
|
|
' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
|
|
' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
|
|
'#line %(out_next_lineno)d "%(out_filename)s"',
|
|
' trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
|
|
' unused = write(trace_marker_fd, ftrace_buf, trlen);',
|
|
' }',
|
|
' }',
|
|
name=event.name,
|
|
args=event.args,
|
|
event_id="TRACE_" + event.name.upper(),
|
|
event_lineno=event.lineno,
|
|
event_filename=event.filename,
|
|
fmt=event.fmt.rstrip("\n"),
|
|
argnames=argnames)
|
|
|
|
|
|
def generate_h_backend_dstate(event, group):
|
|
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
|
|
event_id="TRACE_" + event.name.upper())
|