Add basic map generation

This commit is contained in:
Pragyansh Chaturvedi
2025-09-08 04:21:09 +05:30
parent 70dfa0ff58
commit 1bbf004554
3 changed files with 125 additions and 7 deletions

View File

@ -1,7 +1,14 @@
from pythonbpf.decorators import bpf, section
from pythonbpf.decorators import bpf, bpfglobal, section
from ctypes import c_void_p, c_int64, c_int32
from pythonbpf.helpers import bpf_ktime_get_ns
@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:
@ -9,6 +16,7 @@ def hello(ctx: c_void_p) -> c_int32:
print("multi constant support")
return c_int32(0)
@bpf
@section("tracepoint/syscalls/sys_exit_execve")
def hello_again(ctx: c_void_p) -> c_int64:
@ -16,4 +24,5 @@ def hello_again(ctx: c_void_p) -> c_int64:
ts = bpf_ktime_get_ns()
return c_int64(0)
LICENSE = "GPL"