aboutsummaryrefslogtreecommitdiff
path: root/trace/simple.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-06-09 16:25:34 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-06-09 16:25:34 +0100
commit14ac57339288c07b47e7e91fa192735158aa6a1e (patch)
treed24b742f3c7322d489548a9d74b4bd88b6bb4923 /trace/simple.c
parent4a331bb33bdf112ba95470e5d6ea3561b049c280 (diff)
parenta35d9be622a85d9ad6be5448e78c8a3f95ee5f00 (diff)
Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging
Tracing pull request # gpg: Signature made Mon 09 Jun 2014 14:44:18 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/tracing-pull-request: trace: Replace fprintf with error_report and print location trace: Multi-backend tracing trace: Replace error with warning if event is not defined simpletrace: add support for trace record pid field trace: add pid field to simpletrace record Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'trace/simple.c')
-rw-r--r--trace/simple.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/trace/simple.c b/trace/simple.c
index bb0b52ce02..a8f923c82e 100644
--- a/trace/simple.c
+++ b/trace/simple.c
@@ -75,6 +75,7 @@ uint8_t trace_buf[TRACE_BUF_LEN];
static volatile gint trace_idx;
static unsigned int writeout_idx;
static volatile gint dropped_events;
+static uint32_t trace_pid;
static FILE *trace_fp;
static char *trace_file_name;
@@ -83,7 +84,7 @@ typedef struct {
uint64_t event; /* TraceEventID */
uint64_t timestamp_ns;
uint32_t length; /* in bytes */
- uint32_t reserved; /* unused */
+ uint32_t pid;
uint64_t arguments[];
} TraceRecord;
@@ -190,7 +191,7 @@ static gpointer writeout_thread(gpointer opaque)
dropped.rec.event = DROPPED_EVENT_ID,
dropped.rec.timestamp_ns = get_clock();
dropped.rec.length = sizeof(TraceRecord) + sizeof(uint64_t),
- dropped.rec.reserved = 0;
+ dropped.rec.pid = trace_pid;
do {
dropped_count = g_atomic_int_get(&dropped_events);
} while (!g_atomic_int_compare_and_exchange(&dropped_events,
@@ -249,6 +250,7 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasi
rec_off = write_to_buffer(rec_off, &event_u64, sizeof(event_u64));
rec_off = write_to_buffer(rec_off, &timestamp_ns, sizeof(timestamp_ns));
rec_off = write_to_buffer(rec_off, &rec_len, sizeof(rec_len));
+ rec_off = write_to_buffer(rec_off, &trace_pid, sizeof(trace_pid));
rec->tbuf_idx = idx;
rec->rec_off = (idx + sizeof(TraceRecord)) % TRACE_BUF_LEN;
@@ -366,22 +368,6 @@ void st_flush_trace_buffer(void)
flush_trace_file(true);
}
-void trace_print_events(FILE *stream, fprintf_function stream_printf)
-{
- unsigned int i;
-
- for (i = 0; i < trace_event_count(); i++) {
- TraceEvent *ev = trace_event_id(i);
- stream_printf(stream, "%s [Event ID %u] : state %u\n",
- trace_event_get_name(ev), i, trace_event_get_state_dynamic(ev));
- }
-}
-
-void trace_event_set_state_dynamic_backend(TraceEvent *ev, bool state)
-{
- ev->dstate = state;
-}
-
/* Helper function to create a thread with signals blocked. Use glib's
* portable threads since QEMU abstractions cannot be used due to reentrancy in
* the tracer. Also note the signal masking on POSIX hosts so that the thread
@@ -410,10 +396,12 @@ static GThread *trace_thread_create(GThreadFunc fn)
return thread;
}
-bool trace_backend_init(const char *events, const char *file)
+bool st_init(const char *file)
{
GThread *thread;
+ trace_pid = getpid();
+
#if !GLIB_CHECK_VERSION(2, 31, 0)
trace_available_cond = g_cond_new();
trace_empty_cond = g_cond_new();
@@ -426,7 +414,6 @@ bool trace_backend_init(const char *events, const char *file)
}
atexit(st_flush_trace_buffer);
- trace_backend_init_events(events);
st_set_trace_file(file);
return true;
}