mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-22 06:41:39 +00:00
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>
This commit is contained in:
parent
c95688aac7
commit
bbb2cea7e8
4 changed files with 67 additions and 2 deletions
|
@ -105,3 +105,47 @@ void trace_event(union perf_event *event)
|
|||
}
|
||||
printf(".\n");
|
||||
}
|
||||
|
||||
static struct debug_variable {
|
||||
const char *name;
|
||||
int *ptr;
|
||||
} debug_variables[] = {
|
||||
{ .name = "verbose", .ptr = &verbose },
|
||||
{ .name = NULL, }
|
||||
};
|
||||
|
||||
int perf_debug_option(const char *str)
|
||||
{
|
||||
struct debug_variable *var = &debug_variables[0];
|
||||
char *vstr, *s = strdup(str);
|
||||
int v = 1;
|
||||
|
||||
vstr = strchr(s, '=');
|
||||
if (vstr)
|
||||
*vstr++ = 0;
|
||||
|
||||
while (var->name) {
|
||||
if (!strcmp(s, var->name))
|
||||
break;
|
||||
var++;
|
||||
}
|
||||
|
||||
if (!var->name) {
|
||||
pr_err("Unknown debug variable name '%s'\n", s);
|
||||
free(s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vstr) {
|
||||
v = atoi(vstr);
|
||||
/*
|
||||
* Allow only values in range (0, 10),
|
||||
* otherwise set 0.
|
||||
*/
|
||||
v = (v < 0) || (v > 10) ? 0 : v;
|
||||
}
|
||||
|
||||
*var->ptr = v;
|
||||
free(s);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue