Skip to contentSkip to conversation

Tracing patches

GIT PULL Stefan Hajnoczi 8 participants 26 messages Feb 3, 2016 – Feb 9, 2016 Kbuild

lore
Share & tools
lore
#1 lore raw

[Qemu-devel] [PULL 01/13] trace: count number of enabled events

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

This lets trace_event_get_state_dynamic quickly return false. Right now there is hardly any benefit because there are also many assertions and indirections, but the next patch will streamline all of this.

---
 trace/control-internal.h | 4 +++-
 trace/control.c          | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
trace/control-internal.h +3 -1
index 5a8df28..271bddb 100644
@@ -14,6 +14,7 @@
 
 
 extern TraceEvent trace_events[];
+extern int trace_events_enabled_count;
 
 
 static inline TraceEventID trace_event_count(void)
@@ -54,13 +55,14 @@ static inline bool trace_event_get_state_static(TraceEvent *ev)
 static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
 {
     assert(ev != NULL);
-    return ev->dstate;
+    return unlikely(trace_events_enabled_count) && ev->dstate;
 }
 
 static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
 {
     assert(ev != NULL);
     assert(trace_event_get_state_static(ev));
+    trace_events_enabled_count += state - ev->dstate;
     ev->dstate = state;
 }
 
trace/control.c +2 -0
index 995beb3..95fbc07 100644
@@ -16,6 +16,8 @@
 #endif
 #include "qemu/error-report.h"
 
+int trace_events_enabled_count;
+
 TraceEvent *trace_event_name(const char *name)
 {
     assert(name != NULL);
Signature · 1 line
2.5.0
#0 lore raw

The following changes since commit c65db7705b7926f4a084b93778e4bd5dd3990aad:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-for-peter-2016-02-02' into staging (2016-02-02 18:04:04 +0000)

are available in the git repository at:

git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to c84ea00dc29b2084a62bd31f498ed0f245d3848e:

log: add "-d trace:PATTERN" (2016-02-03 10:37:50 +0000)

----------------------------------------------------------------

----------------------------------------------------------------

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 (11):
trace: count number of enabled events
trace: track enabled events in a separate array
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"

 .travis.yml                          |   2 +-
 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-log.c                           | 179 --------------------------------
 qemu-options.hx                      |  22 ++--
 qom/cpu.c                            |   1 +
 scripts/tracetool/backend/log.py     |  48 +++++++++
 scripts/tracetool/backend/stderr.py  |  47 ---------
 scripts/tracetool/format/events_c.py |   2 +-
 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-internal.h             |  15 ++-
 trace/control.c                      |  98 +++++++++++++-----
 trace/control.h                      |  44 +++++++-
 trace/event-internal.h               |   2 -
 trace/simple.c                       |   6 +-
 trace/simple.h                       |   4 +-
 translate-all.c                      |   1 +
 util/Makefile.objs                   |   1 +
 util/log.c                           | 192 +++++++++++++++++++++++++++++++++++
 vl.c                                 |  38 ++++---
 59 files changed, 512 insertions(+), 356 deletions(-)
 create mode 100644 include/exec/log.h
 delete mode 100644 qemu-log.c
 create mode 100644 scripts/tracetool/backend/log.py
 delete mode 100644 scripts/tracetool/backend/stderr.py
 create mode 100644 util/log.c
Signature · 1 line
2.5.0
#2 lore raw

[Qemu-devel] [PULL 03/13] trace: fix documentation

From: Paolo Bonzini <[email protected]>

Mention the ftrace backend too.

Message-id: [email protected]

---
 qemu-options.hx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
qemu-options.hx +5 -5
index f31a240..cbb4590 100644
@@ -3558,13 +3558,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
#3 lore raw

[Qemu-devel] [PULL 02/13] trace: track enabled events in a separate array

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

This is more cache friendly on the fast path, where we already have the event id available.

---
 scripts/tracetool/format/events_c.py |  2 +-
 trace/control-internal.h             | 15 +++++++++++----
 trace/control.c                      |  1 +
 trace/control.h                      |  2 +-
 trace/event-internal.h               |  2 --
 5 files changed, 14 insertions(+), 8 deletions(-)
scripts/tracetool/format/events_c.py +1 -1
index 2d97fa3..2717ea3 100644
@@ -27,7 +27,7 @@ def generate(events, backend):
     out('TraceEvent trace_events[TRACE_EVENT_COUNT] = {')
 
     for e in events:
-        out('    { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s, .dstate = 0 },',
+        out('    { .id = %(id)s, .name = \"%(name)s\", .sstate = %(sstate)s },',
             id = "TRACE_" + e.name.upper(),
             name = e.name,
             sstate = "TRACE_%s_ENABLED" % e.name.upper())
trace/control-internal.h +11 -4
index 271bddb..07cb1c1 100644
@@ -14,6 +14,7 @@
 
 
 extern TraceEvent trace_events[];
+extern bool trace_events_dstate[];
 extern int trace_events_enabled_count;
 
 
@@ -52,18 +53,24 @@ static inline bool trace_event_get_state_static(TraceEvent *ev)
     return ev->sstate;
 }
 
+static inline bool trace_event_get_state_dynamic_by_id(int id)
+{
+    return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
+}
+
 static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
 {
-    assert(ev != NULL);
-    return unlikely(trace_events_enabled_count) && ev->dstate;
+    int id = trace_event_get_id(ev);
+    return trace_event_get_state_dynamic_by_id(id);
 }
 
 static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
 {
+    int id = trace_event_get_id(ev);
     assert(ev != NULL);
     assert(trace_event_get_state_static(ev));
-    trace_events_enabled_count += state - ev->dstate;
-    ev->dstate = state;
+    trace_events_enabled_count += state - trace_events_dstate[id];
+    trace_events_dstate[id] = state;
 }
 
 #endif  /* TRACE__CONTROL_INTERNAL_H */
trace/control.c +1 -0
index 95fbc07..700440c 100644
@@ -17,6 +17,7 @@
 #include "qemu/error-report.h"
 
 int trace_events_enabled_count;
+bool trace_events_dstate[TRACE_EVENT_COUNT];
 
 TraceEvent *trace_event_name(const char *name)
 {
trace/control.h +1 -1
index da9bb6b..6af7ddc 100644
@@ -104,7 +104,7 @@ static const char * trace_event_get_name(TraceEvent *ev);
  * As a down side, you must always use an immediate #TraceEventID value.
  */
 #define trace_event_get_state(id)                       \
-    ((id ##_ENABLED) && trace_event_get_state_dynamic(trace_event_id(id)))
+    ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
 
 /**
  * trace_event_get_state_static:
trace/event-internal.h +0 -2
index b2310d9..86f6a51 100644
@@ -18,7 +18,6 @@
  * @id: Unique event identifier.
  * @name: Event name.
  * @sstate: Static tracing state.
- * @dstate: Dynamic tracing state.
  *
  * Opaque generic description of a tracing event.
  */
@@ -26,7 +25,6 @@ typedef struct TraceEvent {
     TraceEventID id;
     const char * name;
     const bool sstate;
-    bool dstate;
 } TraceEvent;
 
 
Signature · 1 line
2.5.0
#4 lore raw

[Qemu-devel] [PULL 04/13] trace: split trace_init_events out of trace_init_backends

In reply to Stefan Hajnoczi

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.

Message-id: [email protected]

---
 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 d593f19..1c11d57 100644
@@ -435,7 +435,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 700440c..931d64c 100644
@@ -88,7 +88,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;
@@ -145,7 +145,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)) {
@@ -167,6 +167,5 @@ bool trace_init_backends(const char *events, const char *file)
     }
 #endif
 
-    trace_init_events(events);
     return true;
 }
trace/control.h +12 -3
index 6af7ddc..7905917 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 f043009..ff2a7d5 100644
@@ -2988,7 +2988,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;
@@ -3905,8 +3904,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:
@@ -4106,7 +4106,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);
         }
     }
