Skip to content

Commit e3b74de

Browse files
Andi Kleenacmel
authored andcommitted
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>
1 parent 59c2498 commit e3b74de

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tools/perf/Documentation/perf-config.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,14 @@ samples.*::
590590
Define how many ns worth of time to show
591591
around samples in perf report sample context browser.
592592

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+
593601
SEE ALSO
594602
--------
595603
linkperf:perf[1]

tools/perf/ui/browsers/scripts.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "../../util/symbol.h"
77
#include "../browser.h"
88
#include "../libslang.h"
9+
#include "config.h"
910

1011
#define SCRIPT_NAMELEN 128
1112
#define SCRIPT_MAX_NO 64
@@ -53,6 +54,24 @@ static int add_script_option(const char *name, const char *opt,
5354
return 0;
5455
}
5556

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+
5675
/*
5776
* When success, will copy the full path of the selected script
5877
* into the buffer pointed by script_name, and return 0.
@@ -87,6 +106,7 @@ static int list_scripts(char *script_name, bool *custom,
87106
&scriptc);
88107
add_script_option("Show individual samples with source", "-F +srcline,+srccode",
89108
&scriptc);
109+
perf_config(scripts_config, &scriptc);
90110
custom_perf = scriptc.index;
91111
add_script_option("Show samples with custom perf script arguments", "", &scriptc);
92112
i = scriptc.index;

0 commit comments

Comments
 (0)