<s> import atexit <EOL> from bcc import BPF <EOL> import ctypes as ct <EOL> class Data ( ct . Structure ) : <EOL> _fields_ = [ ( "<STR_LIT>" , ct . c_ulonglong ) , <EOL> ( "<STR_LIT>" , ct . c_ulonglong ) ] <EOL> counter = <NUM_LIT:0> <EOL> def cb ( cpu , data , size ) : <EOL> assert size >= ct . sizeof ( Data ) <EOL> event = ct . cast ( data , ct . POINTER ( Data ) ) . contents <EOL> print ( "<STR_LIT>" % ( cpu , float ( event . ts ) / <NUM_LIT> , event . magic ) ) <EOL> global counter <EOL> counter += <NUM_LIT:1> <EOL> prog = """<STR_LIT>""" <EOL> b = BPF ( text = prog ) <EOL> b [ "<STR_LIT>" ] . open_perf_buffer ( cb ) <EOL> @ atexit . register <EOL> def print_counter ( ) : <EOL> global counter <EOL> global b <EOL> print ( "<STR_LIT>" % ( counter , b [ "<STR_LIT>" ] [ ct . c_int ( <NUM_LIT:0> ) ] . value ) ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> while <NUM_LIT:1> : <EOL> b . kprobe_poll ( ) </s>
