diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-01-31 11:13:08 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-01-31 11:13:08 +0000 |
commit | 89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be (patch) | |
tree | 7ec9555d2e4a7321a482413cd24aa9881dce7cac | |
parent | 0159a64397fc8e6c85de73613d83a3612c840664 (diff) | |
parent | 736ec1677f1ae7e64f2f3436ca3775c48f79678c (diff) | |
download | qemu-89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be.zip qemu-89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be.tar.gz qemu-89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be.tar.bz2 |
Merge remote-tracking branch 'stefanha/tags/tracing-pull-request' into staging
Tracing pull request
# gpg: Signature made Mon 27 Jan 2014 14:51:09 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8
* stefanha/tags/tracing-pull-request:
trace: fix simple trace "disable" keyword
trace: add glib 2.32+ static GMutex support
trace: [simple] Do not include "trace/simple.h" in generated tracer headers
tracing: start trace processing thread in final child process
Message-id: 1390834386-23139-1-git-send-email-stefanha@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | scripts/tracetool/backend/simple.py | 6 | ||||
-rw-r--r-- | trace/simple.c | 24 | ||||
-rw-r--r-- | vl.c | 12 |
3 files changed, 29 insertions, 13 deletions
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py index 37ef599..3dde372 100644 --- a/scripts/tracetool/backend/simple.py +++ b/scripts/tracetool/backend/simple.py @@ -56,7 +56,7 @@ def c(events): out('', - ' TraceEvent *eventp = trace_event_id(%(event_id)s);', + ' TraceEvent *eventp = trace_event_id(%(event_enum)s);', ' bool _state = trace_event_get_state_dynamic(eventp);', ' if (!_state) {', ' return;', @@ -65,6 +65,7 @@ def c(events): ' if (trace_record_start(&rec, %(event_id)s, %(size_str)s)) {', ' return; /* Trace Buffer Full, Event Dropped ! */', ' }', + event_enum = 'TRACE_' + event.name.upper(), event_id = num, size_str = sizestr, ) @@ -93,9 +94,6 @@ def c(events): def h(events): - out('#include "trace/simple.h"', - '') - for event in events: out('void trace_%(name)s(%(args)s);', name = event.name, diff --git a/trace/simple.c b/trace/simple.c index 1e3f691..57572c4 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -19,6 +19,7 @@ #include "qemu/timer.h" #include "trace.h" #include "trace/control.h" +#include "trace/simple.h" /** Trace file header event ID */ #define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with TraceEventIDs */ @@ -39,7 +40,17 @@ * Trace records are written out by a dedicated thread. The thread waits for * records to become available, writes them out, and then waits again. */ +#if GLIB_CHECK_VERSION(2, 32, 0) +static GMutex trace_lock; +#define lock_trace_lock() g_mutex_lock(&trace_lock) +#define unlock_trace_lock() g_mutex_unlock(&trace_lock) +#define get_trace_lock_mutex() (&trace_lock) +#else static GStaticMutex trace_lock = G_STATIC_MUTEX_INIT; +#define lock_trace_lock() g_static_mutex_lock(&trace_lock) +#define unlock_trace_lock() g_static_mutex_unlock(&trace_lock) +#define get_trace_lock_mutex() g_static_mutex_get_mutex(&trace_lock) +#endif /* g_cond_new() was deprecated in glib 2.31 but we still need to support it */ #if GLIB_CHECK_VERSION(2, 31, 0) @@ -139,27 +150,26 @@ static bool get_trace_record(unsigned int idx, TraceRecord **recordptr) */ static void flush_trace_file(bool wait) { - g_static_mutex_lock(&trace_lock); + lock_trace_lock(); trace_available = true; g_cond_signal(trace_available_cond); if (wait) { - g_cond_wait(trace_empty_cond, g_static_mutex_get_mutex(&trace_lock)); + g_cond_wait(trace_empty_cond, get_trace_lock_mutex()); } - g_static_mutex_unlock(&trace_lock); + unlock_trace_lock(); } static void wait_for_trace_records_available(void) { - g_static_mutex_lock(&trace_lock); + lock_trace_lock(); while (!(trace_available && trace_writeout_enabled)) { g_cond_signal(trace_empty_cond); - g_cond_wait(trace_available_cond, - g_static_mutex_get_mutex(&trace_lock)); + g_cond_wait(trace_available_cond, get_trace_lock_mutex()); } trace_available = false; - g_static_mutex_unlock(&trace_lock); + unlock_trace_lock(); } static gpointer writeout_thread(gpointer opaque) @@ -3879,8 +3879,10 @@ int main(int argc, char **argv, char **envp) qemu_set_log(mask); } - if (!trace_backend_init(trace_events, trace_file)) { - exit(1); + if (!is_daemonized()) { + if (!trace_backend_init(trace_events, trace_file)) { + exit(1); + } } /* If no data_dir is specified then try to find it relative to the @@ -4379,6 +4381,12 @@ int main(int argc, char **argv, char **envp) os_setup_post(); + if (is_daemonized()) { + if (!trace_backend_init(trace_events, trace_file)) { + exit(1); + } + } + main_loop(); bdrv_close_all(); pause_all_vcpus(); |