aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/debug.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2014-07-17 06:55:00 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-17 11:58:59 -0400
commitbbb2cea7e8dd496b41558df1a0ec9205497b7ebf (patch)
tree7a73131f1871315194c0a3a594c82b0946c3ca3d /tools/perf/util/debug.c
parentc95688aac7723c17b2badc23233706b2f02e58ed (diff)
perf tools: Add --debug optionto set debug variable
Adding --debug option as a way to setup debug variables. Starting with support for verbose, more will come. It's possible to use it now with report command: $ perf --debug verbose ... $ perf --debug verbose=2 ... I'll need this support to add separated debug variable for ordered events change in order to separate debug output out of standard verbose stream. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20140717105500.GG516@krava.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/debug.c')
-rw-r--r--tools/perf/util/debug.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index c208d6f56e63..71d419362634 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -105,3 +105,47 @@ void trace_event(union perf_event *event)
105 } 105 }
106 printf(".\n"); 106 printf(".\n");
107} 107}
108
109static struct debug_variable {
110 const char *name;
111 int *ptr;
112} debug_variables[] = {
113 { .name = "verbose", .ptr = &verbose },
114 { .name = NULL, }
115};
116
117int perf_debug_option(const char *str)
118{
119 struct debug_variable *var = &debug_variables[0];
120 char *vstr, *s = strdup(str);
121 int v = 1;
122
123 vstr = strchr(s, '=');
124 if (vstr)
125 *vstr++ = 0;
126
127 while (var->name) {
128 if (!strcmp(s, var->name))
129 break;
130 var++;
131 }
132
133 if (!var->name) {
134 pr_err("Unknown debug variable name '%s'\n", s);
135 free(s);
136 return -1;
137 }
138
139 if (vstr) {
140 v = atoi(vstr);
141 /*
142 * Allow only values in range (0, 10),
143 * otherwise set 0.
144 */
145 v = (v < 0) || (v > 10) ? 0 : v;
146 }
147
148 *var->ptr = v;
149 free(s);
150 return 0;
151}