perf/scripts: Add Python scripting engine
Add base support for Python scripting to perf trace. Signed-off-by: Tom Zanussi <tzanussi@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Keiichi KII <k-keiichi@bx.jp.nec.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <1264580883-15324-6-git-send-email-tzanussi@gmail.com> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
This commit is contained in:
parent
266fe2f217
commit
7e4b21b84c
8 changed files with 864 additions and 0 deletions
|
@ -44,6 +44,67 @@ static void process_event_unsupported(int cpu __unused,
|
|||
{
|
||||
}
|
||||
|
||||
static void print_python_unsupported_msg(void)
|
||||
{
|
||||
fprintf(stderr, "Python scripting not supported."
|
||||
" Install libpython and rebuild perf to enable it.\n"
|
||||
"For example:\n # apt-get install python-dev (ubuntu)"
|
||||
"\n # yum install python-devel (Fedora)"
|
||||
"\n etc.\n");
|
||||
}
|
||||
|
||||
static int python_start_script_unsupported(const char *script __unused,
|
||||
int argc __unused,
|
||||
const char **argv __unused)
|
||||
{
|
||||
print_python_unsupported_msg();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int python_generate_script_unsupported(const char *outfile __unused)
|
||||
{
|
||||
print_python_unsupported_msg();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct scripting_ops python_scripting_unsupported_ops = {
|
||||
.name = "Python",
|
||||
.start_script = python_start_script_unsupported,
|
||||
.stop_script = stop_script_unsupported,
|
||||
.process_event = process_event_unsupported,
|
||||
.generate_script = python_generate_script_unsupported,
|
||||
};
|
||||
|
||||
static void register_python_scripting(struct scripting_ops *scripting_ops)
|
||||
{
|
||||
int err;
|
||||
err = script_spec_register("Python", scripting_ops);
|
||||
if (err)
|
||||
die("error registering Python script extension");
|
||||
|
||||
err = script_spec_register("py", scripting_ops);
|
||||
if (err)
|
||||
die("error registering py script extension");
|
||||
|
||||
scripting_context = malloc(sizeof(struct scripting_context));
|
||||
}
|
||||
|
||||
#ifdef NO_LIBPYTHON
|
||||
void setup_python_scripting(void)
|
||||
{
|
||||
register_python_scripting(&python_scripting_unsupported_ops);
|
||||
}
|
||||
#else
|
||||
struct scripting_ops python_scripting_ops;
|
||||
|
||||
void setup_python_scripting(void)
|
||||
{
|
||||
register_python_scripting(&python_scripting_ops);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void print_perl_unsupported_msg(void)
|
||||
{
|
||||
fprintf(stderr, "Perl scripting not supported."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue