]> git.karo-electronics.de Git - karo-tx-linux.git/commit
perf script: Add generic perl handler to process events
authorRobert Richter <robert.richter@amd.com>
Tue, 13 Dec 2011 15:05:54 +0000 (16:05 +0100)
committerRobert Richter <robert.richter@amd.com>
Thu, 15 Dec 2011 14:17:44 +0000 (15:17 +0100)
commit58ef5bce3e50ed004fa54089037daa5cb2ec026c
tree620c764f5452e9b810796d7ff01361603b3df6b4
parentc415f577eb32d80802311ebe9d51f06926c170c1
perf script: Add generic perl handler to process events

The current perf scripting facility only supports tracepoints. This
patch implements a generic perl handler to support other events than
tracepoints too.

This patch introduces a function process_event() that is called by
perf for each sample. The function is called with byte streams as
arguments containing information about the event, its attributes, the
sample and raw data. Perl's unpack() function can easily be used for
byte decoding. The following is the default implementation for
process_event() that can also be generated with perf script:

 # Packed byte string args of process_event():
 #
 # $event:       union perf_event        util/event.h
 # $attr:        struct perf_event_attr  linux/perf_event.h
 # $sample:      struct perf_sample      util/event.h
 # $raw_data:    perf_sample->raw_data   util/event.h

 sub process_event
 {
         my ($event, $attr, $sample, $raw_data) = @_;

         my @event       = unpack("LSS", $event);
         my @attr        = unpack("LLQQQQQLLQQ", $attr);
         my @sample      = unpack("QLLQQQQQLL", $sample);
         my @raw_data    = unpack("C*", $raw_data);

         use Data::Dumper;
         print Dumper \@event, \@attr, \@sample, \@raw_data;
 }

Signed-off-by: Robert Richter <robert.richter@amd.com>
tools/perf/util/scripting-engines/trace-event-perl.c