Commit 67a6259ec97b8408f86f2fe8459d2233f0b0987d

Authored by Tom Zanussi
Committed by Ingo Molnar
1 parent 11a80ddbf3

perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

The 'scripting unsupported' message should only be displayed
when the -s or -g options are used, and not when they aren't, as
the current code does.

Signed-off-by: Tom Zanussi <tzanussi@gmail.com>
Cc: rostedt@goodmis.org
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1260163919-6679-3-git-send-email-tzanussi@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 55 additions and 9 deletions Side-by-side Diff

tools/perf/util/trace-event-perl.c
... ... @@ -570,27 +570,73 @@
570 570 .generate_script = perl_generate_script,
571 571 };
572 572  
573   -#ifdef NO_LIBPERL
574   -void setup_perl_scripting(void)
  573 +static void print_unsupported_msg(void)
575 574 {
576 575 fprintf(stderr, "Perl scripting not supported."
577   - " Install libperl and rebuild perf to enable it. e.g. "
578   - "apt-get install libperl-dev (ubuntu), yum install "
579   - "perl-ExtUtils-Embed (Fedora), etc.\n");
  576 + " Install libperl and rebuild perf to enable it.\n"
  577 + "For example:\n # apt-get install libperl-dev (ubuntu)"
  578 + "\n # yum install perl-ExtUtils-Embed (Fedora)"
  579 + "\n etc.\n");
580 580 }
581   -#else
582   -void setup_perl_scripting(void)
  581 +
  582 +static int perl_start_script_unsupported(const char *script __unused)
583 583 {
  584 + print_unsupported_msg();
  585 +
  586 + return -1;
  587 +}
  588 +
  589 +static int perl_stop_script_unsupported(void)
  590 +{
  591 + return 0;
  592 +}
  593 +
  594 +static void perl_process_event_unsupported(int cpu __unused,
  595 + void *data __unused,
  596 + int size __unused,
  597 + unsigned long long nsecs __unused,
  598 + char *comm __unused)
  599 +{
  600 +}
  601 +
  602 +static int perl_generate_script_unsupported(const char *outfile __unused)
  603 +{
  604 + print_unsupported_msg();
  605 +
  606 + return -1;
  607 +}
  608 +
  609 +struct scripting_ops perl_scripting_unsupported_ops = {
  610 + .name = "Perl",
  611 + .start_script = perl_start_script_unsupported,
  612 + .stop_script = perl_stop_script_unsupported,
  613 + .process_event = perl_process_event_unsupported,
  614 + .generate_script = perl_generate_script_unsupported,
  615 +};
  616 +
  617 +static void register_perl_scripting(struct scripting_ops *scripting_ops)
  618 +{
584 619 int err;
585   - err = script_spec_register("Perl", &perl_scripting_ops);
  620 + err = script_spec_register("Perl", scripting_ops);
586 621 if (err)
587 622 die("error registering Perl script extension");
588 623  
589   - err = script_spec_register("pl", &perl_scripting_ops);
  624 + err = script_spec_register("pl", scripting_ops);
590 625 if (err)
591 626 die("error registering pl script extension");
592 627  
593 628 scripting_context = malloc(sizeof(struct scripting_context));
  629 +}
  630 +
  631 +#ifdef NO_LIBPERL
  632 +void setup_perl_scripting(void)
  633 +{
  634 + register_perl_scripting(&perl_scripting_unsupported_ops);
  635 +}
  636 +#else
  637 +void setup_perl_scripting(void)
  638 +{
  639 + register_perl_scripting(&perl_scripting_ops);
594 640 }
595 641 #endif