]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - tools/perf/util/trace-event-scripting.c
perf script: Replace "struct thread" with "struct addr_location" as a parameter for...
[mirror_ubuntu-jammy-kernel.git] / tools / perf / util / trace-event-scripting.c
CommitLineData
82d156cd
TZ
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>
82d156cd
TZ
25#include <errno.h>
26
27#include "../perf.h"
28#include "util.h"
29#include "trace-event.h"
30
31struct scripting_context *scripting_context;
32
33static int stop_script_unsupported(void)
34{
35 return 0;
36}
37
be6d842a
DA
38static void process_event_unsupported(union perf_event *event __unused,
39 struct perf_sample *sample __unused,
9e69c210 40 struct perf_evsel *evsel __unused,
743eb868 41 struct machine *machine __unused,
73994dc1 42 struct addr_location *al __unused)
82d156cd
TZ
43{
44}
45
7e4b21b8
TZ
46static void print_python_unsupported_msg(void)
47{
48 fprintf(stderr, "Python scripting not supported."
49 " Install libpython and rebuild perf to enable it.\n"
50 "For example:\n # apt-get install python-dev (ubuntu)"
51 "\n # yum install python-devel (Fedora)"
52 "\n etc.\n");
53}
54
55static int python_start_script_unsupported(const char *script __unused,
56 int argc __unused,
57 const char **argv __unused)
58{
59 print_python_unsupported_msg();
60
61 return -1;
62}
63
da378962
ACM
64static int python_generate_script_unsupported(struct pevent *pevent __unused,
65 const char *outfile __unused)
7e4b21b8
TZ
66{
67 print_python_unsupported_msg();
68
69 return -1;
70}
71
72struct 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
80static 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
95void setup_python_scripting(void)
96{
97 register_python_scripting(&python_scripting_unsupported_ops);
98}
99#else
0f940cb7 100extern struct scripting_ops python_scripting_ops;
7e4b21b8
TZ
101
102void setup_python_scripting(void)
103{
104 register_python_scripting(&python_scripting_ops);
105}
106#endif
107
82d156cd
TZ
108static void print_perl_unsupported_msg(void)
109{
110 fprintf(stderr, "Perl scripting not supported."
111 " Install libperl and rebuild perf to enable it.\n"
112 "For example:\n # apt-get install libperl-dev (ubuntu)"
113 "\n # yum install 'perl(ExtUtils::Embed)' (Fedora)"
114 "\n etc.\n");
115}
116
117static int perl_start_script_unsupported(const char *script __unused,
118 int argc __unused,
119 const char **argv __unused)
120{
121 print_perl_unsupported_msg();
122
123 return -1;
124}
125
da378962
ACM
126static int perl_generate_script_unsupported(struct pevent *pevent __unused,
127 const char *outfile __unused)
82d156cd
TZ
128{
129 print_perl_unsupported_msg();
130
131 return -1;
132}
133
134struct scripting_ops perl_scripting_unsupported_ops = {
135 .name = "Perl",
136 .start_script = perl_start_script_unsupported,
137 .stop_script = stop_script_unsupported,
138 .process_event = process_event_unsupported,
139 .generate_script = perl_generate_script_unsupported,
140};
141
142static void register_perl_scripting(struct scripting_ops *scripting_ops)
143{
144 int err;
145 err = script_spec_register("Perl", scripting_ops);
146 if (err)
147 die("error registering Perl script extension");
148
149 err = script_spec_register("pl", scripting_ops);
150 if (err)
151 die("error registering pl script extension");
152
153 scripting_context = malloc(sizeof(struct scripting_context));
154}
155
156#ifdef NO_LIBPERL
157void setup_perl_scripting(void)
158{
159 register_perl_scripting(&perl_scripting_unsupported_ops);
160}
161#else
0f940cb7 162extern struct scripting_ops perl_scripting_ops;
82d156cd
TZ
163
164void setup_perl_scripting(void)
165{
166 register_perl_scripting(&perl_scripting_ops);
167}
168#endif