33from pythonbpf import bpf , map , section , bpfglobal , BPF
44from pythonbpf .helper import pid
55from pythonbpf .maps import HashMap
6- from pylibbpf import BpfMap
76from ctypes import c_void_p , c_int64 , c_uint64 , c_int32
87import matplotlib .pyplot as plt
98
@@ -26,14 +25,14 @@ def hist() -> HashMap:
2625def hello (ctx : c_void_p ) -> c_int64 :
2726 process_id = pid ()
2827 one = 1
29- prev = hist () .lookup (process_id )
28+ prev = hist .lookup (process_id )
3029 if prev :
3130 previous_value = prev + 1
3231 print (f"count: { previous_value } with { process_id } " )
33- hist () .update (process_id , previous_value )
32+ hist .update (process_id , previous_value )
3433 return c_int64 (0 )
3534 else :
36- hist () .update (process_id , one )
35+ hist .update (process_id , one )
3736 return c_int64 (0 )
3837
3938
@@ -44,12 +43,12 @@ def LICENSE() -> str:
4443
4544
4645b = BPF ()
47- b .load_and_attach ()
48- hist = BpfMap ( b , hist )
46+ b .load ()
47+ b . attach_all ( )
4948print ("Recording" )
5049time .sleep (10 )
5150
52- counts = list (hist .values ())
51+ counts = list (b [ " hist" ] .values ())
5352
5453plt .hist (counts , bins = 20 )
5554plt .xlabel ("Clone calls per PID" )
0 commit comments