diff options
author | Andi Kleen <ak@linux.intel.com> | 2019-03-11 10:45:00 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-03-11 15:33:20 -0400 |
commit | e3b74de50a5f8bbfacbd772874c8b5d9220ebcdb (patch) | |
tree | cd5f1e2ee98842651dce0d25169e3a1ead031ae1 /tools/perf/ui/browsers/scripts.c | |
parent | 59c24980dffbea2106fe65e64ea77834d657ee9c (diff) |
perf tools report: Add custom scripts to script menu
Add a way to define custom scripts through ~/.perfconfig, which are then
added to the scripts menu. The scripts get the same arguments as 'perf
script', in particular -i, --cpu, --tid.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20190311144502.15423-10-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/scripts.c')
-rw-r--r-- | tools/perf/ui/browsers/scripts.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 96e5cd3b0eee..27cf3ab88d13 100644 --- a/tools/perf/ui/browsers/scripts.c +++ b/tools/perf/ui/browsers/scripts.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "../../util/symbol.h" | 6 | #include "../../util/symbol.h" |
7 | #include "../browser.h" | 7 | #include "../browser.h" |
8 | #include "../libslang.h" | 8 | #include "../libslang.h" |
9 | #include "config.h" | ||
9 | 10 | ||
10 | #define SCRIPT_NAMELEN 128 | 11 | #define SCRIPT_NAMELEN 128 |
11 | #define SCRIPT_MAX_NO 64 | 12 | #define SCRIPT_MAX_NO 64 |
@@ -53,6 +54,24 @@ static int add_script_option(const char *name, const char *opt, | |||
53 | return 0; | 54 | return 0; |
54 | } | 55 | } |
55 | 56 | ||
57 | static int scripts_config(const char *var, const char *value, void *data) | ||
58 | { | ||
59 | struct script_config *c = data; | ||
60 | |||
61 | if (!strstarts(var, "scripts.")) | ||
62 | return -1; | ||
63 | if (c->index >= SCRIPT_MAX_NO) | ||
64 | return -1; | ||
65 | c->names[c->index] = strdup(var + 7); | ||
66 | if (!c->names[c->index]) | ||
67 | return -1; | ||
68 | if (asprintf(&c->paths[c->index], "%s %s", value, | ||
69 | c->extra_format) < 0) | ||
70 | return -1; | ||
71 | c->index++; | ||
72 | return 0; | ||
73 | } | ||
74 | |||
56 | /* | 75 | /* |
57 | * When success, will copy the full path of the selected script | 76 | * When success, will copy the full path of the selected script |
58 | * into the buffer pointed by script_name, and return 0. | 77 | * into the buffer pointed by script_name, and return 0. |
@@ -87,6 +106,7 @@ static int list_scripts(char *script_name, bool *custom, | |||
87 | &scriptc); | 106 | &scriptc); |
88 | add_script_option("Show individual samples with source", "-F +srcline,+srccode", | 107 | add_script_option("Show individual samples with source", "-F +srcline,+srccode", |
89 | &scriptc); | 108 | &scriptc); |
109 | perf_config(scripts_config, &scriptc); | ||
90 | custom_perf = scriptc.index; | 110 | custom_perf = scriptc.index; |
91 | add_script_option("Show samples with custom perf script arguments", "", &scriptc); | 111 | add_script_option("Show samples with custom perf script arguments", "", &scriptc); |
92 | i = scriptc.index; | 112 | i = scriptc.index; |