aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-scripting.c
diff options
context:
space:
mode:
authorTom Zanussi <tzanussi@gmail.com>2010-01-27 03:27:55 -0500
committerFrederic Weisbecker <fweisbec@gmail.com>2010-02-23 14:49:55 -0500
commit82d156cd5e817055c63ec50247a425c195f4cb14 (patch)
treeed41a42df0ea13472acd0ce806d4070f188fa468 /tools/perf/util/trace-event-scripting.c
parent7397d80ddde8eef3b1dce6c29e0c53bd322ef824 (diff)
perf/scripts: Move Perl scripting files to scripting-engines dir
Create a scripting-engines directory to contain scripting engine implementation code, in anticipation of the addition of new scripting support. Also removes trace-event-perl.h. 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-5-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.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
new file mode 100644
index 000000000000..9e371965c034
--- /dev/null
+++ b/tools/perf/util/trace-event-scripting.c
@@ -0,0 +1,106 @@
1/*
2 * trace-event-scripting. Scripting engine common and initialization code.
3 *
4 * Copyright (C) 2009-2010 Tom Zanussi <tzanussi@gmail.com>
5 *
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.
10 *
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.
15 *
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
19 *
20 */
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#include <ctype.h>
26#include <errno.h>
27
28#include "../perf.h"
29#include "util.h"
30#include "trace-event.h"
31
32struct scripting_context *scripting_context;
33
34static int stop_script_unsupported(void)
35{
36 return 0;
37}
38
39static void process_event_unsupported(int cpu __unused,
40 void *data __unused,
41 int size __unused,
42 unsigned long long nsecs __unused,
43 char *comm __unused)
44{
45}
46
47static void print_perl_unsupported_msg(void)
48{
49 fprintf(stderr, "Perl scripting not supported."
50 " Install libperl and rebuild perf to enable it.\n"
51 "For example:\n # apt-get install libperl-dev (ubuntu)"
52 "\n # yum install 'perl(ExtUtils::Embed)' (Fedora)"
53 "\n etc.\n");
54}
55
56static int perl_start_script_unsupported(const char *script __unused,
57 int argc __unused,
58 const char **argv __unused)
59{
60 print_perl_unsupported_msg();
61
62 return -1;
63}
64
65static int perl_generate_script_unsupported(const char *outfile __unused)
66{
67 print_perl_unsupported_msg();
68
69 return -1;
70}
71
72struct scripting_ops perl_scripting_unsupported_ops = {
73 .name = "Perl",
74 .start_script = perl_start_script_unsupported,
75 .stop_script = stop_script_unsupported,
76 .process_event = process_event_unsupported,
77 .generate_script = perl_generate_script_unsupported,
78};
79
80static void register_perl_scripting(struct scripting_ops *scripting_ops)
81{
82 int err;
83 err = script_spec_register("Perl", scripting_ops);
84 if (err)
85 die("error registering Perl script extension");
86
87 err = script_spec_register("pl", scripting_ops);
88 if (err)
89 die("error registering pl script extension");
90
91 scripting_context = malloc(sizeof(struct scripting_context));
92}
93
94#ifdef NO_LIBPERL
95void setup_perl_scripting(void)
96{
97 register_perl_scripting(&perl_scripting_unsupported_ops);
98}
99#else
100struct scripting_ops perl_scripting_ops;
101
102void setup_perl_scripting(void)
103{
104 register_perl_scripting(&perl_scripting_ops);
105}
106#endif