diff options
Diffstat (limited to 'tools/perf/scripts/perl/Perf-Trace-Util')
8 files changed, 587 insertions, 0 deletions
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Context.c b/tools/perf/scripts/perl/Perf-Trace-Util/Context.c new file mode 100644 index 000000000000..af78d9a52a7d --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Context.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * This file was generated automatically by ExtUtils::ParseXS version 2.18_02 from the | ||
3 | * contents of Context.xs. Do not edit this file, edit Context.xs instead. | ||
4 | * | ||
5 | * ANY CHANGES MADE HERE WILL BE LOST! | ||
6 | * | ||
7 | */ | ||
8 | |||
9 | #line 1 "Context.xs" | ||
10 | /* | ||
11 | * Context.xs. XS interfaces for perf trace. | ||
12 | * | ||
13 | * Copyright (C) 2009 Tom Zanussi <tzanussi@gmail.com> | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or | ||
18 | * (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | #include "EXTERN.h" | ||
32 | #include "perl.h" | ||
33 | #include "XSUB.h" | ||
34 | #include "../../../util/trace-event-perl.h" | ||
35 | |||
36 | #ifndef PERL_UNUSED_VAR | ||
37 | # define PERL_UNUSED_VAR(var) if (0) var = var | ||
38 | #endif | ||
39 | |||
40 | #line 41 "Context.c" | ||
41 | |||
42 | XS(XS_Perf__Trace__Context_common_pc); /* prototype to pass -Wmissing-prototypes */ | ||
43 | XS(XS_Perf__Trace__Context_common_pc) | ||
44 | { | ||
45 | #ifdef dVAR | ||
46 | dVAR; dXSARGS; | ||
47 | #else | ||
48 | dXSARGS; | ||
49 | #endif | ||
50 | if (items != 1) | ||
51 | Perl_croak(aTHX_ "Usage: %s(%s)", "Perf::Trace::Context::common_pc", "context"); | ||
52 | PERL_UNUSED_VAR(cv); /* -W */ | ||
53 | { | ||
54 | struct scripting_context * context = INT2PTR(struct scripting_context *,SvIV(ST(0))); | ||
55 | int RETVAL; | ||
56 | dXSTARG; | ||
57 | |||
58 | RETVAL = common_pc(context); | ||
59 | XSprePUSH; PUSHi((IV)RETVAL); | ||
60 | } | ||
61 | XSRETURN(1); | ||
62 | } | ||
63 | |||
64 | |||
65 | XS(XS_Perf__Trace__Context_common_flags); /* prototype to pass -Wmissing-prototypes */ | ||
66 | XS(XS_Perf__Trace__Context_common_flags) | ||
67 | { | ||
68 | #ifdef dVAR | ||
69 | dVAR; dXSARGS; | ||
70 | #else | ||
71 | dXSARGS; | ||
72 | #endif | ||
73 | if (items != 1) | ||
74 | Perl_croak(aTHX_ "Usage: %s(%s)", "Perf::Trace::Context::common_flags", "context"); | ||
75 | PERL_UNUSED_VAR(cv); /* -W */ | ||
76 | { | ||
77 | struct scripting_context * context = INT2PTR(struct scripting_context *,SvIV(ST(0))); | ||
78 | int RETVAL; | ||
79 | dXSTARG; | ||
80 | |||
81 | RETVAL = common_flags(context); | ||
82 | XSprePUSH; PUSHi((IV)RETVAL); | ||
83 | } | ||
84 | XSRETURN(1); | ||
85 | } | ||
86 | |||
87 | |||
88 | XS(XS_Perf__Trace__Context_common_lock_depth); /* prototype to pass -Wmissing-prototypes */ | ||
89 | XS(XS_Perf__Trace__Context_common_lock_depth) | ||
90 | { | ||
91 | #ifdef dVAR | ||
92 | dVAR; dXSARGS; | ||
93 | #else | ||
94 | dXSARGS; | ||
95 | #endif | ||
96 | if (items != 1) | ||
97 | Perl_croak(aTHX_ "Usage: %s(%s)", "Perf::Trace::Context::common_lock_depth", "context"); | ||
98 | PERL_UNUSED_VAR(cv); /* -W */ | ||
99 | { | ||
100 | struct scripting_context * context = INT2PTR(struct scripting_context *,SvIV(ST(0))); | ||
101 | int RETVAL; | ||
102 | dXSTARG; | ||
103 | |||
104 | RETVAL = common_lock_depth(context); | ||
105 | XSprePUSH; PUSHi((IV)RETVAL); | ||
106 | } | ||
107 | XSRETURN(1); | ||
108 | } | ||
109 | |||
110 | #ifdef __cplusplus | ||
111 | extern "C" | ||
112 | #endif | ||
113 | XS(boot_Perf__Trace__Context); /* prototype to pass -Wmissing-prototypes */ | ||
114 | XS(boot_Perf__Trace__Context) | ||
115 | { | ||
116 | #ifdef dVAR | ||
117 | dVAR; dXSARGS; | ||
118 | #else | ||
119 | dXSARGS; | ||
120 | #endif | ||
121 | const char* file = __FILE__; | ||
122 | |||
123 | PERL_UNUSED_VAR(cv); /* -W */ | ||
124 | PERL_UNUSED_VAR(items); /* -W */ | ||
125 | XS_VERSION_BOOTCHECK ; | ||
126 | |||
127 | newXSproto("Perf::Trace::Context::common_pc", XS_Perf__Trace__Context_common_pc, file, "$"); | ||
128 | newXSproto("Perf::Trace::Context::common_flags", XS_Perf__Trace__Context_common_flags, file, "$"); | ||
129 | newXSproto("Perf::Trace::Context::common_lock_depth", XS_Perf__Trace__Context_common_lock_depth, file, "$"); | ||
130 | if (PL_unitcheckav) | ||
131 | call_list(PL_scopestack_ix, PL_unitcheckav); | ||
132 | XSRETURN_YES; | ||
133 | } | ||
134 | |||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs b/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs new file mode 100644 index 000000000000..fb78006c165e --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Context.xs | |||
@@ -0,0 +1,41 @@ | |||
1 | /* | ||
2 | * Context.xs. XS interfaces for perf trace. | ||
3 | * | ||
4 | * Copyright (C) 2009 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 "EXTERN.h" | ||
23 | #include "perl.h" | ||
24 | #include "XSUB.h" | ||
25 | #include "../../../util/trace-event-perl.h" | ||
26 | |||
27 | MODULE = Perf::Trace::Context PACKAGE = Perf::Trace::Context | ||
28 | PROTOTYPES: ENABLE | ||
29 | |||
30 | int | ||
31 | common_pc(context) | ||
32 | struct scripting_context * context | ||
33 | |||
34 | int | ||
35 | common_flags(context) | ||
36 | struct scripting_context * context | ||
37 | |||
38 | int | ||
39 | common_lock_depth(context) | ||
40 | struct scripting_context * context | ||
41 | |||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL b/tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL new file mode 100644 index 000000000000..decdeb0f6789 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL | |||
@@ -0,0 +1,17 @@ | |||
1 | use 5.010000; | ||
2 | use ExtUtils::MakeMaker; | ||
3 | # See lib/ExtUtils/MakeMaker.pm for details of how to influence | ||
4 | # the contents of the Makefile that is written. | ||
5 | WriteMakefile( | ||
6 | NAME => 'Perf::Trace::Context', | ||
7 | VERSION_FROM => 'lib/Perf/Trace/Context.pm', # finds $VERSION | ||
8 | PREREQ_PM => {}, # e.g., Module::Name => 1.1 | ||
9 | ($] >= 5.005 ? ## Add these new keywords supported since 5.005 | ||
10 | (ABSTRACT_FROM => 'lib/Perf/Trace/Context.pm', # retrieve abstract from module | ||
11 | AUTHOR => 'Tom Zanussi <tzanussi@gmail.com>') : ()), | ||
12 | LIBS => [''], # e.g., '-lm' | ||
13 | DEFINE => '-I ../..', # e.g., '-DHAVE_SOMETHING' | ||
14 | INC => '-I.', # e.g., '-I. -I/usr/include/other' | ||
15 | # Un-comment this if you add C files to link with later: | ||
16 | OBJECT => 'Context.o', # link all the C files too | ||
17 | ); | ||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/README b/tools/perf/scripts/perl/Perf-Trace-Util/README new file mode 100644 index 000000000000..9a9707630791 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/README | |||
@@ -0,0 +1,59 @@ | |||
1 | Perf-Trace-Util version 0.01 | ||
2 | ============================ | ||
3 | |||
4 | This module contains utility functions for use with perf trace. | ||
5 | |||
6 | Core.pm and Util.pm are pure Perl modules; Core.pm contains routines | ||
7 | that the core perf support for Perl calls on and should always be | ||
8 | 'used', while Util.pm contains useful but optional utility functions | ||
9 | that scripts may want to use. Context.pm contains the Perl->C | ||
10 | interface that allows scripts to access data in the embedding perf | ||
11 | executable; scripts wishing to do that should 'use Context.pm'. | ||
12 | |||
13 | The Perl->C perf interface is completely driven by Context.xs. If you | ||
14 | want to add new Perl functions that end up accessing C data in the | ||
15 | perf executable, you add desciptions of the new functions here. | ||
16 | scripting_context is a pointer to the perf data in the perf executable | ||
17 | that you want to access - it's passed as the second parameter, | ||
18 | $context, to all handler functions. | ||
19 | |||
20 | After you do that: | ||
21 | |||
22 | perl Makefile.PL # to create a Makefile for the next step | ||
23 | make # to create Context.c | ||
24 | |||
25 | edit Context.c to add const to the char* file = __FILE__ line in | ||
26 | XS(boot_Perf__Trace__Context) to silence a warning/error. | ||
27 | |||
28 | You can delete the Makefile, object files and anything else that was | ||
29 | generated e.g. blib and shared library, etc, except for of course | ||
30 | Context.c | ||
31 | |||
32 | You should then be able to run the normal perf make as usual. | ||
33 | |||
34 | INSTALLATION | ||
35 | |||
36 | Building perf with perf trace Perl scripting should install this | ||
37 | module in the right place. | ||
38 | |||
39 | You should make sure libperl and ExtUtils/Embed.pm are installed first | ||
40 | e.g. apt-get install libperl-dev or yum install perl-ExtUtils-Embed. | ||
41 | |||
42 | DEPENDENCIES | ||
43 | |||
44 | This module requires these other modules and libraries: | ||
45 | |||
46 | None | ||
47 | |||
48 | COPYRIGHT AND LICENCE | ||
49 | |||
50 | Copyright (C) 2009 by Tom Zanussi <tzanussi@gmail.com> | ||
51 | |||
52 | This library is free software; you can redistribute it and/or modify | ||
53 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||
54 | at your option, any later version of Perl 5 you may have available. | ||
55 | |||
56 | Alternatively, this software may be distributed under the terms of the | ||
57 | GNU General Public License ("GPL") version 2 as published by the Free | ||
58 | Software Foundation. | ||
59 | |||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm new file mode 100644 index 000000000000..6c7f3659cb17 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm | |||
@@ -0,0 +1,55 @@ | |||
1 | package Perf::Trace::Context; | ||
2 | |||
3 | use 5.010000; | ||
4 | use strict; | ||
5 | use warnings; | ||
6 | |||
7 | require Exporter; | ||
8 | |||
9 | our @ISA = qw(Exporter); | ||
10 | |||
11 | our %EXPORT_TAGS = ( 'all' => [ qw( | ||
12 | ) ] ); | ||
13 | |||
14 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
15 | |||
16 | our @EXPORT = qw( | ||
17 | common_pc common_flags common_lock_depth | ||
18 | ); | ||
19 | |||
20 | our $VERSION = '0.01'; | ||
21 | |||
22 | require XSLoader; | ||
23 | XSLoader::load('Perf::Trace::Context', $VERSION); | ||
24 | |||
25 | 1; | ||
26 | __END__ | ||
27 | =head1 NAME | ||
28 | |||
29 | Perf::Trace::Context - Perl extension for accessing functions in perf. | ||
30 | |||
31 | =head1 SYNOPSIS | ||
32 | |||
33 | use Perf::Trace::Context; | ||
34 | |||
35 | =head1 SEE ALSO | ||
36 | |||
37 | Perf (trace) documentation | ||
38 | |||
39 | =head1 AUTHOR | ||
40 | |||
41 | Tom Zanussi, E<lt>tzanussi@gmail.com<gt> | ||
42 | |||
43 | =head1 COPYRIGHT AND LICENSE | ||
44 | |||
45 | Copyright (C) 2009 by Tom Zanussi | ||
46 | |||
47 | This library is free software; you can redistribute it and/or modify | ||
48 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||
49 | at your option, any later version of Perl 5 you may have available. | ||
50 | |||
51 | Alternatively, this software may be distributed under the terms of the | ||
52 | GNU General Public License ("GPL") version 2 as published by the Free | ||
53 | Software Foundation. | ||
54 | |||
55 | =cut | ||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm new file mode 100644 index 000000000000..9df376a9f629 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm | |||
@@ -0,0 +1,192 @@ | |||
1 | package Perf::Trace::Core; | ||
2 | |||
3 | use 5.010000; | ||
4 | use strict; | ||
5 | use warnings; | ||
6 | |||
7 | require Exporter; | ||
8 | |||
9 | our @ISA = qw(Exporter); | ||
10 | |||
11 | our %EXPORT_TAGS = ( 'all' => [ qw( | ||
12 | ) ] ); | ||
13 | |||
14 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
15 | |||
16 | our @EXPORT = qw( | ||
17 | define_flag_field define_flag_value flag_str dump_flag_fields | ||
18 | define_symbolic_field define_symbolic_value symbol_str dump_symbolic_fields | ||
19 | trace_flag_str | ||
20 | ); | ||
21 | |||
22 | our $VERSION = '0.01'; | ||
23 | |||
24 | my %trace_flags = (0x00 => "NONE", | ||
25 | 0x01 => "IRQS_OFF", | ||
26 | 0x02 => "IRQS_NOSUPPORT", | ||
27 | 0x04 => "NEED_RESCHED", | ||
28 | 0x08 => "HARDIRQ", | ||
29 | 0x10 => "SOFTIRQ"); | ||
30 | |||
31 | sub trace_flag_str | ||
32 | { | ||
33 | my ($value) = @_; | ||
34 | |||
35 | my $string; | ||
36 | |||
37 | my $print_delim = 0; | ||
38 | |||
39 | foreach my $idx (sort {$a <=> $b} keys %trace_flags) { | ||
40 | if (!$value && !$idx) { | ||
41 | $string .= "NONE"; | ||
42 | last; | ||
43 | } | ||
44 | |||
45 | if ($idx && ($value & $idx) == $idx) { | ||
46 | if ($print_delim) { | ||
47 | $string .= " | "; | ||
48 | } | ||
49 | $string .= "$trace_flags{$idx}"; | ||
50 | $print_delim = 1; | ||
51 | $value &= ~$idx; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | return $string; | ||
56 | } | ||
57 | |||
58 | my %flag_fields; | ||
59 | my %symbolic_fields; | ||
60 | |||
61 | sub flag_str | ||
62 | { | ||
63 | my ($event_name, $field_name, $value) = @_; | ||
64 | |||
65 | my $string; | ||
66 | |||
67 | if ($flag_fields{$event_name}{$field_name}) { | ||
68 | my $print_delim = 0; | ||
69 | foreach my $idx (sort {$a <=> $b} keys %{$flag_fields{$event_name}{$field_name}{"values"}}) { | ||
70 | if (!$value && !$idx) { | ||
71 | $string .= "$flag_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
72 | last; | ||
73 | } | ||
74 | if ($idx && ($value & $idx) == $idx) { | ||
75 | if ($print_delim && $flag_fields{$event_name}{$field_name}{'delim'}) { | ||
76 | $string .= " $flag_fields{$event_name}{$field_name}{'delim'} "; | ||
77 | } | ||
78 | $string .= "$flag_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
79 | $print_delim = 1; | ||
80 | $value &= ~$idx; | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | |||
85 | return $string; | ||
86 | } | ||
87 | |||
88 | sub define_flag_field | ||
89 | { | ||
90 | my ($event_name, $field_name, $delim) = @_; | ||
91 | |||
92 | $flag_fields{$event_name}{$field_name}{"delim"} = $delim; | ||
93 | } | ||
94 | |||
95 | sub define_flag_value | ||
96 | { | ||
97 | my ($event_name, $field_name, $value, $field_str) = @_; | ||
98 | |||
99 | $flag_fields{$event_name}{$field_name}{"values"}{$value} = $field_str; | ||
100 | } | ||
101 | |||
102 | sub dump_flag_fields | ||
103 | { | ||
104 | for my $event (keys %flag_fields) { | ||
105 | print "event $event:\n"; | ||
106 | for my $field (keys %{$flag_fields{$event}}) { | ||
107 | print " field: $field:\n"; | ||
108 | print " delim: $flag_fields{$event}{$field}{'delim'}\n"; | ||
109 | foreach my $idx (sort {$a <=> $b} keys %{$flag_fields{$event}{$field}{"values"}}) { | ||
110 | print " value $idx: $flag_fields{$event}{$field}{'values'}{$idx}\n"; | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | sub symbol_str | ||
117 | { | ||
118 | my ($event_name, $field_name, $value) = @_; | ||
119 | |||
120 | if ($symbolic_fields{$event_name}{$field_name}) { | ||
121 | foreach my $idx (sort {$a <=> $b} keys %{$symbolic_fields{$event_name}{$field_name}{"values"}}) { | ||
122 | if (!$value && !$idx) { | ||
123 | return "$symbolic_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
124 | last; | ||
125 | } | ||
126 | if ($value == $idx) { | ||
127 | return "$symbolic_fields{$event_name}{$field_name}{'values'}{$idx}"; | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | return undef; | ||
133 | } | ||
134 | |||
135 | sub define_symbolic_field | ||
136 | { | ||
137 | my ($event_name, $field_name) = @_; | ||
138 | |||
139 | # nothing to do, really | ||
140 | } | ||
141 | |||
142 | sub define_symbolic_value | ||
143 | { | ||
144 | my ($event_name, $field_name, $value, $field_str) = @_; | ||
145 | |||
146 | $symbolic_fields{$event_name}{$field_name}{"values"}{$value} = $field_str; | ||
147 | } | ||
148 | |||
149 | sub dump_symbolic_fields | ||
150 | { | ||
151 | for my $event (keys %symbolic_fields) { | ||
152 | print "event $event:\n"; | ||
153 | for my $field (keys %{$symbolic_fields{$event}}) { | ||
154 | print " field: $field:\n"; | ||
155 | foreach my $idx (sort {$a <=> $b} keys %{$symbolic_fields{$event}{$field}{"values"}}) { | ||
156 | print " value $idx: $symbolic_fields{$event}{$field}{'values'}{$idx}\n"; | ||
157 | } | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | |||
162 | 1; | ||
163 | __END__ | ||
164 | =head1 NAME | ||
165 | |||
166 | Perf::Trace::Core - Perl extension for perf trace | ||
167 | |||
168 | =head1 SYNOPSIS | ||
169 | |||
170 | use Perf::Trace::Core | ||
171 | |||
172 | =head1 SEE ALSO | ||
173 | |||
174 | Perf (trace) documentation | ||
175 | |||
176 | =head1 AUTHOR | ||
177 | |||
178 | Tom Zanussi, E<lt>tzanussi@gmail.com<gt> | ||
179 | |||
180 | =head1 COPYRIGHT AND LICENSE | ||
181 | |||
182 | Copyright (C) 2009 by Tom Zanussi | ||
183 | |||
184 | This library is free software; you can redistribute it and/or modify | ||
185 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||
186 | at your option, any later version of Perl 5 you may have available. | ||
187 | |||
188 | Alternatively, this software may be distributed under the terms of the | ||
189 | GNU General Public License ("GPL") version 2 as published by the Free | ||
190 | Software Foundation. | ||
191 | |||
192 | =cut | ||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm new file mode 100644 index 000000000000..052f132ced24 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm | |||
@@ -0,0 +1,88 @@ | |||
1 | package Perf::Trace::Util; | ||
2 | |||
3 | use 5.010000; | ||
4 | use strict; | ||
5 | use warnings; | ||
6 | |||
7 | require Exporter; | ||
8 | |||
9 | our @ISA = qw(Exporter); | ||
10 | |||
11 | our %EXPORT_TAGS = ( 'all' => [ qw( | ||
12 | ) ] ); | ||
13 | |||
14 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
15 | |||
16 | our @EXPORT = qw( | ||
17 | avg nsecs nsecs_secs nsecs_nsecs nsecs_usecs print_nsecs | ||
18 | ); | ||
19 | |||
20 | our $VERSION = '0.01'; | ||
21 | |||
22 | sub avg | ||
23 | { | ||
24 | my ($total, $n) = @_; | ||
25 | |||
26 | return $total / $n; | ||
27 | } | ||
28 | |||
29 | my $NSECS_PER_SEC = 1000000000; | ||
30 | |||
31 | sub nsecs | ||
32 | { | ||
33 | my ($secs, $nsecs) = @_; | ||
34 | |||
35 | return $secs * $NSECS_PER_SEC + $nsecs; | ||
36 | } | ||
37 | |||
38 | sub nsecs_secs { | ||
39 | my ($nsecs) = @_; | ||
40 | |||
41 | return $nsecs / $NSECS_PER_SEC; | ||
42 | } | ||
43 | |||
44 | sub nsecs_nsecs { | ||
45 | my ($nsecs) = @_; | ||
46 | |||
47 | return $nsecs - nsecs_secs($nsecs); | ||
48 | } | ||
49 | |||
50 | sub nsecs_str { | ||
51 | my ($nsecs) = @_; | ||
52 | |||
53 | my $str = sprintf("%5u.%09u", nsecs_secs($nsecs), nsecs_nsecs($nsecs)); | ||
54 | |||
55 | return $str; | ||
56 | } | ||
57 | |||
58 | 1; | ||
59 | __END__ | ||
60 | =head1 NAME | ||
61 | |||
62 | Perf::Trace::Util - Perl extension for perf trace | ||
63 | |||
64 | =head1 SYNOPSIS | ||
65 | |||
66 | use Perf::Trace::Util; | ||
67 | |||
68 | =head1 SEE ALSO | ||
69 | |||
70 | Perf (trace) documentation | ||
71 | |||
72 | =head1 AUTHOR | ||
73 | |||
74 | Tom Zanussi, E<lt>tzanussi@gmail.com<gt> | ||
75 | |||
76 | =head1 COPYRIGHT AND LICENSE | ||
77 | |||
78 | Copyright (C) 2009 by Tom Zanussi | ||
79 | |||
80 | This library is free software; you can redistribute it and/or modify | ||
81 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||
82 | at your option, any later version of Perl 5 you may have available. | ||
83 | |||
84 | Alternatively, this software may be distributed under the terms of the | ||
85 | GNU General Public License ("GPL") version 2 as published by the Free | ||
86 | Software Foundation. | ||
87 | |||
88 | =cut | ||
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/typemap b/tools/perf/scripts/perl/Perf-Trace-Util/typemap new file mode 100644 index 000000000000..840836804aa7 --- /dev/null +++ b/tools/perf/scripts/perl/Perf-Trace-Util/typemap | |||
@@ -0,0 +1 @@ | |||
struct scripting_context * T_PTR | |||