diff options
author | Stefan Hajnoczi | 2020-08-27 16:29:15 +0200 |
---|---|---|
committer | Stefan Hajnoczi | 2021-01-04 15:24:58 +0100 |
commit | 7fb48c0ee1bbf5cc4c905e900b054096250e9f39 (patch) | |
tree | 612ce599994ea35c2a4dc9a6b490668f6743030b /scripts/tracetool/backend/syslog.py | |
parent | tracetool: add input filename and line number to Event (diff) | |
download | qemu-7fb48c0ee1bbf5cc4c905e900b054096250e9f39.tar.gz qemu-7fb48c0ee1bbf5cc4c905e900b054096250e9f39.tar.xz qemu-7fb48c0ee1bbf5cc4c905e900b054096250e9f39.zip |
tracetool: show trace-events filename/lineno in fmt string errors
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>
Diffstat (limited to 'scripts/tracetool/backend/syslog.py')
-rw-r--r-- | scripts/tracetool/backend/syslog.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py index 1373a90192..5a3a00fe31 100644 --- a/scripts/tracetool/backend/syslog.py +++ b/scripts/tracetool/backend/syslog.py @@ -35,9 +35,13 @@ def generate_h(event, group): cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) out(' if (%(cond)s) {', + '#line %(event_lineno)d "%(event_filename)s"', ' syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);', + '#line %(out_next_lineno)d "%(out_filename)s"', ' }', cond=cond, + event_lineno=event.lineno, + event_filename=event.filename, name=event.name, fmt=event.fmt.rstrip("\n"), argnames=argnames) |