trace: make the 'log' backend timestamp configurable
cover trace: make the 'log' backend timestamp configurable
Zoltan reminded me that the 'log' backend prints tids/timestamps and this can be unwanted in some cases. It's easier to look at trace output without them and in some cases parsing is also more convenient with them.
Extend -msg timestamp=on|off to control the 'log' backend's tid/timestamp output.
Stefan Hajnoczi (2):
error: rename error_with_timestamp to message_with_timestamp
trace: make the 'log' backend timestamp configurable
docs/devel/tracing.txt | 3 +++ include/qemu/error-report.h | 2 +- softmmu/vl.c | 2 +- util/qemu-error.c | 4 ++-- scripts/tracetool/backend/log.py | 19 +++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/2 error: rename error_with_timestamp to message_with_timestamp
The -msg timestamp=on|off option controls whether a timestamp is printed with error_report() messages. The "-msg" name suggests that this option has a wider effect than just error_report(). The next patch extends it to the 'log' trace backend, so rename the variable from error_with_timestamp to message_with_timestamp.
--- include/qemu/error-report.h | 2 +- softmmu/vl.c | 2 +- util/qemu-error.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
include/qemu/error-report.h +1 -1
@@ -74,7 +74,7 @@ void error_init(const char *argv0);const char *error_get_progname (void ); -extern bool error_with_timestamp; +extern bool message_with_timestamp;extern bool error_with_guestname;extern const char *error_guest_name;
softmmu/vl.c +1 -1
@@ -737,7 +737,7 @@ static void realtime_init(void)static void configure_msg (QemuOpts *opts) { - error_with_timestamp =qemu_opt_get_bool (opts,"timestamp" , false); + message_with_timestamp =qemu_opt_get_bool (opts,"timestamp" , false); error_with_guestname =qemu_opt_get_bool (opts,"guest-name" , false); }
util/qemu-error.c +2 -2
@@ -25,7 +25,7 @@ typedef enum { } report_type;/* Prepend timestamp to messages */ -bool error_with_timestamp; +bool message_with_timestamp;bool error_with_guestname;const char *error_guest_name;
@@ -208,7 +208,7 @@ static void vreport(report_type type, const char *fmt, va_list ap)GTimeVal tv;gchar *timestr; -if (error_with_timestamp && !monitor_cur ()) { +if (message_with_timestamp && !monitor_cur ()) {g_get_current_time (&tv); timestr =g_time_val_to_iso8601 (&tv);error_printf ("%s " , timestr);
Signature · 1 line
2.29.2
PATCH 2/2 trace: make the 'log' backend timestamp configurable
In reply to Stefan HajnocziTimestamps in tracing output can be distracting. Make it possible to control tid/timestamp printing with -msg timestamp=on|off. The default is no tid/timestamps. Previously they were always printed.
--- docs/devel/tracing.txt | 3 +++ scripts/tracetool/backend/log.py | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-)
docs/devel/tracing.txt +3 -0
@@ -211,6 +211,9 @@ effectively turns trace events into debug printfs. This is the simplest backend and can be used together with existing code that uses DPRINTF(). +The -msg timestamp=on|off command-line option controls whether or not to print +the tid/timestamp prefix for each trace event. + === Simpletrace === The "simple" backend supports common use cases and comes as part of the QEMU
scripts/tracetool/backend/log.py +13 -6
@@ -20,6 +20,7 @@ PUBLIC = True def generate_h_begin(events, group): out('#include "qemu/log-for-trace.h"', + '#include "qemu/error-report.h"', '')
@@ -35,14 +36,20 @@ def generate_h(event, group): cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper()) out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {', - ' struct timeval _now;', - ' gettimeofday(&_now, NULL);', + ' if (message_with_timestamp) {', + ' 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);', + ' 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"', + ' } else {', + '#line %(event_lineno)d "%(event_filename)s"', + ' qemu_log("%(name)s " %(fmt)s "\\n"%(argnames)s);', + '#line %(out_next_lineno)d "%(out_filename)s"', + ' }', ' }', cond=cond, event_lineno=event.lineno,
Signature · 1 line
2.29.2
Hi Stefan,
Quoted 10 lines · Stefan Hajnoczi
Zoltan reminded me that the 'log' backend prints tids/timestamps and this can be unwanted in some cases. It's easier to look at trace output without them and in some cases parsing is also more convenient with them.
Extend -msg timestamp=on|off to control the 'log' backend's tid/timestamp output.
Stefan Hajnoczi (2):
error: renameerror_with_timestamptomessage_with_timestamp
trace: make the 'log' backend timestamp configurable
Quoted 6 lines
docs/devel/tracing.txt | 3 +++ include/qemu/error-report.h | 2 +- softmmu/vl.c | 2 +- util/qemu-error.c | 4 ++-- scripts/tracetool/backend/log.py | 19 +++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-)
I applied your series, rebuilt, but nothing changed.
Apparently there is some buildsys rule missing, the trace files weren't regenerated.
After full tree 'make clean' I could successfully test:
Ignoring the buildsys issue:
Regards,
Phil.
Quoted 20 lines · Philippe Mathieu-Daudé
Hi Stefan,
Quoted 10 lines · Stefan Hajnoczi
Zoltan reminded me that the 'log' backend prints tids/timestamps and this can be unwanted in some cases. It's easier to look at trace output without them and in some cases parsing is also more convenient with them.
Extend -msg timestamp=on|off to control the 'log' backend's tid/timestamp output.
Stefan Hajnoczi (2):
error: renameerror_with_timestamptomessage_with_timestamp
trace: make the 'log' backend timestamp configurableQuoted 6 lines
docs/devel/tracing.txt | 3 +++ include/qemu/error-report.h | 2 +- softmmu/vl.c | 2 +- util/qemu-error.c | 4 ++-- scripts/tracetool/backend/log.py | 19 +++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-)
Quoted 4 lines
I applied your series, rebuilt, but nothing changed.
Apparently there is some buildsys rule missing, the trace files weren't regenerated.
I sent a separate patch that adds tracetool dependencies to meson.build:
"[PATCH] trace: add meson custom_target() depend_files for tracetool"
That will fix the issue.
Stefan
Quoted 5 lines · Stefan Hajnoczi
Zoltan reminded me that the 'log' backend prints tids/timestamps and this can be unwanted in some cases. It's easier to look at trace output without them and in some cases parsing is also more convenient with them.
Extend -msg timestamp=on|off to control the 'log' backend's tid/timestamp output.
Thank you, this works for me
but I had to remove build dir and rerun configure to get it omit timestamps. Just running make (which reruns configure) or make distclean and running configure does not seem to be enough to pick up some changes since the meson conversion. (I had similar problem with gtk being detected and used despite having --disable-gtk on configure before the gtk test was moved to meson; so I think there's some problem detecting changes in configure options somewhere. That was also fixed by rerunning configure after starting from clean build dir but did not work when keeping old build dir or make distclean. This is probably not a problem for someone downloading the sources and compiling it once, only annoying for developers who build it all the time.)
Regards,
BALATON Zoltan
Quoted 10 lines
Stefan Hajnoczi (2):
error: renameerror_with_timestamptomessage_with_timestamp
trace: make the 'log' backend timestamp configurabledocs/devel/tracing.txt | 3 +++ include/qemu/error-report.h | 2 +- softmmu/vl.c | 2 +- util/qemu-error.c | 4 ++-- scripts/tracetool/backend/log.py | 19 +++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-)
Quoted 11 lines · BALATON Zoltan
Quoted 5 lines · Stefan Hajnoczi
Zoltan reminded me that the 'log' backend prints tids/timestamps and this can be unwanted in some cases. It's easier to look at trace output without them and in some cases parsing is also more convenient with them.
Extend -msg timestamp=on|off to control the 'log' backend's tid/timestamp output.
Thank you, this works for me
Tested-by BALATON Zoltan <[email protected]>
Quoted 11 lines
but I had to remove build dir and rerun configure to get it omit timestamps. Just running make (which reruns configure) or make distclean and running configure does not seem to be enough to pick up some changes since the meson conversion. (I had similar problem with gtk being detected and used despite having --disable-gtk on configure before the gtk test was moved to meson; so I think there's some problem detecting changes in configure options somewhere. That was also fixed by rerunning configure after starting from clean build dir but did not work when keeping old build dir or make distclean. This is probably not a problem for someone downloading the sources and compiling it once, only annoying for developers who build it all the time.)
Thanks! The following meson.build fix in the tracing queue:
[PATCH] trace: add meson custom_target() depend_files for tracetool
It solves this issue.
Stefan
Stefan Hajnoczi
AppliedQuoted 10 lines · Stefan Hajnoczi
Zoltan reminded me that the 'log' backend prints tids/timestamps and this can be unwanted in some cases. It's easier to look at trace output without them and in some cases parsing is also more convenient with them.
Extend -msg timestamp=on|off to control the 'log' backend's tid/timestamp output.
Stefan Hajnoczi (2):
error: renameerror_with_timestamptomessage_with_timestamp
trace: make the 'log' backend timestamp configurable
Quoted 10 lines
docs/devel/tracing.txt | 3 +++ include/qemu/error-report.h | 2 +- softmmu/vl.c | 2 +- util/qemu-error.c | 4 ++-- scripts/tracetool/backend/log.py | 19 +++++++++++++------ 5 files changed, 20 insertions(+), 10 deletions(-)Signature · 1 line
2.29.2
Thanks, applied to my master tree:
https://gitlab.com/stefanha/qemu/commits/master
Stefan