Skip to contentSkip to conversation

simplify usage of tracepoints, and connect them to logging

PATCH Applied Denis V. Lunev 3 participants 16 messages Jan 7, 2016 – Jan 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

v4 cover simplify usage of tracepoints, and connect them to logging

This series does three things:

1) add a "-trace [enable=]foo" option to enable one or more trace events, and a "-trace help" option to show the list of tracepoints (patches 4-5)

2) change the stderr tracing backend so that it prints to the -D log file, and enable it by default. "-trace file=..." is now a synonym of -D if the log backend is enabled (patches 7-8)

3) add a "-d trace:foo" option that is a synonym for "-trace foo"; this makes the new functionality more discoverable to people used to "-d", makes it available for user-mode emulation (which does not have -trace), and is somewhat nice if you want to enable both tracepoints and some other "-d" flag (patch 9). When globbing it is also less susceptible to unwanted shell expansion.

For example, you can trace block device I/O and save the result to a file just by adding "-trace bdrv_aio_*,file=trace.txt", or correlate it to guest PCs with "-d exec,nochain,trace:bdrv_aio_*".

Opinions? I would like to have this in 2.5 if there is agreement.

Changes from v3:
- fixed compilation of target-arm/translate-a64.c (patch 7)
- this warning is not observed in my environment /aarch64/qom/xlnx-ep108:
WARNING: RAM size 8000000 is small for EP108OK
- this warning after patch 10 is seen /microblaze/qom/petalogix-s3adsp1800:
Invalid MicroBlaze version number: (null)
OK
though the problem is here even before any patch of the set. It is just hidden as log is not enabled
- no problem for Win32 compilation with

    COLLECT_GCC=x86_64-w64-mingw32-gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/lto-wrapper
    Target: x86_64-w64-mingw32
    Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libexecdir='/usr/lib/gcc-mingw-w64' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++ --enable-lto --with-plugin-ld --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld
    Thread model: win32
    gcc version 4.9.2 (GCC)

Changes from v2:
- compilation fix was extended to patch 2 and 3
- replaced Reviewed-by with Acked-by by request from Christian

Changes from v1:
- small cleanup to vl.c is added as patch (4)
- compilation is fixed in patch (2)
- moved qemu-log.c to util/log.c to fix linking of qemu-io/qemu-nbd

Denis V. Lunev (2):
trace: no need to call trace_backend_init in different branches now
log: move qemu-log.c into util/ directory

Paolo Bonzini (9):
trace: fix documentation
trace: split trace_init_events out of trace_init_backends
trace: split trace_init_file out of trace_init_backends
trace: add "-trace enable=..."
trace: add "-trace help"
log: do not unnecessarily include qom/cpu.h
trace: convert stderr backend to log
trace: switch default backend to "log"
log: add "-d trace:PATTERN"

 Makefile.objs                                   |  1 -
 bsd-user/main.c                                 |  1 +
 configure                                       |  6 +-
 cpu-exec.c                                      |  1 +
 exec.c                                          |  1 +
 hw/acpi/cpu_hotplug.c                           |  1 +
 hw/timer/a9gtimer.c                             |  1 +
 include/exec/log.h                              | 60 ++++++++++++++++
 include/qemu/log.h                              | 60 +---------------
 linux-user/main.c                               |  1 +
 qemu-io.c                                       |  2 +-
 qemu-options.hx                                 | 22 ++++--
 qom/cpu.c                                       |  1 +
 scripts/tracetool/backend/{stderr.py => log.py} |  9 +--
 target-alpha/translate.c                        |  1 +
 target-arm/translate-a64.c                      |  1 +
 target-arm/translate.c                          |  1 +
 target-cris/translate.c                         |  1 +
 target-i386/seg_helper.c                        |  1 +
 target-i386/smm_helper.c                        |  1 +
 target-i386/translate.c                         |  1 +
 target-lm32/helper.c                            |  1 +
 target-lm32/translate.c                         |  1 +
 target-m68k/translate.c                         |  1 +
 target-microblaze/helper.c                      |  1 +
 target-microblaze/translate.c                   |  1 +
 target-mips/helper.c                            |  1 +
 target-mips/translate.c                         |  1 +
 target-moxie/translate.c                        |  1 +
 target-openrisc/translate.c                     |  1 +
 target-ppc/mmu-hash32.c                         |  1 +
 target-ppc/mmu-hash64.c                         |  1 +
 target-ppc/mmu_helper.c                         |  1 +
 target-ppc/translate.c                          |  1 +
 target-s390x/translate.c                        |  1 +
 target-sh4/helper.c                             |  1 +
 target-sh4/translate.c                          |  1 +
 target-sparc/int32_helper.c                     |  1 +
 target-sparc/int64_helper.c                     |  1 +
 target-sparc/translate.c                        |  1 +
 target-tilegx/translate.c                       |  1 +
 target-tricore/translate.c                      |  1 +
 target-unicore32/translate.c                    |  1 +
 target-xtensa/translate.c                       |  1 +
 tcg/tcg.c                                       |  1 +
 trace/control.c                                 | 95 ++++++++++++++++++-------
 trace/control.h                                 | 42 ++++++++++-
 trace/simple.c                                  |  6 +-
 trace/simple.h                                  |  4 +-
 translate-all.c                                 |  1 +
 util/Makefile.objs                              |  1 +
 qemu-log.c => util/log.c                        | 19 ++++-
 vl.c                                            | 38 +++++-----
 53 files changed, 275 insertions(+), 129 deletions(-)
 create mode 100644 include/exec/log.h
 rename scripts/tracetool/backend/{stderr.py => log.py} (78%)
 rename qemu-log.c => util/log.c (90%)
Signature · 1 line
2.5.0
#1 lore raw

PATCH v4 1/11 trace: fix documentation

From: Paolo Bonzini <[email protected]>

Mention the ftrace backend too.

---
 qemu-options.hx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
qemu-options.hx +5 -5
index 215d00d..1ce89db 100644
@@ -3545,13 +3545,13 @@ Specify tracing options.
 @table @option
 @item events=@var{file}
 Immediately enable events listed in @var{file}.
-The file must contain one event name (as listed in the @var{trace-events} file)
-per line.
-This option is only available if QEMU has been compiled with
-either @var{simple} or @var{stderr} tracing backend.
+The file must contain one event name (as listed in the @file{trace-events} file)
+per line; globbing patterns are accepted too.  This option is only
+available if QEMU has been compiled with the @var{simple}, @var{stderr} or
+@var{ftrace} tracing backend.
+
 @item file=@var{file}
 Log output traces to @var{file}.
-
 This option is only available if QEMU has been compiled with
 the @var{simple} tracing backend.
 @end table
Signature · 1 line
2.5.0
#2 lore raw

PATCH v4 2/11 trace: split trace_init_events out of trace_init_backends

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

This is cleaner and has two advantages. First, it improves error reporting with -daemonize. Second, multiple "-trace events" options now cumulate.

