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.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/tools/perf/util/trace-event-perl.c b/tools/perf/util/trace-event-perl.c
index a5ffe60db5d6..6f10e7602452 100644
--- a/tools/perf/util/trace-event-perl.c
+++ b/tools/perf/util/trace-event-perl.c
@@ -267,7 +267,7 @@ int common_lock_depth(struct scripting_context *context)
267} 267}
268 268
269static void perl_process_event(int cpu, void *data, 269static void perl_process_event(int cpu, void *data,
270 int size __attribute((unused)), 270 int size __unused,
271 unsigned long long nsecs, char *comm) 271 unsigned long long nsecs, char *comm)
272{ 272{
273 struct format_field *field; 273 struct format_field *field;
@@ -359,28 +359,42 @@ static void run_start_sub(void)
359/* 359/*
360 * Start trace script 360 * Start trace script
361 */ 361 */
362static int perl_start_script(const char *script) 362static int perl_start_script(const char *script, int argc, const char **argv)
363{ 363{
364 const char *command_line[2] = { "", NULL }; 364 const char **command_line;
365 int i, err = 0;
365 366
367 command_line = malloc((argc + 2) * sizeof(const char *));
368 command_line[0] = "";
366 command_line[1] = script; 369 command_line[1] = script;
370 for (i = 2; i < argc + 2; i++)
371 command_line[i] = argv[i - 2];
367 372
368 my_perl = perl_alloc(); 373 my_perl = perl_alloc();
369 perl_construct(my_perl); 374 perl_construct(my_perl);
370 375
371 if (perl_parse(my_perl, xs_init, 2, (char **)command_line, 376 if (perl_parse(my_perl, xs_init, argc + 2, (char **)command_line,
372 (char **)NULL)) 377 (char **)NULL)) {
373 return -1; 378 err = -1;
379 goto error;
380 }
374 381
375 perl_run(my_perl); 382 perl_run(my_perl);
376 if (SvTRUE(ERRSV)) 383 if (SvTRUE(ERRSV)) {
377 return -1; 384 err = -1;
385 goto error;
386 }
378 387
379 run_start_sub(); 388 run_start_sub();
380 389
390 free(command_line);
381 fprintf(stderr, "perf trace started with Perl script %s\n\n", script); 391 fprintf(stderr, "perf trace started with Perl script %s\n\n", script);
382
383 return 0; 392 return 0;
393error:
394 perl_free(my_perl);
395 free(command_line);
396
397 return err;
384} 398}
385 399
386/* 400/*
@@ -579,7 +593,9 @@ static void print_unsupported_msg(void)
579 "\n etc.\n"); 593 "\n etc.\n");
580} 594}
581 595
582static int perl_start_script_unsupported(const char *script __unused) 596static int perl_start_script_unsupported(const char *script __unused,
597 int argc __unused,
598 const char **argv __unused)
583{ 599{
584 print_unsupported_msg(); 600 print_unsupported_msg();
585 601