diff options
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c (renamed from tools/perf/util/trace-event-perl.c) | 88 | ||||
| -rw-r--r-- | tools/perf/util/trace-event-perl.h | 47 | ||||
| -rw-r--r-- | tools/perf/util/trace-event-scripting.c | 106 |
3 files changed, 117 insertions, 124 deletions
diff --git a/tools/perf/util/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 5b49df067df0..5376378e0cfc 100644 --- a/tools/perf/util/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
| @@ -25,10 +25,16 @@ | |||
| 25 | #include <ctype.h> | 25 | #include <ctype.h> |
| 26 | #include <errno.h> | 26 | #include <errno.h> |
| 27 | 27 | ||
| 28 | #include "../perf.h" | 28 | #include "../../perf.h" |
| 29 | #include "util.h" | 29 | #include "../util.h" |
| 30 | #include "trace-event.h" | 30 | #include "../trace-event.h" |
| 31 | #include "trace-event-perl.h" | 31 | |
| 32 | #include <EXTERN.h> | ||
| 33 | #include <perl.h> | ||
| 34 | |||
| 35 | void boot_Perf__Trace__Context(pTHX_ CV *cv); | ||
| 36 | void boot_DynaLoader(pTHX_ CV *cv); | ||
| 37 | typedef PerlInterpreter * INTERP; | ||
| 32 | 38 | ||
| 33 | void xs_init(pTHX); | 39 | void xs_init(pTHX); |
| 34 | 40 | ||
| @@ -49,7 +55,7 @@ INTERP my_perl; | |||
| 49 | 55 | ||
| 50 | struct event *events[FTRACE_MAX_EVENT]; | 56 | struct event *events[FTRACE_MAX_EVENT]; |
| 51 | 57 | ||
| 52 | static struct scripting_context *scripting_context; | 58 | extern struct scripting_context *scripting_context; |
| 53 | 59 | ||
| 54 | static char *cur_field_name; | 60 | static char *cur_field_name; |
| 55 | static int zero_flag_atom; | 61 | static int zero_flag_atom; |
| @@ -560,75 +566,3 @@ struct scripting_ops perl_scripting_ops = { | |||
| 560 | .process_event = perl_process_event, | 566 | .process_event = perl_process_event, |
| 561 | .generate_script = perl_generate_script, | 567 | .generate_script = perl_generate_script, |
| 562 | }; | 568 | }; |
| 563 | |||
| 564 | static void print_unsupported_msg(void) | ||
| 565 | { | ||
| 566 | fprintf(stderr, "Perl scripting not supported." | ||
| 567 | " Install libperl and rebuild perf to enable it.\n" | ||
| 568 | "For example:\n # apt-get install libperl-dev (ubuntu)" | ||
| 569 | "\n # yum install perl-ExtUtils-Embed (Fedora)" | ||
| 570 | "\n etc.\n"); | ||
| 571 | } | ||
| 572 | |||
| 573 | static int perl_start_script_unsupported(const char *script __unused, | ||
| 574 | int argc __unused, | ||
| 575 | const char **argv __unused) | ||
| 576 | { | ||
| 577 | print_unsupported_msg(); | ||
| 578 | |||
| 579 | return -1; | ||
| 580 | } | ||
| 581 | |||
| 582 | static int perl_stop_script_unsupported(void) | ||
| 583 | { | ||
| 584 | return 0; | ||
| 585 | } | ||
| 586 | |||
| 587 | static void perl_process_event_unsupported(int cpu __unused, | ||
| 588 | void *data __unused, | ||
| 589 | int size __unused, | ||
| 590 | unsigned long long nsecs __unused, | ||
| 591 | char *comm __unused) | ||
| 592 | { | ||
| 593 | } | ||
| 594 | |||
| 595 | static int perl_generate_script_unsupported(const char *outfile __unused) | ||
| 596 | { | ||
| 597 | print_unsupported_msg(); | ||
| 598 | |||
| 599 | return -1; | ||
| 600 | } | ||
| 601 | |||
| 602 | struct scripting_ops perl_scripting_unsupported_ops = { | ||
| 603 | .name = "Perl", | ||
| 604 | .start_script = perl_start_script_unsupported, | ||
| 605 | .stop_script = perl_stop_script_unsupported, | ||
| 606 | .process_event = perl_process_event_unsupported, | ||
| 607 | .generate_script = perl_generate_script_unsupported, | ||
| 608 | }; | ||
| 609 | |||
| 610 | static void register_perl_scripting(struct scripting_ops *scripting_ops) | ||
| 611 | { | ||
| 612 | int err; | ||
| 613 | err = script_spec_register("Perl", scripting_ops); | ||
| 614 | if (err) | ||
| 615 | die("error registering Perl script extension"); | ||
| 616 | |||
| 617 | err = script_spec_register("pl", scripting_ops); | ||
| 618 | if (err) | ||
| 619 | die("error registering pl script extension"); | ||
| 620 | |||
| 621 | scripting_context = malloc(sizeof(struct scripting_context)); | ||
| 622 | } | ||
| 623 | |||
| 624 | #ifdef NO_LIBPERL | ||
| 625 | void setup_perl_scripting(void) | ||
| 626 | { | ||
| 627 | register_perl_scripting(&perl_scripting_unsupported_ops); | ||
| 628 | } | ||
| 629 | #else | ||
| 630 | void setup_perl_scripting(void) | ||
| 631 | { | ||
| 632 | register_perl_scripting(&perl_scripting_ops); | ||
| 633 | } | ||
| 634 | #endif | ||
diff --git a/tools/perf/util/trace-event-perl.h b/tools/perf/util/trace-event-perl.h deleted file mode 100644 index 01efcc9564fb..000000000000 --- a/tools/perf/util/trace-event-perl.h +++ /dev/null | |||
| @@ -1,47 +0,0 @@ | |||
| 1 | #ifndef __PERF_TRACE_EVENT_PERL_H | ||
| 2 | #define __PERF_TRACE_EVENT_PERL_H | ||
| 3 | #ifdef NO_LIBPERL | ||
| 4 | typedef int INTERP; | ||
| 5 | #define dSP | ||
| 6 | #define ENTER | ||
| 7 | #define SAVETMPS | ||
| 8 | #define PUTBACK | ||
| 9 | #define SPAGAIN | ||
| 10 | #define FREETMPS | ||
| 11 | #define LEAVE | ||
| 12 | #define SP | ||
| 13 | #define ERRSV | ||
| 14 | #define G_SCALAR (0) | ||
| 15 | #define G_DISCARD (0) | ||
| 16 | #define G_NOARGS (0) | ||
| 17 | #define PUSHMARK(a) | ||
| 18 | #define SvTRUE(a) (0) | ||
| 19 | #define XPUSHs(s) | ||
| 20 | #define sv_2mortal(a) | ||
| 21 | #define newSVpv(a,b) | ||
| 22 | #define newSVuv(a) | ||
| 23 | #define newSViv(a) | ||
| 24 | #define get_cv(a,b) (0) | ||
| 25 | #define call_pv(a,b) (0) | ||
| 26 | #define perl_alloc() (0) | ||
| 27 | #define perl_construct(a) (0) | ||
| 28 | #define perl_parse(a,b,c,d,e) (0) | ||
| 29 | #define perl_run(a) (0) | ||
| 30 | #define perl_destruct(a) (0) | ||
| 31 | #define perl_free(a) (0) | ||
| 32 | #define pTHX void | ||
| 33 | #define CV void | ||
| 34 | #define dXSUB_SYS | ||
| 35 | #define pTHX_ | ||
| 36 | static inline void newXS(const char *a, void *b, const char *c) {} | ||
| 37 | static void boot_Perf__Trace__Context(pTHX_ CV *cv) {} | ||
| 38 | static void boot_DynaLoader(pTHX_ CV *cv) {} | ||
| 39 | #else | ||
| 40 | #include <EXTERN.h> | ||
| 41 | #include <perl.h> | ||
| 42 | void boot_Perf__Trace__Context(pTHX_ CV *cv); | ||
| 43 | void boot_DynaLoader(pTHX_ CV *cv); | ||
| 44 | typedef PerlInterpreter * INTERP; | ||
| 45 | #endif | ||
| 46 | |||
| 47 | #endif /* __PERF_TRACE_EVENT_PERL_H */ | ||
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 | |||
| 32 | struct scripting_context *scripting_context; | ||
| 33 | |||
| 34 | static int stop_script_unsupported(void) | ||
| 35 | { | ||
| 36 | return 0; | ||
| 37 | } | ||
| 38 | |||
| 39 | static 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 | |||
| 47 | static 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 | |||
| 56 | static 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 | |||
| 65 | static int perl_generate_script_unsupported(const char *outfile __unused) | ||
| 66 | { | ||
| 67 | print_perl_unsupported_msg(); | ||
| 68 | |||
| 69 | return -1; | ||
| 70 | } | ||
| 71 | |||
| 72 | struct 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 | |||
| 80 | static 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 | ||
| 95 | void setup_perl_scripting(void) | ||
| 96 | { | ||
| 97 | register_perl_scripting(&perl_scripting_unsupported_ops); | ||
| 98 | } | ||
| 99 | #else | ||
| 100 | struct scripting_ops perl_scripting_ops; | ||
| 101 | |||
| 102 | void setup_perl_scripting(void) | ||
| 103 | { | ||
| 104 | register_perl_scripting(&perl_scripting_ops); | ||
| 105 | } | ||
| 106 | #endif | ||