---
 qemu-io.c       |  2 +-
 trace/control.c |  5 ++---
 trace/control.h | 15 ++++++++++++---
 vl.c            |  8 ++++----
 4 files changed, 19 insertions(+), 11 deletions(-)
qemu-io.c +1 -1
index 269f17c..d6fa11b 100644
@@ -440,7 +440,7 @@ int main(int argc, char **argv)
             }
             break;
         case 'T':
-            if (!trace_init_backends(optarg, NULL)) {
+            if (!trace_init_backends(optarg)) {
                 exit(1); /* error message will have been printed */
             }
             break;
trace/control.c +2 -3
index 995beb3..ee5fbca 100644
@@ -85,7 +85,7 @@ TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev)
     return NULL;
 }
 
-static void trace_init_events(const char *fname)
+void trace_init_events(const char *fname)
 {
     Location loc;
     FILE *fp;
@@ -142,7 +142,7 @@ static void trace_init_events(const char *fname)
     loc_pop(&loc);
 }
 
-bool trace_init_backends(const char *events, const char *file)
+bool trace_init_backends(const char *file)
 {
 #ifdef CONFIG_TRACE_SIMPLE
     if (!st_init(file)) {
@@ -164,6 +164,5 @@ bool trace_init_backends(const char *events, const char *file)
     }
 #endif
 
-    trace_init_events(events);
     return true;
 }
trace/control.h +12 -3
index da9bb6b..bfbe560 100644
@@ -150,8 +150,6 @@ static void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
 
 /**
  * trace_init_backends:
- * @events: Name of file with events to be enabled at startup; may be NULL.
- *          Corresponds to commandline option "-trace events=...".
  * @file:   Name of trace output file; may be NULL.
  *          Corresponds to commandline option "-trace file=...".
  *
@@ -159,7 +157,18 @@ static void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
  *
  * Returns: Whether the backends could be successfully initialized.
  */
-bool trace_init_backends(const char *events, const char *file);
+bool trace_init_backends(const char *file);
+
+/**
+ * trace_init_events:
+ * @events: Name of file with events to be enabled at startup; may be NULL.
+ *          Corresponds to commandline option "-trace events=...".
+ *
+ * Read the list of enabled tracing events.
+ *
+ * Returns: Whether the backends could be successfully initialized.
+ */
+void trace_init_events(const char *file);
 
 
 #include "trace/control-internal.h"
vl.c +4 -4
index 5aaea77..2aa368b 100644
@@ -2994,7 +2994,6 @@ int main(int argc, char **argv, char **envp)
     bool userconfig = true;
     const char *log_mask = NULL;
     const char *log_file = NULL;
-    const char *trace_events = NULL;
     const char *trace_file = NULL;
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
@@ -3911,8 +3910,9 @@ int main(int argc, char **argv, char **envp)
                 if (!opts) {
                     exit(1);
                 }
-                trace_events = qemu_opt_get(opts, "events");
+                trace_init_events(qemu_opt_get(opts, "events"));
                 trace_file = qemu_opt_get(opts, "file");
+                qemu_opts_del(opts);
                 break;
             }
             case QEMU_OPTION_readconfig:
@@ -4112,7 +4112,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (!is_daemonized()) {
-        if (!trace_init_backends(trace_events, trace_file)) {
+        if (!trace_init_backends(trace_file)) {
             exit(1);
         }
     }
@@ -4676,7 +4676,7 @@ int main(int argc, char **argv, char **envp)
     os_setup_post();
 
     if (is_daemonized()) {
-        if (!trace_init_backends(trace_events, trace_file)) {
+        if (!trace_init_backends(trace_file)) {
             exit(1);
         }
     }
Signature · 1 line
2.5.0
#3 lore raw

PATCH v4 3/11 trace: split trace_init_file out of trace_init_backends

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

This is cleaner, and improves error reporting with -daemonize.

---
 qemu-io.c       |  2 +-
 trace/control.c | 17 ++++++++++++-----
 trace/control.h | 13 ++++++++++++-
 trace/simple.c  |  6 ++----
 trace/simple.h  |  4 ++--
 vl.c            | 13 +++++++++----
 6 files changed, 38 insertions(+), 17 deletions(-)
qemu-io.c +1 -1
index d6fa11b..fbddf82 100644
@@ -440,7 +440,7 @@ int main(int argc, char **argv)
             }
             break;
         case 'T':
-            if (!trace_init_backends(optarg)) {
+            if (!trace_init_backends()) {
                 exit(1); /* error message will have been printed */
             }
             break;
trace/control.c +12 -5
index ee5fbca..3e33d03 100644
@@ -142,17 +142,24 @@ void trace_init_events(const char *fname)
     loc_pop(&loc);
 }
 
-bool trace_init_backends(const char *file)
+void trace_init_file(const char *file)
 {
 #ifdef CONFIG_TRACE_SIMPLE
-    if (!st_init(file)) {
-        fprintf(stderr, "failed to initialize simple tracing backend.\n");
-        return false;
-    }
+    st_set_trace_file(file);
 #else
     if (file) {
         fprintf(stderr, "error: -trace file=...: "
                 "option not supported by the selected tracing backends\n");
+        exit(1);
+    }
+#endif
+}
+
+bool trace_init_backends(void)
+{
+#ifdef CONFIG_TRACE_SIMPLE
+    if (!st_init()) {
+        fprintf(stderr, "failed to initialize simple tracing backend.\n");
         return false;
     }
 #endif
trace/control.h +12 -1
index bfbe560..d2506d4 100644
@@ -157,7 +157,7 @@ static void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
  *
  * Returns: Whether the backends could be successfully initialized.
  */
-bool trace_init_backends(const char *file);
+bool trace_init_backends(void);
 
 /**
  * trace_init_events:
@@ -170,6 +170,17 @@ bool trace_init_backends(const char *file);
  */
 void trace_init_events(const char *file);
 
+/**
+ * trace_init_file:
+ * @file:   Name of trace output file; may be NULL.
+ *          Corresponds to commandline option "-trace file=...".
+ *
+ * Record the name of the output file for the tracing backend.
+ * Exits if no selected backend does not support specifying the
+ * output file, and a non-NULL file was passed.
+ */
+void trace_init_file(const char *file);
+
 
 #include "trace/control-internal.h"
 
trace/simple.c +2 -4
index 56a624c..e8594cd 100644
@@ -322,7 +322,7 @@ void st_set_trace_file_enabled(bool enable)
  * @file        The trace file name or NULL for the default name-<pid> set at
  *              config time
  */
-bool st_set_trace_file(const char *file)
+void st_set_trace_file(const char *file)
 {
     st_set_trace_file_enabled(false);
 
@@ -336,7 +336,6 @@ bool st_set_trace_file(const char *file)
     }
 
     st_set_trace_file_enabled(true);
-    return true;
 }
 
 void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
@@ -374,7 +373,7 @@ static GThread *trace_thread_create(GThreadFunc fn)
     return thread;
 }
 
-bool st_init(const char *file)
+bool st_init(void)
 {
     GThread *thread;
 
@@ -387,6 +386,5 @@ bool st_init(const char *file)
     }
 
     atexit(st_flush_trace_buffer);
