aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-perl.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/trace-event-perl.c')
-rw-r--r--tools/perf/util/trace-event-perl.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/tools/perf/util/trace-event-perl.c b/tools/perf/util/trace-event-perl.c
index c56b08d704d..d179adebc54 100644
--- a/tools/perf/util/trace-event-perl.c
+++ b/tools/perf/util/trace-event-perl.c
@@ -30,6 +30,21 @@
30#include "trace-event.h" 30#include "trace-event.h"
31#include "trace-event-perl.h" 31#include "trace-event-perl.h"
32 32
33void xs_init(pTHX);
34
35void boot_Perf__Trace__Context(pTHX_ CV *cv);
36void boot_DynaLoader(pTHX_ CV *cv);
37
38void xs_init(pTHX)
39{
40 const char *file = __FILE__;
41 dXSUB_SYS;
42
43 newXS("Perf::Trace::Context::bootstrap", boot_Perf__Trace__Context,
44 file);
45 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
46}
47
33INTERP my_perl; 48INTERP my_perl;
34 49
35#define FTRACE_MAX_EVENT \ 50#define FTRACE_MAX_EVENT \
@@ -227,6 +242,33 @@ static inline struct event *find_cache_event(int type)
227 return event; 242 return event;
228} 243}
229 244
245int get_common_pc(struct scripting_context *context)
246{
247 int pc;
248
249 pc = parse_common_pc(context->event_data);
250
251 return pc;
252}
253
254int get_common_flags(struct scripting_context *context)
255{
256 int flags;
257
258 flags = parse_common_flags(context->event_data);
259
260 return flags;
261}
262
263int get_common_lock_depth(struct scripting_context *context)
264{
265 int lock_depth;
266
267 lock_depth = parse_common_lock_depth(context->event_data);
268
269 return lock_depth;
270}
271
230static void perl_process_event(int cpu, void *data, 272static void perl_process_event(int cpu, void *data,
231 int size __attribute((unused)), 273 int size __attribute((unused)),
232 unsigned long long nsecs, char *comm) 274 unsigned long long nsecs, char *comm)
@@ -290,6 +332,7 @@ static void perl_process_event(int cpu, void *data,
290 } 332 }
291 333
292 PUTBACK; 334 PUTBACK;
335
293 if (get_cv(handler, 0)) 336 if (get_cv(handler, 0))
294 call_pv(handler, G_SCALAR); 337 call_pv(handler, G_SCALAR);
295 else if (get_cv("main::trace_unhandled", 0)) { 338 else if (get_cv("main::trace_unhandled", 0)) {
@@ -328,7 +371,8 @@ static int perl_start_script(const char *script)
328 my_perl = perl_alloc(); 371 my_perl = perl_alloc();
329 perl_construct(my_perl); 372 perl_construct(my_perl);
330 373
331 if (perl_parse(my_perl, NULL, 2, (char **)command_line, (char **)NULL)) 374 if (perl_parse(my_perl, xs_init, 2, (char **)command_line,
375 (char **)NULL))
332 return -1; 376 return -1;
333 377
334 perl_run(my_perl); 378 perl_run(my_perl);