2 * trace-event-scripting. Scripting engine common and initialization code.
4 * Copyright (C) 2009-2010 Tom Zanussi <tzanussi@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "trace-event.h"
31 struct scripting_context *scripting_context;
33 static int flush_script_unsupported(void)
38 static int stop_script_unsupported(void)
43 static void process_event_unsupported(union perf_event *event __maybe_unused,
44 struct perf_sample *sample __maybe_unused,
45 struct perf_evsel *evsel __maybe_unused,
46 struct thread *thread __maybe_unused,
47 struct addr_location *al __maybe_unused)
51 static void print_python_unsupported_msg(void)
53 fprintf(stderr, "Python scripting not supported."
54 " Install libpython and rebuild perf to enable it.\n"
55 "For example:\n # apt-get install python-dev (ubuntu)"
56 "\n # yum install python-devel (Fedora)"
60 static int python_start_script_unsupported(const char *script __maybe_unused,
61 int argc __maybe_unused,
62 const char **argv __maybe_unused)
64 print_python_unsupported_msg();
69 static int python_generate_script_unsupported(struct pevent *pevent
74 print_python_unsupported_msg();
79 struct scripting_ops python_scripting_unsupported_ops = {
81 .start_script = python_start_script_unsupported,
82 .flush_script = flush_script_unsupported,
83 .stop_script = stop_script_unsupported,
84 .process_event = process_event_unsupported,
85 .generate_script = python_generate_script_unsupported,
88 static void register_python_scripting(struct scripting_ops *scripting_ops)
91 err = script_spec_register("Python", scripting_ops);
93 die("error registering Python script extension");
95 err = script_spec_register("py", scripting_ops);
97 die("error registering py script extension");
99 scripting_context = malloc(sizeof(struct scripting_context));
103 void setup_python_scripting(void)
105 register_python_scripting(&python_scripting_unsupported_ops);
108 extern struct scripting_ops python_scripting_ops;
110 void setup_python_scripting(void)
112 register_python_scripting(&python_scripting_ops);
116 static void print_perl_unsupported_msg(void)
118 fprintf(stderr, "Perl scripting not supported."
119 " Install libperl and rebuild perf to enable it.\n"
120 "For example:\n # apt-get install libperl-dev (ubuntu)"
121 "\n # yum install 'perl(ExtUtils::Embed)' (Fedora)"
125 static int perl_start_script_unsupported(const char *script __maybe_unused,
126 int argc __maybe_unused,
127 const char **argv __maybe_unused)
129 print_perl_unsupported_msg();
134 static int perl_generate_script_unsupported(struct pevent *pevent
136 const char *outfile __maybe_unused)
138 print_perl_unsupported_msg();
143 struct scripting_ops perl_scripting_unsupported_ops = {
145 .start_script = perl_start_script_unsupported,
146 .flush_script = flush_script_unsupported,
147 .stop_script = stop_script_unsupported,
148 .process_event = process_event_unsupported,
149 .generate_script = perl_generate_script_unsupported,
152 static void register_perl_scripting(struct scripting_ops *scripting_ops)
155 err = script_spec_register("Perl", scripting_ops);
157 die("error registering Perl script extension");
159 err = script_spec_register("pl", scripting_ops);
161 die("error registering pl script extension");
163 scripting_context = malloc(sizeof(struct scripting_context));
167 void setup_perl_scripting(void)
169 register_perl_scripting(&perl_scripting_unsupported_ops);
172 extern struct scripting_ops perl_scripting_ops;
174 void setup_perl_scripting(void)
176 register_perl_scripting(&perl_scripting_ops);