@@ -4653,7 +4653,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
#5 lore raw

[Qemu-devel] [PULL 05/13] trace: split trace_init_file out of trace_init_backends

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

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

Message-id: [email protected]

---
 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 1c11d57..83c48f4 100644
@@ -435,7 +435,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 931d64c..f5a497a 100644
@@ -145,17 +145,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 7905917..d50f399 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 ff2a7d5..955f364 100644
@@ -2988,7 +2988,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;
@@ -3905,7 +3905,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;
             }
@@ -4089,6 +4092,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) {
@@ -4106,7 +4111,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (!is_daemonized()) {
-        if (!trace_init_backends(trace_file)) {
+        if (!trace_init_backends()) {
             exit(1);
         }
     }
@@ -4653,7 +4658,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
#10 lore raw

[Qemu-devel] [PULL 06/13] trace: no need to call trace_backend_init in different branches now

In reply to Stefan Hajnoczi

From: "Denis V. Lunev" <[email protected]>

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.

Message-id: [email protected]

---
 vl.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
vl.c +2 -10
index 955f364..6370efe 100644
@@ -4110,10 +4110,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
@@ -4657,12 +4655,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
#11 lore raw

[Qemu-devel] [PULL 07/13] trace: add "-trace enable=..."

In reply to Stefan Hajnoczi

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).

Message-id: [email protected]

---
 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 cbb4590..35dc725 100644
@@ -3544,7 +3544,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
@@ -3556,6 +3556,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 d50f399..d5081ce 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 6370efe..58cc050 100644
@@ -270,10 +270,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,
         },{
@@ -3900,10 +3904,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
#12 lore raw

[Qemu-devel] [PULL 08/13] trace: add "-trace help"

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

Print a list of trace points

Message-id: [email protected]

---
 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 35dc725..733a194 100644
@@ -3564,6 +3564,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 af92705..bef7884 100644
@@ -88,7 +88,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;
@@ -114,6 +123,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 d5081ce..d5bc86e 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
#13 lore raw

[Qemu-devel] [PULL 09/13] log: do not unnecessarily include qom/cpu.h

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

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

Message-id: [email protected]

---
 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 c459364..fd92452 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 9e076bc..ab37360 100644
@@ -52,6 +52,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 2f99ec5..5a410a5 100644
@@ -12,6 +12,7 @@
 #include "qemu/osdep.h"
 #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 c11a7bc..fa4602c 100644
@@ -25,6 +25,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 f8d4577..e719a2d 100644
@@ -28,6 +28,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 8f537a4..38dc713 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 7d419d9..c96adbb 100644
@@ -28,6 +28,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 80f6c20..2af7d86 100644
@@ -31,6 +31,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 cff511b..3ec758a 100644
@@ -32,6 +32,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 295005f..0350cb5 100644
@@ -35,6 +35,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 4c7cab7..4f26941 100644
@@ -23,6 +23,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 b930421..e7bb5be 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "exec/helper-proto.h"
+#include "exec/log.h"
 
 /* SMM support */
 
target-i386/translate.c +1 -0
index 957a92d..73a45c8 100644
@@ -28,6 +28,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 3ebec68..655248f 100644
@@ -22,6 +22,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 477d428..52fe562 100644
@@ -29,6 +29,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 342c040..a402bd8 100644
@@ -29,6 +29,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 3b0fae8..4de6bdb 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "qemu/host-utils.h"
+#include "exec/log.h"
 
 #define D(x)
 
target-microblaze/translate.c +1 -0
index 2e1293d..40be4ec 100644
@@ -28,6 +28,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 f9c4c11..1004ede 100644
@@ -21,6 +21,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 383d4b5..791866b 100644
@@ -33,6 +33,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 229ce3b..04ab278 100644
@@ -31,6 +31,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 62890c2..b766b27 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 b076d80..39abb2f 100644
@@ -24,6 +24,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 6d110ee..9c58fbf 100644
@@ -25,6 +25,7 @@
 #include "qemu/error-report.h"
 #include "kvm_ppc.h"
 #include "mmu-hash64.h"
+#include "exec/log.h"
 
 //#define DEBUG_SLB
 
target-ppc/mmu_helper.c +1 -0
index de4e286..e5ec8d6 100644
@@ -24,6 +24,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 7db3145..0057bda 100644
@@ -29,6 +29,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 811928b..3087692 100644
@@ -44,6 +44,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 9d8b61c..6438338 100644
@@ -19,6 +19,7 @@
 #include "qemu/osdep.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 9de5659..3e4164b 100644
@@ -29,6 +29,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 d4d6a4b..09afe13 100644
@@ -21,6 +21,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 ddef66b..aa876cd 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #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 747f94d..6726860 100644
@@ -29,6 +29,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 #define DEBUG_DISAS
target-tilegx/translate.c +1 -0
index 2088f87..a5bb8d4 100644
@@ -21,6 +21,7 @@
 #include "qemu/osdep.h"
 #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 2b07b86..e385fc7 100644
@@ -28,6 +28,7 @@
 #include "exec/helper-gen.h"
 
 #include "tricore-opcodes.h"
+#include "exec/log.h"
 
 /*
  * TCG registers
target-unicore32/translate.c +1 -0
index 5db8f94..7dbfe3b 100644
@@ -20,6 +20,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/log.h"
 
 
 /* internal defines */
target-xtensa/translate.c +1 -0
index a8c1113..435ee03 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 3ce02dc..be765ad 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 ab61fac..e9f409b 100644
@@ -55,6 +55,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
#14 lore raw

[Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory

In reply to Stefan Hajnoczi

From: "Denis V. Lunev" <[email protected]>

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

Message-id: [email protected]

---
 Makefile.objs      |   1 -
 qemu-log.c         | 179 -----------------------------------------------------
 util/Makefile.objs |   1 +
 util/log.c         | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 180 insertions(+), 180 deletions(-)
 delete mode 100644 qemu-log.c
 create mode 100644 util/log.c
Makefile.objs +0 -1
index 06b95c7..fbcaa74 100644
@@ -89,7 +89,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/
qemu-log.c deleted +0 -179

179 lines not on this page · raw message

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 new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
2.5.0
#20 lore raw

[Qemu-devel] [PULL 11/13] trace: convert stderr backend to log

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

[Also update .travis.yml --enable-trace-backends=stderr --Stefan]

Message-id: [email protected]

---
 .travis.yml                         |  2 +-
 configure                           |  4 ++--
 include/qemu/log.h                  |  1 +
 scripts/tracetool/backend/log.py    | 48 +++++++++++++++++++++++++++++++++++++
 scripts/tracetool/backend/stderr.py | 47 ------------------------------------
 trace/control.c                     | 10 ++++++++
 util/log.c                          |  3 +++
 vl.c                                |  2 ++
 8 files changed, 67 insertions(+), 50 deletions(-)
 create mode 100644 scripts/tracetool/backend/log.py
 delete mode 100644 scripts/tracetool/backend/stderr.py
.travis.yml +1 -1
index 6ca0260..0428aed 100644
@@ -78,7 +78,7 @@ matrix:
       compiler: gcc
     # All the trace backends (apart from dtrace)
     - env: TARGETS=i386-softmmu,x86_64-softmmu
-           EXTRA_CONFIG="--enable-trace-backends=stderr"
+           EXTRA_CONFIG="--enable-trace-backends=log"
       compiler: gcc
     - env: TARGETS=i386-softmmu,x86_64-softmmu
            EXTRA_CONFIG="--enable-trace-backends=simple"
configure +2 -2
index 297bfc7..92c2616 100755
@@ -5445,8 +5445,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 new file +48 -0

48 lines not on this page · raw message

scripts/tracetool/backend/stderr.py deleted +0 -47

47 lines not on this page · raw message

trace/control.c +10 -0
index bef7884..84ea840 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"
 
 int trace_events_enabled_count;
@@ -174,6 +177,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 58cc050..a7d7c39 100644
@@ -4115,6 +4115,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
#21 lore raw

[Qemu-devel] [PULL 12/13] trace: switch default backend to "log"

In reply to Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

This enables integration with other QEMU logging facilities.

Message-id: [email protected]

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
index 92c2616..d4411a1 100755
@@ -303,7 +303,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
#22 lore raw

[Qemu-devel] [PULL 13/13] log: add "-d trace:PATTERN"

In reply to Stefan Hajnoczi

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.

Message-id: [email protected]

---
 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
#15 lore raw

Re: [Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory

In reply to Stefan Hajnoczi
Quoted 9 lines · Stefan Hajnoczi

From: "Denis V. Lunev" <[email protected]>

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

Message-id: [email protected]

Quoted 8 lines
---
 Makefile.objs      |   1 -
 qemu-log.c         | 179 -----------------------------------------------------
 util/Makefile.objs |   1 +
 util/log.c         | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 180 insertions(+), 180 deletions(-)
 delete mode 100644 qemu-log.c
 create mode 100644 util/log.c

Note we don't have a MAINTAINERS entry for the log code currently. Need some unlucky volunteer.... ?

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#16 lore raw

Re: [Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory

Quoted 18 lines · Daniel P. Berrange
Quoted 9 lines · Stefan Hajnoczi

From: "Denis V. Lunev" <[email protected]>

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

Message-id: [email protected]

Quoted 8 lines
---
  Makefile.objs      |   1 -
  qemu-log.c         | 179 -----------------------------------------------------
  util/Makefile.objs |   1 +
  util/log.c         | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  4 files changed, 180 insertions(+), 180 deletions(-)

delete mode 100644 qemu-log.c
create mode 100644 util/log.c

Quoted 5 lines

Note we don't have a MAINTAINERS entry for the log code currently. Need some unlucky volunteer.... ?

Regards,
Daniel

why unlucky? :)

Actually we can manage this as a part of tracing
or sign me if there is no other willing person
at the moment if this will be good to all other
parties.

Den

#17 lore raw

Re: [Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory

In reply to Daniel P. Berrange
Quoted 19 lines · Daniel P. Berrange
Quoted 9 lines · Stefan Hajnoczi

From: "Denis V. Lunev" <[email protected]>

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

Message-id: [email protected]

Quoted 8 lines
---
 Makefile.objs      |   1 -
 qemu-log.c         | 179 -----------------------------------------------------
 util/Makefile.objs |   1 +
 util/log.c         | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 180 insertions(+), 180 deletions(-)
 delete mode 100644 qemu-log.c
 create mode 100644 util/log.c
Quoted 2 lines

Note we don't have a MAINTAINERS entry for the log code currently. Need some unlucky volunteer.... ?

A while ago, we mentioned the idea of tweaking checkpatch.pl to prevent the addition of any new files without coverage in MAINTAINERS. Is anyone up to the task of hacking that in? (My perl is too weak, or I might volunteer)

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

Re: [Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory

In reply to Stefan Hajnoczi

Hi all,

A while ago me and Alex [cc'ed] submitted a trivial patch related to logging [1]. Since this patch set here moves the qemu-log.c under util/, our patch will not apply any more. Should we rebase it and resend it against current master?

Thanks a lot,
dimara

[1] https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg02687.html

Quoted 412 lines · Stefan Hajnoczi

From: "Denis V. Lunev" <[email protected]>

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

Message-id: [email protected]

---
 Makefile.objs      |   1 -
 qemu-log.c         | 179 -----------------------------------------------------
 util/Makefile.objs |   1 +
 util/log.c         | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 180 insertions(+), 180 deletions(-)
 delete mode 100644 qemu-log.c
 create mode 100644 util/log.c
Makefile.objs +0 -1
index 06b95c7..fbcaa74 100644
@@ -89,7 +89,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/
qemu-log.c deleted +0 -179
deleted file mode 100644
index 901b930..0000000
@@ -1,179 +0,0 @@
-/*
- * Logging support
- *
- *  Copyright (c) 2003 Fabrice Bellard
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "qemu-common.h"
-#include "qemu/log.h"
-
-static char *logfilename;
-FILE *qemu_logfile;
-int qemu_loglevel;
-static int log_append = 0;
-
-void qemu_log(const char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    if (qemu_logfile) {
-        vfprintf(qemu_logfile, fmt, ap);
-    }
-    va_end(ap);
-}
-
-void qemu_log_mask(int mask, const char *fmt, ...)
-{
-    va_list ap;
-
-    va_start(ap, fmt);
-    if ((qemu_loglevel & mask) && qemu_logfile) {
-        vfprintf(qemu_logfile, fmt, ap);
-    }
-    va_end(ap);
-}
-
-/* enable or disable low levels log */
-void do_qemu_set_log(int log_flags, bool use_own_buffers)
-{
-    qemu_loglevel = log_flags;
-    if (qemu_loglevel && !qemu_logfile) {
-        if (logfilename) {
-            qemu_logfile = fopen(logfilename, log_append ? "a" : "w");
-            if (!qemu_logfile) {
-                perror(logfilename);
-                _exit(1);
-            }
-        } else {
-            /* Default to stderr if no log file specified */
-            qemu_logfile = stderr;
-        }
-        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
-        if (use_own_buffers) {
-            static char logfile_buf[4096];
-
-            setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
-        } else {
-#if defined(_WIN32)
-            /* Win32 doesn't support line-buffering, so use unbuffered output. */
-            setvbuf(qemu_logfile, NULL, _IONBF, 0);
-#else
-            setvbuf(qemu_logfile, NULL, _IOLBF, 0);
-#endif
-            log_append = 1;
-        }
-    }
-    if (!qemu_loglevel && qemu_logfile) {
-        qemu_log_close();
-    }
-}
-
-void qemu_set_log_filename(const char *filename)
-{
-    g_free(logfilename);
-    logfilename = g_strdup(filename);
-    qemu_log_close();
-    qemu_set_log(qemu_loglevel);
-}
-
-const QEMULogItem qemu_log_items[] = {
-    { CPU_LOG_TB_OUT_ASM, "out_asm",
-      "show generated host assembly code for each compiled TB" },
-    { CPU_LOG_TB_IN_ASM, "in_asm",
-      "show target assembly code for each compiled TB" },
-    { CPU_LOG_TB_OP, "op",
-      "show micro ops for each compiled TB" },
-    { CPU_LOG_TB_OP_OPT, "op_opt",
-      "show micro ops (x86 only: before eflags optimization) and\n"
-      "after liveness analysis" },
-    { CPU_LOG_INT, "int",
-      "show interrupts/exceptions in short format" },
-    { CPU_LOG_EXEC, "exec",
-      "show trace before each executed TB (lots of logs)" },
-    { CPU_LOG_TB_CPU, "cpu",
-      "show CPU state before block translation" },
-    { CPU_LOG_MMU, "mmu",
-      "log MMU-related activities" },
-    { CPU_LOG_PCALL, "pcall",
-      "x86 only: show protected mode far calls/returns/exceptions" },
-    { CPU_LOG_RESET, "cpu_reset",
-      "show CPU state before CPU resets" },
-    { LOG_UNIMP, "unimp",
-      "log unimplemented functionality" },
-    { LOG_GUEST_ERROR, "guest_errors",
-      "log when the guest OS does something invalid (eg accessing a\n"
-      "non-existent register)" },
-    { CPU_LOG_PAGE, "page",
-      "dump pages at beginning of user mode emulation" },
-    { CPU_LOG_TB_NOCHAIN, "nochain",
-      "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
-      "complete traces" },
-    { 0, NULL, NULL },
-};
-
-static int cmp1(const char *s1, int n, const char *s2)
-{
-    if (strlen(s2) != n) {
-        return 0;
-    }
-    return memcmp(s1, s2, n) == 0;
-}
-
-/* takes a comma separated list of log masks. Return 0 if error. */
-int qemu_str_to_log_mask(const char *str)
-{
-    const QEMULogItem *item;
-    int mask;
-    const char *p, *p1;
-
-    p = str;
-    mask = 0;
-    for (;;) {
-        p1 = strchr(p, ',');
-        if (!p1) {
-            p1 = p + strlen(p);
-        }
-        if (cmp1(p,p1-p,"all")) {
-            for (item = qemu_log_items; item->mask != 0; item++) {
-                mask |= item->mask;
-            }
-        } else {
-            for (item = qemu_log_items; item->mask != 0; item++) {
-                if (cmp1(p, p1 - p, item->name)) {
-                    goto found;
-                }
-            }
-            return 0;
-        }
-    found:
-        mask |= item->mask;
-        if (*p1 != ',') {
-            break;
-        }
-        p = p1 + 1;
-    }
-    return mask;
-}
-
-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);
-    }
-}
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 new file +179 -0
new file mode 100644
index 0000000..901b930
@@ -0,0 +1,179 @@
+/*
+ * Logging support
+ *
+ *  Copyright (c) 2003 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu-common.h"
+#include "qemu/log.h"
+
+static char *logfilename;
+FILE *qemu_logfile;
+int qemu_loglevel;
+static int log_append = 0;
+
+void qemu_log(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    if (qemu_logfile) {
+        vfprintf(qemu_logfile, fmt, ap);
+    }
+    va_end(ap);
+}
+
+void qemu_log_mask(int mask, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    if ((qemu_loglevel & mask) && qemu_logfile) {
+        vfprintf(qemu_logfile, fmt, ap);
+    }
+    va_end(ap);
+}
+
+/* enable or disable low levels log */
+void do_qemu_set_log(int log_flags, bool use_own_buffers)
+{
+    qemu_loglevel = log_flags;
+    if (qemu_loglevel && !qemu_logfile) {
+        if (logfilename) {
+            qemu_logfile = fopen(logfilename, log_append ? "a" : "w");
+            if (!qemu_logfile) {
+                perror(logfilename);
+                _exit(1);
+            }
+        } else {
+            /* Default to stderr if no log file specified */
+            qemu_logfile = stderr;
+        }
+        /* must avoid mmap() usage of glibc by setting a buffer "by hand" */
+        if (use_own_buffers) {
+            static char logfile_buf[4096];
+
+            setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
+        } else {
+#if defined(_WIN32)
+            /* Win32 doesn't support line-buffering, so use unbuffered output. */
+            setvbuf(qemu_logfile, NULL, _IONBF, 0);
+#else
+            setvbuf(qemu_logfile, NULL, _IOLBF, 0);
+#endif
+            log_append = 1;
+        }
+    }
+    if (!qemu_loglevel && qemu_logfile) {
+        qemu_log_close();
+    }
+}
+
+void qemu_set_log_filename(const char *filename)
+{
+    g_free(logfilename);
+    logfilename = g_strdup(filename);
+    qemu_log_close();
+    qemu_set_log(qemu_loglevel);
+}
+
+const QEMULogItem qemu_log_items[] = {
+    { CPU_LOG_TB_OUT_ASM, "out_asm",
+      "show generated host assembly code for each compiled TB" },
+    { CPU_LOG_TB_IN_ASM, "in_asm",
+      "show target assembly code for each compiled TB" },
+    { CPU_LOG_TB_OP, "op",
+      "show micro ops for each compiled TB" },
+    { CPU_LOG_TB_OP_OPT, "op_opt",
+      "show micro ops (x86 only: before eflags optimization) and\n"
+      "after liveness analysis" },
+    { CPU_LOG_INT, "int",
+      "show interrupts/exceptions in short format" },
+    { CPU_LOG_EXEC, "exec",
+      "show trace before each executed TB (lots of logs)" },
+    { CPU_LOG_TB_CPU, "cpu",
+      "show CPU state before block translation" },
+    { CPU_LOG_MMU, "mmu",
+      "log MMU-related activities" },
+    { CPU_LOG_PCALL, "pcall",
+      "x86 only: show protected mode far calls/returns/exceptions" },
+    { CPU_LOG_RESET, "cpu_reset",
+      "show CPU state before CPU resets" },
+    { LOG_UNIMP, "unimp",
+      "log unimplemented functionality" },
+    { LOG_GUEST_ERROR, "guest_errors",
+      "log when the guest OS does something invalid (eg accessing a\n"
+      "non-existent register)" },
+    { CPU_LOG_PAGE, "page",
+      "dump pages at beginning of user mode emulation" },
+    { CPU_LOG_TB_NOCHAIN, "nochain",
+      "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
+      "complete traces" },
+    { 0, NULL, NULL },
+};
+
+static int cmp1(const char *s1, int n, const char *s2)
+{
+    if (strlen(s2) != n) {
+        return 0;
+    }
+    return memcmp(s1, s2, n) == 0;
+}
+
+/* takes a comma separated list of log masks. Return 0 if error. */
+int qemu_str_to_log_mask(const char *str)
+{
+    const QEMULogItem *item;
+    int mask;
+    const char *p, *p1;
+
+    p = str;
+    mask = 0;
+    for (;;) {
+        p1 = strchr(p, ',');
+        if (!p1) {
+            p1 = p + strlen(p);
+        }
+        if (cmp1(p,p1-p,"all")) {
+            for (item = qemu_log_items; item->mask != 0; item++) {
+                mask |= item->mask;
+            }
+        } else {
+            for (item = qemu_log_items; item->mask != 0; item++) {
+                if (cmp1(p, p1 - p, item->name)) {
+                    goto found;
+                }
+            }
+            return 0;
+        }
+    found:
+        mask |= item->mask;
+        if (*p1 != ',') {
+            break;
+        }
+        p = p1 + 1;
+    }
+    return mask;
+}
+
+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);
+    }
+}
Signature · 1 line
2.5.0
#23 lore raw
In reply to Stefan Hajnoczi
Quoted 6 lines · Stefan Hajnoczi

