diff options
| -rw-r--r-- | tools/perf/Documentation/perf-config.txt | 8 | ||||
| -rw-r--r-- | tools/perf/ui/browsers/scripts.c | 20 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt index 2d0fb7613134..95054a8176a2 100644 --- a/tools/perf/Documentation/perf-config.txt +++ b/tools/perf/Documentation/perf-config.txt | |||
| @@ -590,6 +590,14 @@ samples.*:: | |||
| 590 | Define how many ns worth of time to show | 590 | Define how many ns worth of time to show |
| 591 | around samples in perf report sample context browser. | 591 | around samples in perf report sample context browser. |
| 592 | 592 | ||
| 593 | scripts.*:: | ||
| 594 | |||
| 595 | Any option defines a script that is added to the scripts menu | ||
| 596 | in the interactive perf browser and whose output is displayed. | ||
| 597 | The name of the option is the name, the value is a script command line. | ||
| 598 | The script gets the same options passed as a full perf script, | ||
| 599 | in particular -i perfdata file, --cpu, --tid | ||
| 600 | |||
| 593 | SEE ALSO | 601 | SEE ALSO |
| 594 | -------- | 602 | -------- |
| 595 | linkperf:perf[1] | 603 | linkperf:perf[1] |
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; |