-    st_set_trace_file(file);
     return true;
 }
trace/simple.h +2 -2
index 6997996..8d1a32e 100644
@@ -20,8 +20,8 @@
 
 void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
 void st_set_trace_file_enabled(bool enable);
-bool st_set_trace_file(const char *file);
-bool st_init(const char *file);
+void st_set_trace_file(const char *file);
+bool st_init(void);
 void st_flush_trace_buffer(void);
 
 typedef struct {
vl.c +9 -4
index 2aa368b..210db41 100644
@@ -2994,7 +2994,7 @@ int main(int argc, char **argv, char **envp)
     bool userconfig = true;
     const char *log_mask = NULL;
     const char *log_file = NULL;
-    const char *trace_file = NULL;
+    char *trace_file = NULL;
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
@@ -3911,7 +3911,10 @@ int main(int argc, char **argv, char **envp)
                     exit(1);
                 }
                 trace_init_events(qemu_opt_get(opts, "events"));
-                trace_file = qemu_opt_get(opts, "file");
+                if (trace_file) {
+                    g_free(trace_file);
+                }
+                trace_file = g_strdup(qemu_opt_get(opts, "file"));
                 qemu_opts_del(opts);
                 break;
             }
@@ -4095,6 +4098,8 @@ int main(int argc, char **argv, char **envp)
         exit(0);
     }
 
