Path: blob/master/tools/perf/scripts/perl/check-perf-trace.pl
10823 views
# perf script event handlers, generated by perf script -g perl1# (c) 2009, Tom Zanussi <[email protected]>2# Licensed under the terms of the GNU GPL License version 234# This script tests basic functionality such as flag and symbol5# strings, common_xxx() calls back into perf, begin, end, unhandled6# events, etc. Basically, if this script runs successfully and7# displays expected results, perl scripting support should be ok.89use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";10use lib "./Perf-Trace-Util/lib";11use Perf::Trace::Core;12use Perf::Trace::Context;13use Perf::Trace::Util;1415sub trace_begin16{17print "trace_begin\n";18}1920sub trace_end21{22print "trace_end\n";2324print_unhandled();25}2627sub irq::softirq_entry28{29my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,30$common_pid, $common_comm,31$vec) = @_;3233print_header($event_name, $common_cpu, $common_secs, $common_nsecs,34$common_pid, $common_comm);3536print_uncommon($context);3738printf("vec=%s\n",39symbol_str("irq::softirq_entry", "vec", $vec));40}4142sub kmem::kmalloc43{44my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,45$common_pid, $common_comm,46$call_site, $ptr, $bytes_req, $bytes_alloc,47$gfp_flags) = @_;4849print_header($event_name, $common_cpu, $common_secs, $common_nsecs,50$common_pid, $common_comm);5152print_uncommon($context);5354printf("call_site=%p, ptr=%p, bytes_req=%u, bytes_alloc=%u, ".55"gfp_flags=%s\n",56$call_site, $ptr, $bytes_req, $bytes_alloc,5758flag_str("kmem::kmalloc", "gfp_flags", $gfp_flags));59}6061# print trace fields not included in handler args62sub print_uncommon63{64my ($context) = @_;6566printf("common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, ",67common_pc($context), trace_flag_str(common_flags($context)),68common_lock_depth($context));6970}7172my %unhandled;7374sub print_unhandled75{76if ((scalar keys %unhandled) == 0) {77return;78}7980print "\nunhandled events:\n\n";8182printf("%-40s %10s\n", "event", "count");83printf("%-40s %10s\n", "----------------------------------------",84"-----------");8586foreach my $event_name (keys %unhandled) {87printf("%-40s %10d\n", $event_name, $unhandled{$event_name});88}89}9091sub trace_unhandled92{93my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,94$common_pid, $common_comm) = @_;9596$unhandled{$event_name}++;97}9899sub print_header100{101my ($event_name, $cpu, $secs, $nsecs, $pid, $comm) = @_;102103printf("%-20s %5u %05u.%09u %8u %-20s ",104$event_name, $cpu, $secs, $nsecs, $pid, $comm);105}106107108