<s> from __future__ import print_function <EOL> from bcc import BPF <EOL> import argparse <EOL> from time import strftime <EOL> import ctypes as ct <EOL> examples = """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( <EOL> description = "<STR_LIT>" , <EOL> formatter_class = argparse . RawDescriptionHelpFormatter , <EOL> epilog = examples ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> args = parser . parse_args ( ) <EOL> debug = <NUM_LIT:0> <EOL> bpf_text = """<STR_LIT>""" <EOL> TASK_COMM_LEN = <NUM_LIT:16> <EOL> DNAME_INLINE_LEN = <NUM_LIT:255> <EOL> class Data ( ct . Structure ) : <EOL> _fields_ = [ <EOL> ( "<STR_LIT>" , ct . c_ulonglong ) , <EOL> ( "<STR_LIT>" , ct . c_ulonglong ) , <EOL> ( "<STR_LIT>" , ct . c_char * TASK_COMM_LEN ) , <EOL> ( "<STR_LIT>" , ct . c_char * DNAME_INLINE_LEN ) <EOL> ] <EOL> if args . pid : <EOL> bpf_text = bpf_text . replace ( '<STR_LIT>' , <EOL> '<STR_LIT>' % args . pid ) <EOL> else : <EOL> bpf_text = bpf_text . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if debug : <EOL> print ( bpf_text ) <EOL> b = BPF ( text = bpf_text ) <EOL> b . attach_kprobe ( event = "<STR_LIT>" , fn_name = "<STR_LIT>" ) <EOL> b . attach_kprobe ( event = "<STR_LIT>" , fn_name = "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" % ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def print_event ( cpu , data , size ) : <EOL> event = ct . cast ( data , ct . POINTER ( Data ) ) . contents <EOL> print ( "<STR_LIT>" % ( strftime ( "<STR_LIT>" ) , event . pid , <EOL> event . comm , float ( event . delta ) / <NUM_LIT:1000> , event . fname ) ) <EOL> b [ "<STR_LIT>" ] . open_perf_buffer ( print_event ) <EOL> while <NUM_LIT:1> : <EOL> b . kprobe_poll ( ) </s>