+    trace_init_file(trace_file);
+
     /* Open the logfile at this point and set the log mask if necessary.
      */
     if (log_file) {
@@ -4112,7 +4117,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (!is_daemonized()) {
-        if (!trace_init_backends(trace_file)) {
+        if (!trace_init_backends()) {
             exit(1);
         }
     }
@@ -4676,7 +4681,7 @@ int main(int argc, char **argv, char **envp)
     os_setup_post();
 
     if (is_daemonized()) {
-        if (!trace_init_backends(trace_file)) {
+        if (!trace_init_backends()) {
             exit(1);
         }
     }
Signature · 1 line
2.5.0
#4 lore raw

PATCH v4 4/11 trace: no need to call trace_backend_init in different branches now

In reply to Denis V. Lunev

original idea to split calling locations was to spawn tracing thread in the final child process according to

    commit 8a745f2a9296ad2cf6bda33534ed298f2625a4ad
    Author: Michael Mueller
    Date:   Mon Sep 23 16:36:54 2013 +0200

os_daemonize is now on top of both locations. Drop unneeded ifs.

---
 vl.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
vl.c +2 -10
index 210db41..1cd30b2 100644
@@ -4116,10 +4116,8 @@ int main(int argc, char **argv, char **envp)
         qemu_set_log(mask);
     }
 
-    if (!is_daemonized()) {
-        if (!trace_init_backends()) {
-            exit(1);
-        }
+    if (!trace_init_backends()) {
+        exit(1);
     }
 
     /* If no data_dir is specified then try to find it relative to the
@@ -4680,12 +4678,6 @@ int main(int argc, char **argv, char **envp)
 
     os_setup_post();
 
-    if (is_daemonized()) {
-        if (!trace_init_backends()) {
-            exit(1);
-        }
-    }
-
     main_loop();
     replay_disable_events();
 
Signature · 1 line
2.5.0
#5 lore raw

PATCH v4 5/11 trace: add "-trace enable=..."

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

Allow enabling events without going through a file, for example:

qemu-system-x86_64 -trace bdrv_aio_writev -trace bdrv_aio_readv

or with globbing too:

qemu-system-x86_64 -trace 'bdrv_aio_*'

if an appropriate backend is enabled (simple, stderr, ftrace).

---
 qemu-options.hx | 10 +++++++++-
 trace/control.c | 48 +++++++++++++++++++++++++++---------------------
 trace/control.h |  9 +++++++++
 vl.c            | 11 +++++++++--
 4 files changed, 54 insertions(+), 24 deletions(-)
qemu-options.hx +9 -1
index 1ce89db..e5d03c9 100644
@@ -3531,7 +3531,7 @@ config files on @var{sysconfdir}, but won't make it skip the QEMU-provided confi
 files from @var{datadir}.
 ETEXI
 DEF("trace", HAS_ARG, QEMU_OPTION_trace,
-    "-trace [events=<file>][,file=<file>]\n"
+    "-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
     "                specify tracing options\n",
     QEMU_ARCH_ALL)
 STEXI
@@ -3543,6 +3543,14 @@ HXCOMM HX does not support conditional compilation of text.
 Specify tracing options.
 
 @table @option
+@item [enable=]@var{pattern}
+Immediately enable events matching @var{pattern}.
+The file must contain one event name (as listed in the @file{trace-events} file)
+per line; globbing patterns are accepted too.  This option is only
+available if QEMU has been compiled with the @var{simple}, @var{stderr}
+or @var{ftrace} tracing backend.  To specify multiple events or patterns,
+specify the @option{-trace} option multiple times.
+
 @item events=@var{file}
 Immediately enable events listed in @var{file}.
 The file must contain one event name (as listed in the @file{trace-events} file)
trace/control.c +27 -21

60 lines not on this page · raw message

trace/control.h +9 -0
index d2506d4..32a66ce 100644
@@ -181,6 +181,15 @@ void trace_init_events(const char *file);
  */
 void trace_init_file(const char *file);
 
+/**
+ * trace_enable_events:
+ * @line_buf: A string with a glob pattern of events to be enabled or,
+ *            if the string starts with '-', disabled.
+ *
+ * Enable or disable matching events.
+ */
+void trace_enable_events(const char *line_buf);
+
 
 #include "trace/control-internal.h"
 
vl.c +9 -2
index 1cd30b2..01b39d4 100644
@@ -271,10 +271,14 @@ static QemuOptsList qemu_sandbox_opts = {
 
 static QemuOptsList qemu_trace_opts = {
     .name = "trace",
-    .implied_opt_name = "trace",
+    .implied_opt_name = "enable",
     .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head),
     .desc = {
         {
+            .name = "enable",
+            .type = QEMU_OPT_STRING,
+        },
+        {
             .name = "events",
             .type = QEMU_OPT_STRING,
         },{
@@ -3906,10 +3910,13 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_trace:
             {
                 opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
-                                               optarg, false);
+                                               optarg, true);
                 if (!opts) {
                     exit(1);
                 }
+                if (qemu_opt_get(opts, "enable")) {
+                    trace_enable_events(qemu_opt_get(opts, "enable"));
+                }
                 trace_init_events(qemu_opt_get(opts, "events"));
                 if (trace_file) {
                     g_free(trace_file);
Signature · 1 line
2.5.0
#6 lore raw

PATCH v4 6/11 trace: add "-trace help"

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

Print a list of trace points

---
 qemu-options.hx |  2 ++
 trace/control.c | 21 ++++++++++++++++++++-
 trace/control.h |  7 +++++++
 3 files changed, 29 insertions(+), 1 deletion(-)
qemu-options.hx +2 -0
index e5d03c9..aa3707d 100644
@@ -3551,6 +3551,8 @@ available if QEMU has been compiled with the @var{simple}, @var{stderr}
 or @var{ftrace} tracing backend.  To specify multiple events or patterns,
 specify the @option{-trace} option multiple times.
 
+Use @code{-trace help} to print a list of names of trace points.
+
 @item events=@var{file}
 Immediately enable events listed in @var{file}.
 The file must contain one event name (as listed in the @file{trace-events} file)
trace/control.c +20 -1
index 715b5b7..7c84795 100644
@@ -85,7 +85,16 @@ TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev)
     return NULL;
 }
 
-void trace_enable_events(const char *line_buf)
+void trace_list_events(void)
+{
+    int i;
+    for (i = 0; i < trace_event_count(); i++) {
+        TraceEvent *res = trace_event_id(i);
+        fprintf(stderr, "%s\n", trace_event_get_name(res));
+    }
+}
+
+static void do_trace_enable_events(const char *line_buf)
 {
     const bool enable = ('-' != line_buf[0]);
     const char *line_ptr = enable ? line_buf : line_buf + 1;
@@ -111,6 +120,16 @@ void trace_enable_events(const char *line_buf)
     }
 }
 
+void trace_enable_events(const char *line_buf)
+{
+    if (is_help_option(line_buf)) {
+        trace_list_events();
+        exit(0);
+    } else {
+        do_trace_enable_events(line_buf);
+    }
+}
+
 void trace_init_events(const char *fname)
 {
     Location loc;
trace/control.h +7 -0
index 32a66ce..3707b3b 100644
@@ -182,6 +182,13 @@ void trace_init_events(const char *file);
 void trace_init_file(const char *file);
 
 /**
+ * trace_list_events:
+ *
+ * List all available events.
+ */
+void trace_list_events(void);
+
+/**
  * trace_enable_events:
  * @line_buf: A string with a glob pattern of events to be enabled or,
  *            if the string starts with '-', disabled.
Signature · 1 line
2.5.0
#7 lore raw

PATCH v4 7/11 log: do not unnecessarily include qom/cpu.h

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

Split the bits that require it to exec/log.h.

---
 bsd-user/main.c               |  1 +
 cpu-exec.c                    |  1 +
 exec.c                        |  1 +
 hw/acpi/cpu_hotplug.c         |  1 +
 hw/timer/a9gtimer.c           |  1 +
 include/exec/log.h            | 60 +++++++++++++++++++++++++++++++++++++++++++
 include/qemu/log.h            | 59 ------------------------------------------
 linux-user/main.c             |  1 +
 qom/cpu.c                     |  1 +
 target-alpha/translate.c      |  1 +
 target-arm/translate-a64.c    |  1 +
 target-arm/translate.c        |  1 +
 target-cris/translate.c       |  1 +
 target-i386/seg_helper.c      |  1 +
 target-i386/smm_helper.c      |  1 +
 target-i386/translate.c       |  1 +
 target-lm32/helper.c          |  1 +
 target-lm32/translate.c       |  1 +
 target-m68k/translate.c       |  1 +
 target-microblaze/helper.c    |  1 +
 target-microblaze/translate.c |  1 +
 target-mips/helper.c          |  1 +
 target-mips/translate.c       |  1 +
 target-moxie/translate.c      |  1 +
 target-openrisc/translate.c   |  1 +
 target-ppc/mmu-hash32.c       |  1 +
 target-ppc/mmu-hash64.c       |  1 +
 target-ppc/mmu_helper.c       |  1 +
 target-ppc/translate.c        |  1 +
 target-s390x/translate.c      |  1 +
 target-sh4/helper.c           |  1 +
 target-sh4/translate.c        |  1 +
 target-sparc/int32_helper.c   |  1 +
 target-sparc/int64_helper.c   |  1 +
 target-sparc/translate.c      |  1 +
 target-tilegx/translate.c     |  1 +
 target-tricore/translate.c    |  1 +
 target-unicore32/translate.c  |  1 +
 target-xtensa/translate.c     |  1 +
 tcg/tcg.c                     |  1 +
 translate-all.c               |  1 +
 41 files changed, 99 insertions(+), 59 deletions(-)
 create mode 100644 include/exec/log.h
bsd-user/main.c +1 -0
index 1ecaeb5..fefcfc1 100644
@@ -33,6 +33,7 @@
 #include "tcg.h"
 #include "qemu/timer.h"
 #include "qemu/envlist.h"
+#include "exec/log.h"
 
 int singlestep;
 unsigned long mmap_min_addr;
cpu-exec.c +1 -0
index c88d0ff..8e2e52b 100644
@@ -27,6 +27,7 @@
 #include "exec/address-spaces.h"
 #include "qemu/rcu.h"
 #include "exec/tb-hash.h"
+#include "exec/log.h"
 #if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY)
 #include "hw/i386/apic.h"
 #endif
exec.c +1 -0
index 8718a75..b6a0b01 100644
@@ -54,6 +54,7 @@
 
 #include "exec/memory-internal.h"
 #include "exec/ram_addr.h"
+#include "exec/log.h"
 
 #include "qemu/range.h"
 #ifndef _WIN32
hw/acpi/cpu_hotplug.c +1 -0
index f5b9972..16bacfc 100644
@@ -11,6 +11,7 @@
  */
 #include "hw/hw.h"
 #include "hw/acpi/cpu_hotplug.h"
+#include "qom/cpu.h"
 
 static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
 {
hw/timer/a9gtimer.c +1 -0
index dd4aae8..b38c76a 100644
@@ -24,6 +24,7 @@
 #include "qemu/timer.h"
 #include "qemu/bitops.h"
 #include "qemu/log.h"
+#include "qom/cpu.h"
 
 #ifndef A9_GTIMER_ERR_DEBUG
 #define A9_GTIMER_ERR_DEBUG 0
include/exec/log.h new file +60 -0

60 lines not on this page · raw message

include/qemu/log.h +0 -59

71 lines not on this page · raw message

linux-user/main.c +1 -0
index ee12035..61547ab 100644
@@ -33,6 +33,7 @@
 #include "qemu/timer.h"
 #include "qemu/envlist.h"
 #include "elf.h"
+#include "exec/log.h"
 
 char *exec_path;
 
qom/cpu.c +1 -0
index fb80d13..ce7dfa2 100644
@@ -23,6 +23,7 @@
 #include "sysemu/kvm.h"
 #include "qemu/notify.h"
 #include "qemu/log.h"
+#include "exec/log.h"
 #include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
 
target-alpha/translate.c +1 -0
index 9909c70..635f129 100644
@@ -27,6 +27,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #undef ALPHA_DEBUG_DISAS
target-arm/translate-a64.c +1 -0
index 14e8131..6be4b39 100644
@@ -35,6 +35,7 @@
 
 #include "exec/helper-proto.h"
 #include "exec/helper-gen.h"
+#include "exec/log.h"
 
 #include "trace-tcg.h"
 
target-arm/translate.c +1 -0
index d485e7d..de3f93e 100644
@@ -36,6 +36,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define ENABLE_ARCH_4T    arm_dc_feature(s, ARM_FEATURE_V4T)
target-cris/translate.c +1 -0
index 2429931..a17a009 100644
@@ -34,6 +34,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define DISAS_CRIS 0
target-i386/seg_helper.c +1 -0
index 20ee892..e55694f 100644
@@ -22,6 +22,7 @@
 #include "qemu/log.h"
 #include "exec/helper-proto.h"
 #include "exec/cpu_ldst.h"
+#include "exec/log.h"
 
 //#define DEBUG_PCALL
 
target-i386/smm_helper.c +1 -0
index c272a98..1ab6637 100644
@@ -19,6 +19,7 @@
 
 #include "cpu.h"
 #include "exec/helper-proto.h"
+#include "exec/log.h"
 
 /* SMM support */
 
target-i386/translate.c +1 -0
index a3dd167..3079e96 100644
@@ -32,6 +32,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define PREFIX_REPZ   0x01
target-lm32/helper.c +1 -0
index e26c133..978b99f 100644
@@ -21,6 +21,7 @@
 #include "qemu/host-utils.h"
 #include "sysemu/sysemu.h"
 #include "exec/semihost.h"
+#include "exec/log.h"
 
 int lm32_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw,
                               int mmu_idx)
target-lm32/translate.c +1 -0
index fa5b0b9..ad6bd20 100644
@@ -28,6 +28,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define DISAS_LM32 1
target-m68k/translate.c +1 -0
index 41ae2c6..03772cf 100644
@@ -28,6 +28,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 //#define DEBUG_DISPATCH 1
target-microblaze/helper.c +1 -0
index a482e47..5539f74 100644
@@ -20,6 +20,7 @@
 
 #include "cpu.h"
 #include "qemu/host-utils.h"
+#include "exec/log.h"
 
 #define D(x)
 
target-microblaze/translate.c +1 -0
index 9e52011..27b8277 100644
@@ -27,6 +27,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define SIM_COMPAT 0
target-mips/helper.c +1 -0
index 118072a..4675b07 100644
@@ -25,6 +25,7 @@
 #include "cpu.h"
 #include "sysemu/kvm.h"
 #include "exec/cpu_ldst.h"
+#include "exec/log.h"
 
 enum {
     TLBRET_XI = -6,
target-mips/translate.c +1 -0
index 5626647..cfc993c 100644
@@ -32,6 +32,7 @@
 #include "exec/semihost.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 #define MIPS_DEBUG_DISAS 0
 
target-moxie/translate.c +1 -0
index 6dedcb7..9e2ac47 100644
@@ -35,6 +35,7 @@
 
 #include "exec/helper-proto.h"
 #include "exec/helper-gen.h"
+#include "exec/log.h"
 
 /* This is the state at translation time.  */
 typedef struct DisasContext {
target-openrisc/translate.c +1 -0
index 606490a..b572eee 100644
@@ -32,6 +32,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define OPENRISC_DISAS
target-ppc/mmu-hash32.c +1 -0
index a00ae3c..74b77a5 100644
@@ -23,6 +23,7 @@
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
 #include "mmu-hash32.h"
+#include "exec/log.h"
 
 //#define DEBUG_BAT
 
target-ppc/mmu-hash64.c +1 -0
index 34e20fa..7631476 100644
@@ -22,6 +22,7 @@
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
 #include "mmu-hash64.h"
+#include "exec/log.h"
 
 //#define DEBUG_SLB
 
target-ppc/mmu_helper.c +1 -0
index 5217691..34c2338 100644
@@ -23,6 +23,7 @@
 #include "mmu-hash64.h"
 #include "mmu-hash32.h"
 #include "exec/cpu_ldst.h"
+#include "exec/log.h"
 
 //#define DEBUG_MMU
 //#define DEBUG_BATS
target-ppc/translate.c +1 -0
index 4be7eaa..b0dc66a 100644
@@ -28,6 +28,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define CPU_SINGLE_STEP 0x1
target-s390x/translate.c +1 -0
index c79a2cb..4c69ee3 100644
@@ -43,6 +43,7 @@ static TCGv_ptr cpu_env;
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 /* Information that (most) every instruction needs to manipulate.  */
target-sh4/helper.c +1 -0
index eaececd..90b4405 100644
@@ -23,6 +23,7 @@
 #include <inttypes.h>
 
 #include "cpu.h"
+#include "exec/log.h"
 
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/sh4/sh_intc.h"
target-sh4/translate.c +1 -0
index 7bc6216..b07904d 100644
@@ -28,6 +28,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 typedef struct DisasContext {
target-sparc/int32_helper.c +1 -0
index 7c380ba..ac5e599 100644
@@ -20,6 +20,7 @@
 #include "cpu.h"
 #include "trace.h"
 #include "sysemu/sysemu.h"
+#include "exec/log.h"
 
 #define DEBUG_PCALL
 
target-sparc/int64_helper.c +1 -0
index b02d22b..a753151 100644
@@ -19,6 +19,7 @@
 
 #include "cpu.h"
 #include "exec/helper-proto.h"
+#include "exec/log.h"
 #include "trace.h"
 
 #define DEBUG_PCALL
target-sparc/translate.c +1 -0
index 63440dd..0c771e1 100644
@@ -33,6 +33,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define DEBUG_DISAS
target-tilegx/translate.c +1 -0
index 354f25a..78befe8 100644
@@ -20,6 +20,7 @@
 
 #include "cpu.h"
 #include "qemu/log.h"
+#include "exec/log.h"
 #include "disas/disas.h"
 #include "tcg-op.h"
 #include "exec/cpu_ldst.h"
target-tricore/translate.c +1 -0
index 135c583..1d29ea1 100644
@@ -27,6 +27,7 @@
 #include "exec/helper-gen.h"
 
 #include "tricore-opcodes.h"
+#include "exec/log.h"
 
 /*
  * TCG registers
target-unicore32/translate.c +1 -0
index d2f92f0..8e9e434 100644
@@ -24,6 +24,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 /* internal defines */
target-xtensa/translate.c +1 -0
index fbcec94..72dff3a 100644
@@ -43,6 +43,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 typedef struct DisasContext {
tcg/tcg.c +1 -0
index a163541..77c1365 100644
@@ -60,6 +60,7 @@
 #endif
 
 #include "elf.h"
+#include "exec/log.h"
 
 /* Forward declarations for functions declared in tcg-target.c and used here. */
 static void tcg_target_init(TCGContext *s);
translate-all.c +1 -0
index 042a857..4d5526d 100644
@@ -62,6 +62,7 @@
 #include "translate-all.h"
 #include "qemu/bitmap.h"
 #include "qemu/timer.h"
+#include "exec/log.h"
 
 //#define DEBUG_TB_INVALIDATE
 //#define DEBUG_FLUSH
Signature · 1 line
2.5.0
#8 lore raw

PATCH v4 8/11 log: move qemu-log.c into util/ directory

In reply to Denis V. Lunev

log will become common facility with tracepoints support in next step.

---
 Makefile.objs            | 1 -
 util/Makefile.objs       | 1 +
 qemu-log.c => util/log.c | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename qemu-log.c => util/log.c (100%)
Makefile.objs +0 -1
index dac2c02..b003533 100644
@@ -88,7 +88,6 @@ endif
 
 #######################################################################
 # Target-independent parts used in system and user emulation
-common-obj-y += qemu-log.o
 common-obj-y += tcg-runtime.o
 common-obj-y += hw/
 common-obj-y += qom/
util/Makefile.objs +1 -0
index 8620a80..a8a777e 100644
@@ -31,3 +31,4 @@ util-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o
 util-obj-y += buffer.o
 util-obj-y += timed-average.o
 util-obj-y += base64.o
+util-obj-y += log.o
util/log.c renamed from qemu-log.c +0 -0
similarity index 100%
rename from qemu-log.c
rename to util/log.c
Signature · 1 line
2.5.0
#9 lore raw

PATCH v4 9/11 trace: convert stderr backend to log

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

---
 configure                                       |  4 ++--
 include/qemu/log.h                              |  1 +
 scripts/tracetool/backend/{stderr.py => log.py} |  9 +++++----
 trace/control.c                                 | 10 ++++++++++
 util/log.c                                      |  3 +++
 vl.c                                            |  2 ++
 6 files changed, 23 insertions(+), 6 deletions(-)
 rename scripts/tracetool/backend/{stderr.py => log.py} (78%)
configure +2 -2
index 83b40fc..76d9ae6 100755
@@ -5375,8 +5375,8 @@ if have_backend "simple"; then
   # Set the appropriate trace file.
   trace_file="\"$trace_file-\" FMT_pid"
 fi
-if have_backend "stderr"; then
-  echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak
+if have_backend "log"; then
+  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
 fi
 if have_backend "ust"; then
   echo "CONFIG_TRACE_UST=y" >> $config_host_mak
include/qemu/log.h +1 -0
index 09722e3..30817f7 100644
@@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void)
 #define CPU_LOG_MMU        (1 << 12)
 #define CPU_LOG_TB_NOCHAIN (1 << 13)
 #define CPU_LOG_PAGE       (1 << 14)
+#define LOG_TRACE          (1 << 15)
 
 /* Returns true if a bit is set in the current loglevel mask
  */
scripts/tracetool/backend/log.py renamed from scripts/tracetool/backend/stderr.py +5 -4
similarity index 78%
rename from scripts/tracetool/backend/stderr.py
rename to scripts/tracetool/backend/log.py
index ca58054..a62c310 100644
@@ -25,6 +25,7 @@ def generate_h_begin(events):
         '#include <sys/types.h>',
         '#include <unistd.h>',
         '#include "trace/control.h"',
+        '#include "qemu/log.h"',
         '')
 
 
@@ -36,10 +37,10 @@ def generate_h(event):
     out('    if (trace_event_get_state(%(event_id)s)) {',
         '        struct timeval _now;',
         '        gettimeofday(&_now, NULL);',
-        '        fprintf(stderr, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
-        '                        getpid(),',
-        '                        (size_t)_now.tv_sec, (size_t)_now.tv_usec',
-        '                        %(argnames)s);',
+        '        qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
+        '                      getpid(),',
+        '                      (size_t)_now.tv_sec, (size_t)_now.tv_usec',
+        '                      %(argnames)s);',
         '    }',
         event_id="TRACE_" + event.name.upper(),
         name=event.name,
trace/control.c +10 -0
index 7c84795..9a1e381 100644
@@ -14,6 +14,9 @@
 #ifdef CONFIG_TRACE_FTRACE
 #include "trace/ftrace.h"
 #endif
+#ifdef CONFIG_TRACE_LOG
+#include "qemu/log.h"
+#endif
 #include "qemu/error-report.h"
 
 TraceEvent *trace_event_name(const char *name)
@@ -171,6 +174,13 @@ void trace_init_file(const char *file)
 {
 #ifdef CONFIG_TRACE_SIMPLE
     st_set_trace_file(file);
+#elif defined CONFIG_TRACE_LOG
+    /* If both the simple and the log backends are enabled, "-trace file"
+     * only applies to the simple backend; use "-D" for the log backend.
+     */
+    if (file) {
+        qemu_set_log_filename(file);
+    }
 #else
     if (file) {
         fprintf(stderr, "error: -trace file=...: "
util/log.c +3 -0
index 901b930..37185a5 100644
@@ -51,6 +51,9 @@ void qemu_log_mask(int mask, const char *fmt, ...)
 void do_qemu_set_log(int log_flags, bool use_own_buffers)
 {
     qemu_loglevel = log_flags;
+#ifdef CONFIG_TRACE_LOG
+    qemu_loglevel |= LOG_TRACE;
+#endif
     if (qemu_loglevel && !qemu_logfile) {
         if (logfilename) {
             qemu_logfile = fopen(logfilename, log_append ? "a" : "w");
vl.c +2 -0
index 01b39d4..6720839 100644
@@ -4121,6 +4121,8 @@ int main(int argc, char **argv, char **envp)
             exit(1);
         }
         qemu_set_log(mask);
+    } else {
+        qemu_set_log(0);
     }
 
     if (!trace_init_backends()) {
Signature · 1 line
2.5.0
#10 lore raw

PATCH v4 10/11 trace: switch default backend to "log"

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

This enables integration with other QEMU logging facilities.

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 76d9ae6..b08426e 100755
@@ -302,7 +302,7 @@ pkgversion=""
 pie=""
 zero_malloc=""
 qom_cast_debug="yes"
-trace_backends="nop"
+trace_backends="log"
 trace_file="trace"
 spice=""
 rbd=""
Signature · 1 line
2.5.0
#11 lore raw

PATCH v4 11/11 log: add "-d trace:PATTERN"

In reply to Denis V. Lunev

From: Paolo Bonzini <[email protected]>

This is a bit easier to use than "-trace" if you are also enabling other kinds of logging. It is also more discoverable for experienced QEMU users, and accessible from user-mode emulators.

---
 util/log.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
util/log.c +13 -3
index 37185a5..46c88c9 100644
@@ -19,6 +19,7 @@
 
 #include "qemu-common.h"
 #include "qemu/log.h"
+#include "trace/control.h"
 
 static char *logfilename;
 FILE *qemu_logfile;
@@ -154,6 +155,11 @@ int qemu_str_to_log_mask(const char *str)
             for (item = qemu_log_items; item->mask != 0; item++) {
                 mask |= item->mask;
             }
+#ifdef CONFIG_TRACE_LOG
+        } else if (strncmp(p, "trace:", 6) == 0 && p + 6 != p1) {
+            trace_enable_events(p + 6);
+            mask |= LOG_TRACE;
+#endif
         } else {
             for (item = qemu_log_items; item->mask != 0; item++) {
                 if (cmp1(p, p1 - p, item->name)) {
@@ -161,9 +167,9 @@ int qemu_str_to_log_mask(const char *str)
                 }
             }
             return 0;
+        found:
+            mask |= item->mask;
         }
-    found:
-        mask |= item->mask;
         if (*p1 != ',') {
             break;
         }
@@ -177,6 +183,10 @@ void qemu_print_log_usage(FILE *f)
     const QEMULogItem *item;
     fprintf(f, "Log items (comma separated):\n");
     for (item = qemu_log_items; item->mask != 0; item++) {
-        fprintf(f, "%-10s %s\n", item->name, item->help);
+        fprintf(f, "%-15s %s\n", item->name, item->help);
     }
+#ifdef CONFIG_TRACE_LOG
+    fprintf(f, "trace:PATTERN   enable trace events\n");
+    fprintf(f, "\nUse \"-d trace:help\" to get a list of trace events.\n\n");
+#endif
 }
Signature · 1 line
2.5.0
#12 lore raw
In reply to Denis V. Lunev
Quoted 17 lines · Denis V. Lunev

This series does three things:

1) add a "-trace [enable=]foo" option to enable one or more trace events, and a "-trace help" option to show the list of tracepoints (patches 4-5)

2) change the stderr tracing backend so that it prints to the -D log file, and enable it by default. "-trace file=..." is now a synonym of -D if the log backend is enabled (patches 7-8)

3) add a "-d trace:foo" option that is a synonym for "-trace foo"; this makes the new functionality more discoverable to people used to "-d", makes it available for user-mode emulation (which does not have -trace), and is somewhat nice if you want to enable both tracepoints and some other "-d" flag (patch 9). When globbing it is also less susceptible to unwanted shell expansion.

Quoted 5 lines

For example, you can trace block device I/O and save the result to a file just by adding "-trace bdrv_aio_*,file=trace.txt", or correlate it to guest PCs with "-d exec,nochain,trace:bdrv_aio_*".

Opinions? I would like to have this in 2.5 if there is agreement.

Stale sentence :)

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#13 lore raw
Quoted 18 lines · Eric Blake
Quoted 17 lines · Denis V. Lunev

This series does three things:

1) add a "-trace [enable=]foo" option to enable one or more trace events, and a "-trace help" option to show the list of tracepoints (patches 4-5)

2) change the stderr tracing backend so that it prints to the -D log file, and enable it by default. "-trace file=..." is now a synonym of -D if the log backend is enabled (patches 7-8)

3) add a "-d trace:foo" option that is a synonym for "-trace foo"; this makes the new functionality more discoverable to people used to "-d", makes it available for user-mode emulation (which does not have -trace), and is somewhat nice if you want to enable both tracepoints and some other "-d" flag (patch 9). When globbing it is also less susceptible to unwanted shell expansion.

Quoted 7 lines
Quoted 5 lines

For example, you can trace block device I/O and save the result to a file just by adding "-trace bdrv_aio_*,file=trace.txt", or correlate it to guest PCs with "-d exec,nochain,trace:bdrv_aio_*".

Opinions? I would like to have this in 2.5 if there is agreement.

Stale sentence :)

copy/paste forever :)

#14 lore raw
In reply to Denis V. Lunev
Quoted 123 lines · Denis V. Lunev

This series does three things:

1) add a "-trace [enable=]foo" option to enable one or more trace events, and a "-trace help" option to show the list of tracepoints (patches 4-5)

