summaryrefslogtreecommitdiff
path: root/trace/control.c
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2016-11-30 14:11:48 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2016-11-30 14:11:58 +0900
commit2371603ef207b015cc29728296b21cb1722d8ae6 (patch)
tree25cbb62daf29066fa874b9a4b8f754bc18187806 /trace/control.c
parentd5df306aedcc13cf5a2463ddf858c8d718a788d5 (diff)
parentd4dcb59384ab4433702f015fdddda1eff8e3927f (diff)
downloadqemu-2371603ef207b015cc29728296b21cb1722d8ae6.tar.gz
qemu-2371603ef207b015cc29728296b21cb1722d8ae6.tar.bz2
qemu-2371603ef207b015cc29728296b21cb1722d8ae6.zip
Merge branch 'develop_qemu_2.7' into develop
Change-Id: Ibae70e3c0d1d88632903f98be114f47af9ca7502 Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
Diffstat (limited to 'trace/control.c')
-rw-r--r--trace/control.c74
1 files changed, 70 insertions, 4 deletions
diff --git a/trace/control.c b/trace/control.c
index d099f735d5..d173c09f44 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -1,7 +1,7 @@
/*
* Interface for configuring and controlling the state of tracing events.
*
- * Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu>
+ * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
@@ -19,11 +19,41 @@
#ifdef CONFIG_TRACE_LOG
#include "qemu/log.h"
#endif
+#include "qapi/error.h"
#include "qemu/error-report.h"
+#include "qemu/config-file.h"
#include "monitor/monitor.h"
int trace_events_enabled_count;
-bool trace_events_dstate[TRACE_EVENT_COUNT];
+/*
+ * Interpretation depends on wether the event has the 'vcpu' property:
+ * - false: Boolean value indicating whether the event is active.
+ * - true : Integral counting the number of vCPUs that have this event enabled.
+ */
+uint16_t trace_events_dstate[TRACE_EVENT_COUNT];
+/* Marks events for late vCPU state init */
+static bool trace_events_dstate_init[TRACE_EVENT_COUNT];
+
+QemuOptsList qemu_trace_opts = {
+ .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,
+ },{
+ .name = "file",
+ .type = QEMU_OPT_STRING,
+ },
+ { /* end of list */ }
+ },
+};
+
TraceEvent *trace_event_name(const char *name)
{
@@ -112,7 +142,10 @@ static void do_trace_enable_events(const char *line_buf)
TraceEvent *ev = NULL;
while ((ev = trace_event_pattern(line_ptr, ev)) != NULL) {
if (trace_event_get_state_static(ev)) {
+ /* start tracing */
trace_event_set_state_dynamic(ev, enable);
+ /* mark for late vCPU init */
+ trace_events_dstate_init[ev->id] = true;
}
}
} else {
@@ -124,7 +157,10 @@ static void do_trace_enable_events(const char *line_buf)
error_report("WARNING: trace event '%s' is not traceable",
line_ptr);
} else {
+ /* start tracing */
trace_event_set_state_dynamic(ev, enable);
+ /* mark for late vCPU init */
+ trace_events_dstate_init[ev->id] = true;
}
}
}
@@ -141,7 +177,7 @@ void trace_enable_events(const char *line_buf)
}
}
-void trace_init_events(const char *fname)
+static void trace_init_events(const char *fname)
{
Location loc;
FILE *fp;
@@ -187,7 +223,7 @@ void trace_init_file(const char *file)
* only applies to the simple backend; use "-D" for the log backend.
*/
if (file) {
- qemu_set_log_filename(file);
+ qemu_set_log_filename(file, &error_fatal);
}
#else
if (file) {
@@ -216,3 +252,33 @@ bool trace_init_backends(void)
return true;
}
+
+char *trace_opt_parse(const char *optarg)
+{
+ char *trace_file;
+ QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
+ 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"));
+ trace_file = g_strdup(qemu_opt_get(opts, "file"));
+ qemu_opts_del(opts);
+
+ return trace_file;
+}
+
+void trace_init_vcpu_events(void)
+{
+ TraceEvent *ev = NULL;
+ while ((ev = trace_event_pattern("*", ev)) != NULL) {
+ if (trace_event_is_vcpu(ev) &&
+ trace_event_get_state_static(ev) &&
+ trace_events_dstate_init[ev->id]) {
+ trace_event_set_state_dynamic(ev, true);
+ }
+ }
+}