The following changes since commit c65db7705b7926f4a084b93778e4bd5dd3990aad:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-for-peter-2016-02-02' into staging (2016-02-02 18:04:04 +0000)

are available in the git repository at:

Quoted 7 lines

git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to c84ea00dc29b2084a62bd31f498ed0f245d3848e:

log: add "-d trace:PATTERN" (2016-02-03 10:37:50 +0000)

----------------------------------------------------------------

Hi. I'm afraid this fails to compile on Windows:

In file included from /home/petmay01/linaro/qemu-for-merges/include/trace.h:4,
from
/home/petmay01/linaro/qemu-for-merges/util/oslib-win32.c:38:
./trace/generated-tracers.h: In function ‘trace_virtio_console_flush_buf’:
./trace/generated-tracers.h:240: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 8 has type ‘ssize_t’
CC util/hbitmap.o
./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_so’:
./trace/generated-tracers.h:2784: warning: format ‘%zu’ expects type ‘size_t’, but argument 11 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_data_overrun’:
./trace/generated-tracers.h:2796: warning: format ‘%zu’ expects type ‘size_t’, but argument 7 has type ‘ssize_t’
CC util/fifo8.o
CC util/acl.o
./trace/generated-tracers.h: In function ‘trace_spice_vmc_write’:
./trace/generated-tracers.h:6516: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 6 has type ‘ssize_t’
CC util/error.o
CC util/qemu-error.o
cc1: warnings being treated as errors
In file included from /home/petmay01/linaro/qemu-for-merges/include/trace.h:4,
from /home/petmay01/linaro/qemu-for-merges/util/hbitmap.c:18:
./trace/generated-tracers.h: In function ‘trace_virtio_console_flush_buf’:
./trace/generated-tracers.h:240: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 8 has type ‘ssize_t’
CC util/id.o
CC util/iov.o
./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_so’:./trace/generated-tracers.h: In function ‘trace_v9fs_read_return’:
./trace/generated-tracers.h:2784: warning: format ‘%zu’ expects type ‘size_t’, but argument 11 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_data_overrun’:
./trace/generated-tracers.h:2796: warning: format ‘%zu’ expects type ‘size_t’, but argument 7 has type ‘ssize_t’

