<s> from bcc import BPF <EOL> import time <EOL> from unittest import main , TestCase <EOL> class TestCallchain ( TestCase ) : <EOL> def test_callchain1 ( self ) : <EOL> hist = { } <EOL> def cb ( pid , callchain ) : <EOL> counter = hist . get ( callchain , <NUM_LIT:0> ) <EOL> counter += <NUM_LIT:1> <EOL> hist [ callchain ] = counter <EOL> b = BPF ( text = """<STR_LIT>""" , cb = cb ) <EOL> start = time . time ( ) <EOL> while time . time ( ) < start + <NUM_LIT:1> : <EOL> b . kprobe_poll ( ) <EOL> for k , v in hist . items ( ) : <EOL> syms = [ b . ksym ( addr ) for addr in k ] <EOL> print ( "<STR_LIT>" % v , syms ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
