diff options
author | RajithaY <rajithax.yerrumsetty@intel.com> | 2017-04-25 03:31:15 -0700 |
---|---|---|
committer | Rajitha Yerrumchetty <rajithax.yerrumsetty@intel.com> | 2017-05-22 06:48:08 +0000 |
commit | bb756eebdac6fd24e8919e2c43f7d2c8c4091f59 (patch) | |
tree | ca11e03542edf2d8f631efeca5e1626d211107e3 /qemu/trace/control.c | |
parent | a14b48d18a9ed03ec191cf16b162206998a895ce (diff) |
Adding qemu as a submodule of KVMFORNFV
This Patch includes the changes to add qemu as a submodule to
kvmfornfv repo and make use of the updated latest qemu for the
execution of all testcase
Change-Id: I1280af507a857675c7f81d30c95255635667bdd7
Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>
Diffstat (limited to 'qemu/trace/control.c')
-rw-r--r-- | qemu/trace/control.c | 218 |
1 files changed, 0 insertions, 218 deletions
diff --git a/qemu/trace/control.c b/qemu/trace/control.c deleted file mode 100644 index d099f735d..000000000 --- a/qemu/trace/control.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Interface for configuring and controlling the state of tracing events. - * - * Copyright (C) 2011-2014 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. - */ - -#include "qemu/osdep.h" -#include "trace/control.h" -#include "qemu/help_option.h" -#ifdef CONFIG_TRACE_SIMPLE -#include "trace/simple.h" -#endif -#ifdef CONFIG_TRACE_FTRACE -#include "trace/ftrace.h" -#endif -#ifdef CONFIG_TRACE_LOG -#include "qemu/log.h" -#endif -#include "qemu/error-report.h" -#include "monitor/monitor.h" - -int trace_events_enabled_count; -bool trace_events_dstate[TRACE_EVENT_COUNT]; - -TraceEvent *trace_event_name(const char *name) -{ - assert(name != NULL); - - TraceEventID i; - for (i = 0; i < trace_event_count(); i++) { - TraceEvent *ev = trace_event_id(i); - if (strcmp(trace_event_get_name(ev), name) == 0) { - return ev; - } - } - return NULL; -} - -static bool pattern_glob(const char *pat, const char *ev) -{ - while (*pat != '\0' && *ev != '\0') { - if (*pat == *ev) { - pat++; - ev++; - } - else if (*pat == '*') { - if (pattern_glob(pat, ev+1)) { - return true; - } else if (pattern_glob(pat+1, ev)) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - while (*pat == '*') { - pat++; - } - - if (*pat == '\0' && *ev == '\0') { - return true; - } else { - return false; - } -} - -TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev) -{ - assert(pat != NULL); - - TraceEventID i; - - if (ev == NULL) { - i = -1; - } else { - i = trace_event_get_id(ev); - } - i++; - - while (i < trace_event_count()) { - TraceEvent *res = trace_event_id(i); - if (pattern_glob(pat, trace_event_get_name(res))) { - return res; - } - i++; - } - - return NULL; -} - -void trace_list_events(void) -{ - int i; - for (i = 0; i < trace_event_count(); i++) { - TraceEvent *res = trace_event_id(i); - fprintf(stderr, "%s\n", trace_event_get_name(res)); - } -} - -static void do_trace_enable_events(const char *line_buf) -{ - const bool enable = ('-' != line_buf[0]); - const char *line_ptr = enable ? line_buf : line_buf + 1; - - if (trace_event_is_pattern(line_ptr)) { - TraceEvent *ev = NULL; - while ((ev = trace_event_pattern(line_ptr, ev)) != NULL) { - if (trace_event_get_state_static(ev)) { - trace_event_set_state_dynamic(ev, enable); - } - } - } else { - TraceEvent *ev = trace_event_name(line_ptr); - if (ev == NULL) { - error_report("WARNING: trace event '%s' does not exist", - line_ptr); - } else if (!trace_event_get_state_static(ev)) { - error_report("WARNING: trace event '%s' is not traceable", - line_ptr); - } else { - trace_event_set_state_dynamic(ev, enable); - } - } -} - -void trace_enable_events(const char *line_buf) -{ - if (is_help_option(line_buf)) { - trace_list_events(); - if (cur_mon == NULL) { - exit(0); - } - } else { - do_trace_enable_events(line_buf); - } -} - -void trace_init_events(const char *fname) -{ - Location loc; - FILE *fp; - char line_buf[1024]; - size_t line_idx = 0; - - if (fname == NULL) { - return; - } - - loc_push_none(&loc); - loc_set_file(fname, 0); - fp = fopen(fname, "r"); - if (!fp) { - error_report("%s", strerror(errno)); - exit(1); - } - while (fgets(line_buf, sizeof(line_buf), fp)) { - loc_set_file(fname, ++line_idx); - size_t len = strlen(line_buf); - if (len > 1) { /* skip empty lines */ - line_buf[len - 1] = '\0'; - if ('#' == line_buf[0]) { /* skip commented lines */ - continue; - } - trace_enable_events(line_buf); - } - } - if (fclose(fp) != 0) { - loc_set_file(fname, 0); - error_report("%s", strerror(errno)); - exit(1); - } - loc_pop(&loc); -} - -void trace_init_file(const char *file) -{ -#ifdef CONFIG_TRACE_SIMPLE - st_set_trace_file(file); -#elif defined CONFIG_TRACE_LOG - /* If both the simple and the log backends are enabled, "-trace file" - * only applies to the simple backend; use "-D" for the log backend. - */ - if (file) { - qemu_set_log_filename(file); - } -#else - if (file) { - fprintf(stderr, "error: -trace file=...: " - "option not supported by the selected tracing backends\n"); - exit(1); - } -#endif -} - -bool trace_init_backends(void) -{ -#ifdef CONFIG_TRACE_SIMPLE - if (!st_init()) { - fprintf(stderr, "failed to initialize simple tracing backend.\n"); - return false; - } -#endif - -#ifdef CONFIG_TRACE_FTRACE - if (!ftrace_init()) { - fprintf(stderr, "failed to initialize ftrace backend.\n"); - return false; - } -#endif - - return true; -} |