./trace/generated-tracers.h:10368: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_readdir_return’:
./trace/generated-tracers.h:10392: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_write_return’:
./trace/generated-tracers.h:10416: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’
CC util/qemu-config.o
./trace/generated-tracers.h: In function ‘trace_spice_vmc_write’:
./trace/generated-tracers.h:6516: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 6 has type ‘ssize_t’
CC util/qemu-sockets.o
./trace/generated-tracers.h: In function ‘trace_v9fs_read_return’:
./trace/generated-tracers.h:10368: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_readdir_return’:
./trace/generated-tracers.h:10392: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_write_return’:
./trace/generated-tracers.h:10416: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’
CC util/notify.o

I think this is a quirk of this elderly mingw setup that's come up before, but I forget what the resolution of it was.
(I now have a more up to date mingw build in the mix too, so I'm not completely averse to the suggestion of "drop this thing".)

thanks
-- PMM

#19 lore raw

Re: [Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory

In reply to Dimitris Aragiorgis
Quoted 6 lines · Dimitris Aragiorgis

Hi all,

A while ago me and Alex [cc'ed] submitted a trivial patch related to logging [1]. Since this patch set here moves the qemu-log.c under util/, our patch will not apply any more. Should we rebase it and resend it against current master?

git can handle it, it will apply.

I'll look at the patch tomorrow, it's a good idea (though -daemonize isn't a good idea :)).

Paolo

#24 lore raw
In reply to Peter Maydell
Quoted 78 lines · Peter Maydell
Quoted 6 lines · Stefan Hajnoczi

The following changes since commit c65db7705b7926f4a084b93778e4bd5dd3990aad:

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-for-peter-2016-02-02' into staging (2016-02-02 18:04:04 +0000)

are available in the git repository at:

Quoted 7 lines

git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to c84ea00dc29b2084a62bd31f498ed0f245d3848e:

log: add "-d trace:PATTERN" (2016-02-03 10:37:50 +0000)

----------------------------------------------------------------

Hi. I'm afraid this fails to compile on Windows:

In file included from /home/petmay01/linaro/qemu-for-merges/include/trace.h:4,
from
/home/petmay01/linaro/qemu-for-merges/util/oslib-win32.c:38:
./trace/generated-tracers.h: In function ‘trace_virtio_console_flush_buf’:
./trace/generated-tracers.h:240: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 8 has type ‘ssize_t’
CC util/hbitmap.o
./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_so’:
./trace/generated-tracers.h:2784: warning: format ‘%zu’ expects type ‘size_t’, but argument 11 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_data_overrun’:
./trace/generated-tracers.h:2796: warning: format ‘%zu’ expects type ‘size_t’, but argument 7 has type ‘ssize_t’
CC util/fifo8.o
CC util/acl.o
./trace/generated-tracers.h: In function ‘trace_spice_vmc_write’:
./trace/generated-tracers.h:6516: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 6 has type ‘ssize_t’
CC util/error.o
CC util/qemu-error.o
cc1: warnings being treated as errors
In file included from /home/petmay01/linaro/qemu-for-merges/include/trace.h:4,
from /home/petmay01/linaro/qemu-for-merges/util/hbitmap.c:18:
./trace/generated-tracers.h: In function ‘trace_virtio_console_flush_buf’:
./trace/generated-tracers.h:240: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 8 has type ‘ssize_t’
CC util/id.o
CC util/iov.o
./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_so’:./trace/generated-tracers.h: In function ‘trace_v9fs_read_return’:
./trace/generated-tracers.h:2784: warning: format ‘%zu’ expects type ‘size_t’, but argument 11 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_usb_ohci_iso_td_data_overrun’:
./trace/generated-tracers.h:2796: warning: format ‘%zu’ expects type ‘size_t’, but argument 7 has type ‘ssize_t’

./trace/generated-tracers.h:10368: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_readdir_return’:
./trace/generated-tracers.h:10392: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_write_return’:
./trace/generated-tracers.h:10416: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’
CC util/qemu-config.o
./trace/generated-tracers.h: In function ‘trace_spice_vmc_write’:
./trace/generated-tracers.h:6516: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 6 has type ‘ssize_t’
CC util/qemu-sockets.o
./trace/generated-tracers.h: In function ‘trace_v9fs_read_return’:
./trace/generated-tracers.h:10368: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_readdir_return’:
./trace/generated-tracers.h:10392: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’ ./trace/generated-tracers.h: In function ‘trace_v9fs_write_return’:
./trace/generated-tracers.h:10416: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 9 has type ‘ssize_t’
CC util/notify.o

Quoted 4 lines

I think this is a quirk of this elderly mingw setup that's come up before, but I forget what the resolution of it was.
(I now have a more up to date mingw build in the mix too, so I'm not completely averse to the suggestion of "drop this thing".)

Looks like this was always broken, it just required some extra configure argument.

I would "drop this thing" or, better, you could compile with "--enable-trace-backend=nop" on the old mingw setup and without it on the new one. This has the additional advantage of better coverage.

We should also add -Werror=format to the Makefile.

Paolo

#25 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Peter Maydell

On 3 February 2016 at 15:47, Stefan Hajnoczi <[email protected]> wrote:
I think this is a quirk of this elderly mingw setup that's come up before, but I forget what the resolution of it was.
(I now have a more up to date mingw build in the mix too, so I'm not completely averse to the suggestion of "drop this thing".)

Quoted 6 lines

Looks like this was always broken, it just required some extra configure argument.

I would "drop this thing" or, better, you could compile with "--enable-trace-backend=nop" on the old mingw setup and without it on the new one. This has the additional advantage of better coverage.

I added this configure argument and the build does pass, so I've pushed it to master. I probably will drop the build config entirely at some point though, IIRC it doesn't actually build working executables. It's kind of handy to have one elderly gcc in the mix, though, as long as the mingw foibles don't cause too much hassle.

thanks
-- PMM

#6 lore raw

Re: [Qemu-devel] [PULL 05/13] trace: split trace_init_file out of trace_init_backends

In reply to Stefan Hajnoczi
Quoted 38 lines · Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

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

Message-id: [email protected]

---
 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 1c11d57..83c48f4 100644
@@ -435,7 +435,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 +0 -0
index 931d64c..f5a497a 100644
@@ -145,17 +145,24 @@ void trace_init_events(const char *fname)
     loc_pop(&loc);
 }

trace/control.c void trace_init_events(const char *fname) · line 151

Quoted 10 lines
trace/control.c +2 -5
 
-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);

This breaks "make check" as st_set_trace_file will attempt to flush the file:

    /* Halt trace writeout */
    flush_trace_file(true);
    trace_writeout_enabled = false;
    flush_trace_file(true);

And this deadlocks waiting for trace_empty_cond to get tickled which will never happen because:

<snip>

Quoted 26 lines
vl.c +5 -2
index ff2a7d5..955f364 100644
@@ -2988,7 +2988,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;
@@ -3905,7 +3905,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;
             }

vl.c int main(int argc, char **argv, char **envp) · line 4096

Quoted 5 lines
vl.c +2 -0
@@ -4089,6 +4092,8 @@ int main(int argc, char **argv, char **envp)
         exit(0);
     }
 
+    trace_init_file(trace_file);
+

This happens before:

Quoted 12 lines
vl.c +1 -1
      */
     if (log_file) {
@@ -4106,7 +4111,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (!is_daemonized()) {
-        if (!trace_init_backends(trace_file)) {
+        if (!trace_init_backends()) {
             exit(1);
         }
     }

vl.c int main(int argc, char **argv, char **envp) · line 4661

Quoted 5 lines
vl.c +1 -1
@@ -4653,7 +4658,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()) {

This which creates the thread.

vl.c int main(int argc, char **argv, char **envp) · line 3914

Quoted 3 lines
vl.c +0 -0
             exit(1);
         }
     }

--
Alex Bennée

#7 lore raw

Re: [Qemu-devel] [PULL 05/13] trace: split trace_init_file out of trace_init_backends

Quoted 41 lines · Alex Bennée
Quoted 39 lines · Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

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

Message-id: [email protected]

---
  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 1c11d57..83c48f4 100644
@@ -435,7 +435,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 +0 -0
index 931d64c..f5a497a 100644
@@ -145,17 +145,24 @@ void trace_init_events(const char *fname)
      loc_pop(&loc);
  }
 
Quoted 11 lines

trace/control.c void trace_init_events(const char *fname) · line 151

Quoted 9 lines
trace/control.c +2 -5
-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);

