Path: blob/master/tools/perf/scripts/python/check-perf-trace.py
10823 views
# perf script event handlers, generated by perf script -g python1# (c) 2010, Tom Zanussi <[email protected]>2# Licensed under the terms of the GNU GPL License version 23#4# 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, Python scripting support should be ok.89import os10import sys1112sys.path.append(os.environ['PERF_EXEC_PATH'] + \13'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')1415from Core import *16from perf_trace_context import *1718unhandled = autodict()1920def trace_begin():21print "trace_begin"22pass2324def trace_end():25print_unhandled()2627def irq__softirq_entry(event_name, context, common_cpu,28common_secs, common_nsecs, common_pid, common_comm,29vec):30print_header(event_name, common_cpu, common_secs, common_nsecs,31common_pid, common_comm)3233print_uncommon(context)3435print "vec=%s\n" % \36(symbol_str("irq__softirq_entry", "vec", vec)),3738def kmem__kmalloc(event_name, context, common_cpu,39common_secs, common_nsecs, common_pid, common_comm,40call_site, ptr, bytes_req, bytes_alloc,41gfp_flags):42print_header(event_name, common_cpu, common_secs, common_nsecs,43common_pid, common_comm)4445print_uncommon(context)4647print "call_site=%u, ptr=%u, bytes_req=%u, " \48"bytes_alloc=%u, gfp_flags=%s\n" % \49(call_site, ptr, bytes_req, bytes_alloc,5051flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)),5253def trace_unhandled(event_name, context, event_fields_dict):54try:55unhandled[event_name] += 156except TypeError:57unhandled[event_name] = 15859def print_header(event_name, cpu, secs, nsecs, pid, comm):60print "%-20s %5u %05u.%09u %8u %-20s " % \61(event_name, cpu, secs, nsecs, pid, comm),6263# print trace fields not included in handler args64def print_uncommon(context):65print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \66% (common_pc(context), trace_flag_str(common_flags(context)), \67common_lock_depth(context))6869def print_unhandled():70keys = unhandled.keys()71if not keys:72return7374print "\nunhandled events:\n\n",7576print "%-40s %10s\n" % ("event", "count"),77print "%-40s %10s\n" % ("----------------------------------------", \78"-----------"),7980for event_name in keys:81print "%-40s %10d\n" % (event_name, unhandled[event_name])828384