2) change the stderr tracing backend so that it prints to the -D log file, and enable it by default. "-trace file=..." is now a synonym of -D if the log backend is enabled (patches 7-8)

3) add a "-d trace:foo" option that is a synonym for "-trace foo"; this makes the new functionality more discoverable to people used to "-d", makes it available for user-mode emulation (which does not have -trace), and is somewhat nice if you want to enable both tracepoints and some other "-d" flag (patch 9). When globbing it is also less susceptible to unwanted shell expansion.

For example, you can trace block device I/O and save the result to a file just by adding "-trace bdrv_aio_*,file=trace.txt", or correlate it to guest PCs with "-d exec,nochain,trace:bdrv_aio_*".

Opinions? I would like to have this in 2.5 if there is agreement.

Changes from v3:
- fixed compilation of target-arm/translate-a64.c (patch 7)
- this warning is not observed in my environment /aarch64/qom/xlnx-ep108:
WARNING: RAM size 8000000 is small for EP108OK
- this warning after patch 10 is seen /microblaze/qom/petalogix-s3adsp1800:
Invalid MicroBlaze version number: (null)
OK
though the problem is here even before any patch of the set. It is just hidden as log is not enabled
- no problem for Win32 compilation with

     COLLECT_GCC=x86_64-w64-mingw32-gcc
     COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/lto-wrapper
     Target: x86_64-w64-mingw32
     Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libexecdir='/usr/lib/gcc-mingw-w64' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++ --enable-lto --with-plugin-ld --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld
     Thread model: win32
     gcc version 4.9.2 (GCC)