This breaks "make check" as st_set_trace_file will attempt to flush the file:

this does not hang for me even with CONFIG_TRACE_SIMPLE enabled. Could you share your ./configure options?

Den

#8 lore raw

Re: [Qemu-devel] [PULL 05/13] trace: split trace_init_file out of trace_init_backends

Quoted 53 lines · Denis V. Lunev
Quoted 41 lines · Alex Bennée
Quoted 39 lines · Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

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

Message-id: [email protected]

---
  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 1c11d57..83c48f4 100644
@@ -435,7 +435,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 +0 -0
index 931d64c..f5a497a 100644
@@ -145,17 +145,24 @@ void trace_init_events(const char *fname)
      loc_pop(&loc);
  }
 
Quoted 11 lines

trace/control.c void trace_init_events(const char *fname) · line 151

Quoted 9 lines
trace/control.c +2 -5
-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);

This breaks "make check" as st_set_trace_file will attempt to flush the file:

Quoted 2 lines

this does not hang for me even with CONFIG_TRACE_SIMPLE enabled. Could you share your ./configure options?

./configure --target-list=x86_64-softmmu --enable-trace-backends=simple

Also see:

https://travis-ci.org/stsquad/qemu/jobs/107280320

--
Alex Bennée

#9 lore raw

Re: [Qemu-devel] [PULL 05/13] trace: split trace_init_file out of trace_init_backends

Quoted 57 lines · Alex Bennée
Quoted 53 lines · Denis V. Lunev
Quoted 41 lines · Alex Bennée
Quoted 39 lines · Stefan Hajnoczi

From: Paolo Bonzini <[email protected]>

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

Message-id: [email protected]

---
   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 1c11d57..83c48f4 100644
@@ -435,7 +435,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 +0 -0
index 931d64c..f5a497a 100644
@@ -145,17 +145,24 @@ void trace_init_events(const char *fname)
       loc_pop(&loc);
   }
 
Quoted 11 lines

trace/control.c void trace_init_events(const char *fname) · line 151

Quoted 9 lines
trace/control.c +2 -5
-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);

This breaks "make check" as st_set_trace_file will attempt to flush the file:

Quoted 2 lines

this does not hang for me even with CONFIG_TRACE_SIMPLE enabled. Could you share your ./configure options?

Quoted 8 lines

./configure --target-list=x86_64-softmmu --enable-trace-backends=simple

Also see:

https://travis-ci.org/stsquad/qemu/jobs/107280320

--
Alex Bennée

for the reference (proposed fix):

http://lists.nongnu.org/archive/html/qemu-devel/2016-02/msg02123.html