From: Lluís <xscript@gmx.net>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, chouteau@adacore.com
Subject: [Qemu-devel] [PATCH v2 09/11] trace-state: [simple] add "-trace events" argument to control initial state
Date: Wed, 06 Apr 2011 20:34:56 +0200 [thread overview]
Message-ID: <20110406183456.22854.99191.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20110406183341.22854.93929.stgit@ginnungagap.bsc.es>
When using the "simple" tracing backend, all events are in disabled state by
default.
The "-trace events" argument can be used to provide a file with a list of trace
event names that will be enabled prior to starting execution. This saves the
user from manually toggling event states through the monitor interface, as well
as enables early tracing for the selected points, much like other
more-sophisticated backends like "ust" or "dtrace".
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
docs/tracing.txt | 5 +++++
qemu-config.c | 3 +++
qemu-options.hx | 18 ++++++++++++++----
vl.c | 26 ++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/docs/tracing.txt b/docs/tracing.txt
index 9138dca..26b221f 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -146,6 +146,11 @@ source tree. It may not be as powerful as platform-specific or third-party
trace backends but it is portable. This is the recommended trace backend
unless you have specific needs for more advanced backends.
+==== Enabling trace events from the command line ====
+
+The "-trace events=<file>" command line argument can be used to enable the
+events listed in <file> from the very beginning of the program.
+
==== Monitor commands ====
* info trace
diff --git a/qemu-config.c b/qemu-config.c
index 8ba0804..7c7357f 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -306,6 +306,9 @@ static QemuOptsList qemu_trace_opts = {
{
.name = "file",
.type = QEMU_OPT_STRING,
+ },{
+ .name = "events",
+ .type = QEMU_OPT_STRING,
},
{ /* end if list */ }
},
diff --git a/qemu-options.hx b/qemu-options.hx
index ef60730..ff8e75d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2358,13 +2358,23 @@ option will prevent QEMU from loading these configuration files at startup.
ETEXI
#ifdef CONFIG_SIMPLE_TRACE
DEF("trace", HAS_ARG, QEMU_OPTION_trace,
- "-trace\n"
- " Specify a trace file to log traces to\n",
+ "-trace [file=<file>][,events=<file>]\n"
+ " specify tracing options\n",
QEMU_ARCH_ALL)
STEXI
-@item -trace
+@item -trace [file=@var{file}][,events=@var{file}]
@findex -trace
-Specify a trace file to log output traces to.
+
+Specify tracing options.
+
+@table @option
+@item file=@var{file}
+Log output traces to @var{file}.
+@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.
+@end table
ETEXI
#endif
diff --git a/vl.c b/vl.c
index 5a9ea51..35d440d 100644
--- a/vl.c
+++ b/vl.c
@@ -1968,6 +1968,7 @@ int main(int argc, char **argv, char **envp)
int defconfig = 1;
#if defined(CONFIG_SIMPLE_TRACE)
const char *trace_file = NULL;
+ const char *trace_events_file = NULL;
#endif
atexit(qemu_run_exit_notifiers);
@@ -2766,6 +2767,7 @@ int main(int argc, char **argv, char **envp)
opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0);
if (opts) {
trace_file = qemu_opt_get(opts, "file");
+ trace_events_file = qemu_opt_get(opts, "events");
}
break;
#endif
@@ -2818,6 +2820,30 @@ int main(int argc, char **argv, char **envp)
if (!st_init(trace_file)) {
fprintf(stderr, "warning: unable to initialize simple trace backend\n");
}
+ if (trace_events_file) {
+ FILE *trace_events_fp = fopen(trace_events_file, "r");
+ if (!trace_events_fp) {
+ fprintf(stderr, "could not open trace events file '%s': %s\n",
+ trace_events_file, strerror(errno));
+ exit(1);
+ }
+ char line_buf[1024];
+ while (fgets(line_buf, sizeof(line_buf), trace_events_fp)) {
+ size_t len = strlen(line_buf);
+ if (len > 1) { /* skip empty lines */
+ line_buf[len - 1] = '\0';
+ if (!st_change_trace_event_state(line_buf, true)) {
+ fprintf(stderr, "trace event '%s' does not exist\n", line_buf);
+ exit(1);
+ }
+ }
+ }
+ if (fclose(trace_events_fp) != 0) {
+ fprintf(stderr, "error closing file '%s': %s\n",
+ trace_events_file, strerror(errno));
+ exit(1);
+ }
+ }
#endif
/* If no data_dir is specified then try to find it relative to the
next prev parent reply other threads:[~2011-04-06 18:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 18:33 [Qemu-devel] [RFC][PATCH v2 00/11] trace-state: make the behaviour of "disable" consistent across all backends Lluís
2011-04-06 18:33 ` [Qemu-devel] [PATCH v2 01/11] minor whitespace/indentation fixes Lluís
2011-04-23 14:19 ` Stefan Hajnoczi
2011-04-26 10:00 ` Markus Armbruster
2011-04-06 18:33 ` [Qemu-devel] [PATCH v2 02/11] docs/tracing.txt: minor documentation fixes Lluís
2011-04-06 18:34 ` [Qemu-devel] [PATCH v2 03/11] trace: [ust] fix generation of 'trace.c' on events without args Lluís
2011-04-06 18:34 ` [Qemu-devel] [PATCH v2 04/11] trace: [trace-events] fix print formats in some events Lluís
2011-04-06 18:34 ` [Qemu-devel] [PATCH v2 05/11] trace: [simple] minor code fixes on conditional compilation Lluís
2011-04-23 14:20 ` Stefan Hajnoczi
2011-04-06 18:34 ` [Qemu-devel] [PATCH v2 06/11] trace: generalize the "property" concept in the trace-events file Lluís
2011-04-23 14:22 ` Stefan Hajnoczi
2011-04-06 18:34 ` [Qemu-devel] [PATCH v2 07/11] trace-state: always use the "nop" backend on events with the "disable" keyword Lluís
2011-04-06 18:34 ` [Qemu-devel] [PATCH v2 08/11] trace-state: [simple] disable all trace points by default Lluís
2011-04-06 18:34 ` Lluís [this message]
2011-04-06 18:35 ` [Qemu-devel] [PATCH v2 10/11] trace-state: [stderr] add support for dynamically enabling/disabling events Lluís
2011-04-23 14:31 ` Stefan Hajnoczi
2011-04-24 6:24 ` Paolo Bonzini
2011-04-24 9:33 ` Stefan Hajnoczi
2011-04-25 10:27 ` Lluís
2011-04-25 18:10 ` Paolo Bonzini
2011-04-26 12:30 ` Fabien Chouteau
2011-04-26 12:38 ` Stefan Hajnoczi
2011-04-26 12:59 ` Paolo Bonzini
2011-04-26 14:01 ` Lluís
2011-04-06 18:35 ` [Qemu-devel] [PATCH v2 11/11] trace: enable all events Lluís
2011-04-23 14:45 ` [Qemu-devel] [RFC][PATCH v2 00/11] trace-state: make the behaviour of "disable" consistent across all backends Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110406183456.22854.99191.stgit@ginnungagap.bsc.es \
--to=xscript@gmx.net \
--cc=chouteau@adacore.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).