Changes from v2:
- compilation fix was extended to patch 2 and 3
- replaced Reviewed-by with Acked-by by request from Christian

Changes from v1:
- small cleanup to vl.c is added as patch (4)
- compilation is fixed in patch (2)
- moved qemu-log.c to util/log.c to fix linking of qemu-io/qemu-nbd

Denis V. Lunev (2):
trace: no need to call trace_backend_init in different branches now
log: move qemu-log.c into util/ directory

Paolo Bonzini (9):
trace: fix documentation
trace: split trace_init_events out of trace_init_backends
trace: split trace_init_file out of trace_init_backends
trace: add "-trace enable=..."
trace: add "-trace help"
log: do not unnecessarily include qom/cpu.h
trace: convert stderr backend to log
trace: switch default backend to "log"
log: add "-d trace:PATTERN"

  Makefile.objs                                   |  1 -
  bsd-user/main.c                                 |  1 +
  configure                                       |  6 +-
  cpu-exec.c                                      |  1 +
  exec.c                                          |  1 +
  hw/acpi/cpu_hotplug.c                           |  1 +
  hw/timer/a9gtimer.c                             |  1 +
  include/exec/log.h                              | 60 ++++++++++++++++
  include/qemu/log.h                              | 60 +---------------
  linux-user/main.c                               |  1 +
  qemu-io.c                                       |  2 +-
  qemu-options.hx                                 | 22 ++++--
  qom/cpu.c                                       |  1 +
  scripts/tracetool/backend/{stderr.py => log.py} |  9 +--
  target-alpha/translate.c                        |  1 +
  target-arm/translate-a64.c                      |  1 +
  target-arm/translate.c                          |  1 +
  target-cris/translate.c                         |  1 +
  target-i386/seg_helper.c                        |  1 +
  target-i386/smm_helper.c                        |  1 +
  target-i386/translate.c                         |  1 +
  target-lm32/helper.c                            |  1 +
  target-lm32/translate.c                         |  1 +
  target-m68k/translate.c                         |  1 +
  target-microblaze/helper.c                      |  1 +
  target-microblaze/translate.c                   |  1 +
  target-mips/helper.c                            |  1 +
  target-mips/translate.c                         |  1 +
  target-moxie/translate.c                        |  1 +
  target-openrisc/translate.c                     |  1 +
  target-ppc/mmu-hash32.c                         |  1 +
  target-ppc/mmu-hash64.c                         |  1 +
  target-ppc/mmu_helper.c                         |  1 +
  target-ppc/translate.c                          |  1 +
  target-s390x/translate.c                        |  1 +
  target-sh4/helper.c                             |  1 +
  target-sh4/translate.c                          |  1 +
  target-sparc/int32_helper.c                     |  1 +
  target-sparc/int64_helper.c                     |  1 +
  target-sparc/translate.c                        |  1 +
  target-tilegx/translate.c                       |  1 +
  target-tricore/translate.c                      |  1 +
  target-unicore32/translate.c                    |  1 +
  target-xtensa/translate.c                       |  1 +
  tcg/tcg.c                                       |  1 +
  trace/control.c                                 | 95 ++++++++++++++++++-------
  trace/control.h                                 | 42 ++++++++++-
  trace/simple.c                                  |  6 +-
  trace/simple.h                                  |  4 +-
  translate-all.c                                 |  1 +
  util/Makefile.objs                              |  1 +
  qemu-log.c => util/log.c                        | 19 ++++-
  vl.c                                            | 38 +++++-----
  53 files changed, 275 insertions(+), 129 deletions(-)
