mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
30 lines
657 B
Python
30 lines
657 B
Python
from pythonbpf.decorators import bpf, bpfglobal, section
|
|
from ctypes import c_void_p, c_int64, c_int32, c_uint64
|
|
from pythonbpf.helpers import bpf_ktime_get_ns
|
|
from pythonbpf.maps import HashMap
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def last():
|
|
return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=1)
|
|
|
|
|
|
@bpf
|
|
@section("tracepoint/syscalls/sys_enter_execve")
|
|
def hello(ctx: c_void_p) -> c_int32:
|
|
print("entered")
|
|
print("multi constant support")
|
|
return c_int32(0)
|
|
|
|
|
|
@bpf
|
|
@section("tracepoint/syscalls/sys_exit_execve")
|
|
def hello_again(ctx: c_void_p) -> c_int64:
|
|
print("exited")
|
|
ts = bpf_ktime_get_ns()
|
|
return c_int64(0)
|
|
|
|
|
|
LICENSE = "GPL"
|