mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
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>
This commit is contained in:
parent
4e66c9ef64
commit
7fb48c0ee1
3 changed files with 12 additions and 0 deletions
|
@ -37,12 +37,16 @@ def generate_h(event, group):
|
|||
out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {',
|
||||
' struct timeval _now;',
|
||||
' gettimeofday(&_now, NULL);',
|
||||
'#line %(event_lineno)d "%(event_filename)s"',
|
||||
' qemu_log("%%d@%%zu.%%06zu:%(name)s " %(fmt)s "\\n",',
|
||||
' qemu_get_thread_id(),',
|
||||
' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
|
||||
' %(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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue