diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:02:01 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-03-19 20:02:01 -0400 |
commit | 10ce3cc919f50c2043b41ca968b43c26a3672600 (patch) | |
tree | ea409366a5208aced495bc0516a08b81fd43222e /tools/perf/util/scripting-engines | |
parent | 24e3e5ae1e4c2a3a32f5b1f96b4e3fd721806acd (diff) | |
parent | 5c6a7a62c130afef3d61c1dee153012231ff5cd9 (diff) |
Merge branch 'next' into for-linus
Diffstat (limited to 'tools/perf/util/scripting-engines')
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c | 75 | ||||
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-python.c | 4 |
2 files changed, 72 insertions, 7 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 74350ffb57fe..e30749e38a9b 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
@@ -27,7 +27,10 @@ | |||
27 | 27 | ||
28 | #include "../../perf.h" | 28 | #include "../../perf.h" |
29 | #include "../util.h" | 29 | #include "../util.h" |
30 | #include "../thread.h" | ||
31 | #include "../event.h" | ||
30 | #include "../trace-event.h" | 32 | #include "../trace-event.h" |
33 | #include "../evsel.h" | ||
31 | 34 | ||
32 | #include <EXTERN.h> | 35 | #include <EXTERN.h> |
33 | #include <perl.h> | 36 | #include <perl.h> |
@@ -245,11 +248,11 @@ static inline struct event *find_cache_event(int type) | |||
245 | return event; | 248 | return event; |
246 | } | 249 | } |
247 | 250 | ||
248 | static void perl_process_event(union perf_event *pevent __unused, | 251 | static void perl_process_tracepoint(union perf_event *pevent __unused, |
249 | struct perf_sample *sample, | 252 | struct perf_sample *sample, |
250 | struct perf_evsel *evsel, | 253 | struct perf_evsel *evsel, |
251 | struct perf_session *session __unused, | 254 | struct machine *machine __unused, |
252 | struct thread *thread) | 255 | struct thread *thread) |
253 | { | 256 | { |
254 | struct format_field *field; | 257 | struct format_field *field; |
255 | static char handler[256]; | 258 | static char handler[256]; |
@@ -265,6 +268,9 @@ static void perl_process_event(union perf_event *pevent __unused, | |||
265 | 268 | ||
266 | dSP; | 269 | dSP; |
267 | 270 | ||
271 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | ||
272 | return; | ||
273 | |||
268 | type = trace_parse_common_type(data); | 274 | type = trace_parse_common_type(data); |
269 | 275 | ||
270 | event = find_cache_event(type); | 276 | event = find_cache_event(type); |
@@ -332,6 +338,42 @@ static void perl_process_event(union perf_event *pevent __unused, | |||
332 | LEAVE; | 338 | LEAVE; |
333 | } | 339 | } |
334 | 340 | ||
341 | static void perl_process_event_generic(union perf_event *pevent __unused, | ||
342 | struct perf_sample *sample, | ||
343 | struct perf_evsel *evsel __unused, | ||
344 | struct machine *machine __unused, | ||
345 | struct thread *thread __unused) | ||
346 | { | ||
347 | dSP; | ||
348 | |||
349 | if (!get_cv("process_event", 0)) | ||
350 | return; | ||
351 | |||
352 | ENTER; | ||
353 | SAVETMPS; | ||
354 | PUSHMARK(SP); | ||
355 | XPUSHs(sv_2mortal(newSVpvn((const char *)pevent, pevent->header.size))); | ||
356 | XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->attr, sizeof(evsel->attr)))); | ||
357 | XPUSHs(sv_2mortal(newSVpvn((const char *)sample, sizeof(*sample)))); | ||
358 | XPUSHs(sv_2mortal(newSVpvn((const char *)sample->raw_data, sample->raw_size))); | ||
359 | PUTBACK; | ||
360 | call_pv("process_event", G_SCALAR); | ||
361 | SPAGAIN; | ||
362 | PUTBACK; | ||
363 | FREETMPS; | ||
364 | LEAVE; | ||
365 | } | ||
366 | |||
367 | static void perl_process_event(union perf_event *pevent, | ||
368 | struct perf_sample *sample, | ||
369 | struct perf_evsel *evsel, | ||
370 | struct machine *machine, | ||
371 | struct thread *thread) | ||
372 | { | ||
373 | perl_process_tracepoint(pevent, sample, evsel, machine, thread); | ||
374 | perl_process_event_generic(pevent, sample, evsel, machine, thread); | ||
375 | } | ||
376 | |||
335 | static void run_start_sub(void) | 377 | static void run_start_sub(void) |
336 | { | 378 | { |
337 | dSP; /* access to Perl stack */ | 379 | dSP; /* access to Perl stack */ |
@@ -553,7 +595,28 @@ static int perl_generate_script(const char *outfile) | |||
553 | fprintf(ofp, "sub print_header\n{\n" | 595 | fprintf(ofp, "sub print_header\n{\n" |
554 | "\tmy ($event_name, $cpu, $secs, $nsecs, $pid, $comm) = @_;\n\n" | 596 | "\tmy ($event_name, $cpu, $secs, $nsecs, $pid, $comm) = @_;\n\n" |
555 | "\tprintf(\"%%-20s %%5u %%05u.%%09u %%8u %%-20s \",\n\t " | 597 | "\tprintf(\"%%-20s %%5u %%05u.%%09u %%8u %%-20s \",\n\t " |
556 | "$event_name, $cpu, $secs, $nsecs, $pid, $comm);\n}"); | 598 | "$event_name, $cpu, $secs, $nsecs, $pid, $comm);\n}\n"); |
599 | |||
600 | fprintf(ofp, | ||
601 | "\n# Packed byte string args of process_event():\n" | ||
602 | "#\n" | ||
603 | "# $event:\tunion perf_event\tutil/event.h\n" | ||
604 | "# $attr:\tstruct perf_event_attr\tlinux/perf_event.h\n" | ||
605 | "# $sample:\tstruct perf_sample\tutil/event.h\n" | ||
606 | "# $raw_data:\tperf_sample->raw_data\tutil/event.h\n" | ||
607 | "\n" | ||
608 | "sub process_event\n" | ||
609 | "{\n" | ||
610 | "\tmy ($event, $attr, $sample, $raw_data) = @_;\n" | ||
611 | "\n" | ||
612 | "\tmy @event\t= unpack(\"LSS\", $event);\n" | ||
613 | "\tmy @attr\t= unpack(\"LLQQQQQLLQQ\", $attr);\n" | ||
614 | "\tmy @sample\t= unpack(\"QLLQQQQQLL\", $sample);\n" | ||
615 | "\tmy @raw_data\t= unpack(\"C*\", $raw_data);\n" | ||
616 | "\n" | ||
617 | "\tuse Data::Dumper;\n" | ||
618 | "\tprint Dumper \\@event, \\@attr, \\@sample, \\@raw_data;\n" | ||
619 | "}\n"); | ||
557 | 620 | ||
558 | fclose(ofp); | 621 | fclose(ofp); |
559 | 622 | ||
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c index 6ccf70e8d8f2..0b2a48783172 100644 --- a/tools/perf/util/scripting-engines/trace-event-python.c +++ b/tools/perf/util/scripting-engines/trace-event-python.c | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #include "../../perf.h" | 30 | #include "../../perf.h" |
31 | #include "../util.h" | 31 | #include "../util.h" |
32 | #include "../event.h" | ||
33 | #include "../thread.h" | ||
32 | #include "../trace-event.h" | 34 | #include "../trace-event.h" |
33 | 35 | ||
34 | PyMODINIT_FUNC initperf_trace_context(void); | 36 | PyMODINIT_FUNC initperf_trace_context(void); |
@@ -207,7 +209,7 @@ static inline struct event *find_cache_event(int type) | |||
207 | static void python_process_event(union perf_event *pevent __unused, | 209 | static void python_process_event(union perf_event *pevent __unused, |
208 | struct perf_sample *sample, | 210 | struct perf_sample *sample, |
209 | struct perf_evsel *evsel __unused, | 211 | struct perf_evsel *evsel __unused, |
210 | struct perf_session *session __unused, | 212 | struct machine *machine __unused, |
211 | struct thread *thread) | 213 | struct thread *thread) |
212 | { | 214 | { |
213 | PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; | 215 | PyObject *handler, *retval, *context, *t, *obj, *dict = NULL; |