Quoted 4 lines

create mode 100644 include/exec/log.h
rename scripts/tracetool/backend/{stderr.py => log.py} (78%) rename qemu-log.c => util/log.c (90%)

ping

#15 lore raw
In reply to Denis V. Lunev
Quoted 118 lines · Denis V. Lunev

This series does three things:

1) add a "-trace [enable=]foo" option to enable one or more trace events, and a "-trace help" option to show the list of tracepoints (patches 4-5)

2) change the stderr tracing backend so that it prints to the -D log file, and enable it by default. "-trace file=..." is now a synonym of -D if the log backend is enabled (patches 7-8)

3) add a "-d trace:foo" option that is a synonym for "-trace foo"; this makes the new functionality more discoverable to people used to "-d", makes it available for user-mode emulation (which does not have -trace), and is somewhat nice if you want to enable both tracepoints and some other "-d" flag (patch 9). When globbing it is also less susceptible to unwanted shell expansion.

For example, you can trace block device I/O and save the result to a file just by adding "-trace bdrv_aio_*,file=trace.txt", or correlate it to guest PCs with "-d exec,nochain,trace:bdrv_aio_*".

Opinions? I would like to have this in 2.5 if there is agreement.

Changes from v3:
- fixed compilation of target-arm/translate-a64.c (patch 7)
- this warning is not observed in my environment /aarch64/qom/xlnx-ep108:
WARNING: RAM size 8000000 is small for EP108OK
- this warning after patch 10 is seen /microblaze/qom/petalogix-s3adsp1800:
Invalid MicroBlaze version number: (null)
OK
though the problem is here even before any patch of the set. It is just hidden as log is not enabled
- no problem for Win32 compilation with

    COLLECT_GCC=x86_64-w64-mingw32-gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/4.9-win32/lto-wrapper
    Target: x86_64-w64-mingw32
    Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libexecdir='/usr/lib/gcc-mingw-w64' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++ --enable-lto --with-plugin-ld --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld
    Thread model: win32
    gcc version 4.9.2 (GCC)

