diff options
author | Lluís <xscript@gmx.net> | 2011-08-31 20:31:31 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2011-09-01 10:34:54 +0100 |
commit | 23d15e860b33819ad76092fbb32577542fe0c44d (patch) | |
tree | 20c99fb621ab3c063c60029e69c8df744c6be0eb /trace/control.c | |
parent | 31965ae27bc11e90674be12584bb201b83df5aef (diff) | |
download | qemu-23d15e860b33819ad76092fbb32577542fe0c44d.zip qemu-23d15e860b33819ad76092fbb32577542fe0c44d.tar.gz qemu-23d15e860b33819ad76092fbb32577542fe0c44d.tar.bz2 |
trace: add "-trace events" argument to control initial state
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, thus providing
early tracing.
This saves the user from manually toggling event states through the monitor
interface or whichever backend-specific interface.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Diffstat (limited to 'trace/control.c')
-rw-r--r-- | trace/control.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/trace/control.c b/trace/control.c new file mode 100644 index 0000000..4c5527d --- /dev/null +++ b/trace/control.c @@ -0,0 +1,42 @@ +/* + * Interface for configuring and controlling the state of tracing events. + * + * Copyright (C) 2011 Lluís Vilanova <vilanova@ac.upc.edu> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "trace/control.h" + + +void trace_backend_init_events(const char *fname) +{ + if (fname == NULL) { + return; + } + + FILE *fp = fopen(fname, "r"); + if (!fp) { + fprintf(stderr, "error: could not open trace events file '%s': %s\n", + fname, strerror(errno)); + exit(1); + } + char line_buf[1024]; + while (fgets(line_buf, sizeof(line_buf), fp)) { + size_t len = strlen(line_buf); + if (len > 1) { /* skip empty lines */ + line_buf[len - 1] = '\0'; + if (!trace_event_set_state(line_buf, true)) { + fprintf(stderr, + "error: trace event '%s' does not exist\n", line_buf); + exit(1); + } + } + } + if (fclose(fp) != 0) { + fprintf(stderr, "error: closing file '%s': %s\n", + fname, strerror(errno)); + exit(1); + } +} |