diff options
author | Tom Zanussi <tzanussi@gmail.com> | 2010-01-27 03:27:57 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-02-24 22:07:29 -0500 |
commit | 7e4b21b84c43bb8a80b916e40718ca4ed1fc52e6 (patch) | |
tree | cafeb2a119cfa4aad3252f8d9ad164b276153f3e /tools/perf/util/trace-event-scripting.c | |
parent | 266fe2f217d1dc9f8041e395c0ab4569a5bad91a (diff) |
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>
Diffstat (limited to 'tools/perf/util/trace-event-scripting.c')
-rw-r--r-- | tools/perf/util/trace-event-scripting.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c index 9e371965c034..7ea983acfaea 100644 --- a/tools/perf/util/trace-event-scripting.c +++ b/tools/perf/util/trace-event-scripting.c | |||
@@ -44,6 +44,67 @@ static void process_event_unsupported(int cpu __unused, | |||
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | static void print_python_unsupported_msg(void) | ||
48 | { | ||
49 | fprintf(stderr, "Python scripting not supported." | ||
50 | " Install libpython and rebuild perf to enable it.\n" | ||
51 | "For example:\n # apt-get install python-dev (ubuntu)" | ||
52 | "\n # yum install python-devel (Fedora)" | ||
53 | "\n etc.\n"); | ||
54 | } | ||
55 | |||
56 | static int python_start_script_unsupported(const char *script __unused, | ||
57 | int argc __unused, | ||
58 | const char **argv __unused) | ||
59 | { | ||
60 | print_python_unsupported_msg(); | ||
61 | |||
62 | return -1; | ||
63 | } | ||
64 | |||
65 | static int python_generate_script_unsupported(const char *outfile __unused) | ||
66 | { | ||
67 | print_python_unsupported_msg(); | ||
68 | |||
69 | return -1; | ||
70 | } | ||
71 | |||
72 | struct scripting_ops python_scripting_unsupported_ops = { | ||
73 | .name = "Python", | ||
74 | .start_script = python_start_script_unsupported, | ||
75 | .stop_script = stop_script_unsupported, | ||
76 | .process_event = process_event_unsupported, | ||
77 | .generate_script = python_generate_script_unsupported, | ||
78 | }; | ||
79 | |||
80 | static void register_python_scripting(struct scripting_ops *scripting_ops) | ||
81 | { | ||
82 | int err; | ||
83 | err = script_spec_register("Python", scripting_ops); | ||
84 | if (err) | ||
85 | die("error registering Python script extension"); | ||
86 | |||
87 | err = script_spec_register("py", scripting_ops); | ||
88 | if (err) | ||
89 | die("error registering py script extension"); | ||
90 | |||
91 | scripting_context = malloc(sizeof(struct scripting_context)); | ||
92 | } | ||
93 | |||
94 | #ifdef NO_LIBPYTHON | ||
95 | void setup_python_scripting(void) | ||
96 | { | ||
97 | register_python_scripting(&python_scripting_unsupported_ops); | ||
98 | } | ||
99 | #else | ||
100 | struct scripting_ops python_scripting_ops; | ||
101 | |||
102 | void setup_python_scripting(void) | ||
103 | { | ||
104 | register_python_scripting(&python_scripting_ops); | ||
105 | } | ||
106 | #endif | ||
107 | |||
47 | static void print_perl_unsupported_msg(void) | 108 | static void print_perl_unsupported_msg(void) |
48 | { | 109 | { |
49 | fprintf(stderr, "Perl scripting not supported." | 110 | fprintf(stderr, "Perl scripting not supported." |