Changes from v2:
- compilation fix was extended to patch 2 and 3
- replaced Reviewed-by with Acked-by by request from Christian

Changes from v1:
- small cleanup to vl.c is added as patch (4)
- compilation is fixed in patch (2)
- moved qemu-log.c to util/log.c to fix linking of qemu-io/qemu-nbd

Denis V. Lunev (2):
trace: no need to call trace_backend_init in different branches now
log: move qemu-log.c into util/ directory

Paolo Bonzini (9):
trace: fix documentation
trace: split trace_init_events out of trace_init_backends
trace: split trace_init_file out of trace_init_backends
trace: add "-trace enable=..."
trace: add "-trace help"
log: do not unnecessarily include qom/cpu.h
trace: convert stderr backend to log
trace: switch default backend to "log"
log: add "-d trace:PATTERN"

 Makefile.objs                                   |  1 -
 bsd-user/main.c                                 |  1 +
 configure                                       |  6 +-
 cpu-exec.c                                      |  1 +
 exec.c                                          |  1 +
 hw/acpi/cpu_hotplug.c                           |  1 +
 hw/timer/a9gtimer.c                             |  1 +
 include/exec/log.h                              | 60 ++++++++++++++++
 include/qemu/log.h                              | 60 +---------------
 linux-user/main.c                               |  1 +
 qemu-io.c                                       |  2 +-
 qemu-options.hx                                 | 22 ++++--
 qom/cpu.c                                       |  1 +
 scripts/tracetool/backend/{stderr.py => log.py} |  9 +--
 target-alpha/translate.c                        |  1 +
 target-arm/translate-a64.c                      |  1 +
 target-arm/translate.c                          |  1 +
 target-cris/translate.c                         |  1 +
 target-i386/seg_helper.c                        |  1 +
 target-i386/smm_helper.c                        |  1 +
 target-i386/translate.c                         |  1 +
 target-lm32/helper.c                            |  1 +
 target-lm32/translate.c                         |  1 +
 target-m68k/translate.c                         |  1 +
 target-microblaze/helper.c                      |  1 +
 target-microblaze/translate.c                   |  1 +
 target-mips/helper.c                            |  1 +
 target-mips/translate.c                         |  1 +
 target-moxie/translate.c                        |  1 +
 target-openrisc/translate.c                     |  1 +
 target-ppc/mmu-hash32.c                         |  1 +
 target-ppc/mmu-hash64.c                         |  1 +
 target-ppc/mmu_helper.c                         |  1 +
 target-ppc/translate.c                          |  1 +
 target-s390x/translate.c                        |  1 +
 target-sh4/helper.c                             |  1 +
 target-sh4/translate.c                          |  1 +
 target-sparc/int32_helper.c                     |  1 +
 target-sparc/int64_helper.c                     |  1 +
 target-sparc/translate.c                        |  1 +
 target-tilegx/translate.c                       |  1 +
 target-tricore/translate.c                      |  1 +
 target-unicore32/translate.c                    |  1 +
 target-xtensa/translate.c                       |  1 +
 tcg/tcg.c                                       |  1 +
 trace/control.c                                 | 95 ++++++++++++++++++-------
 trace/control.h                                 | 42 ++++++++++-
 trace/simple.c                                  |  6 +-
 trace/simple.h                                  |  4 +-
Quoted 12 lines
 translate-all.c                                 |  1 +
 util/Makefile.objs                              |  1 +
 qemu-log.c => util/log.c                        | 19 ++++-
 vl.c                                            | 38 +++++-----
 53 files changed, 275 insertions(+), 129 deletions(-)
 create mode 100644 include/exec/log.h
 rename scripts/tracetool/backend/{stderr.py => log.py} (78%)
 rename qemu-log.c => util/log.c (90%)
Signature · 1 line
2.5.0

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan