Implement bpf_get_current_comm_emitter

This commit is contained in:
Pragyansh Chaturvedi
2025-10-15 14:03:09 +05:30
parent a0d954b20b
commit 13a804f7ac
4 changed files with 100 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from pythonbpf import bpf, map, struct, section, bpfglobal, compile
from pythonbpf.helper import ktime, pid
from pythonbpf.helper import ktime, pid, comm
from pythonbpf.maps import PerfEventArray
from ctypes import c_void_p, c_int64, c_uint64
@ -25,7 +25,7 @@ def hello(ctx: c_void_p) -> c_int64:
dataobj = data_t()
strobj = "hellohellohello"
dataobj.pid, dataobj.ts = pid(), ktime()
# get_curr_comm(dataobj.comm)
comm(dataobj.comm)
print(f"clone called at {dataobj.ts} by pid {dataobj.pid}, comm {strobj}")
events.output(dataobj)
return 0 # type: ignore [return-value]