From 81f4a0a79963ffcf94498878bf3b86f4f44917f9 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Sat, 6 Sep 2025 02:40:42 +0530 Subject: [PATCH] Add shorter examples --- examples/c-form/ex2.bpf.c | 10 ++++++++++ examples/execve2.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 examples/c-form/ex2.bpf.c create mode 100644 examples/execve2.py diff --git a/examples/c-form/ex2.bpf.c b/examples/c-form/ex2.bpf.c new file mode 100644 index 0000000..80075dd --- /dev/null +++ b/examples/c-form/ex2.bpf.c @@ -0,0 +1,10 @@ +#include +#include + +SEC("kprobe/sys_clone") +int hello(struct pt_regs *ctx) { + bpf_printk("Hello, World!"); + return 0; +} + +char LICENSE[] SEC("license") = "GPL"; diff --git a/examples/execve2.py b/examples/execve2.py new file mode 100644 index 0000000..d04ea3c --- /dev/null +++ b/examples/execve2.py @@ -0,0 +1,14 @@ +from pythonbpf.decorators import section +# from pythonbpf.decorators import tracepoint, syscalls +from ctypes import c_void_p, c_int32 + +# @tracepoint(syscalls.sys_enter_execve) + + +@section("kprobe/sys_clone") +def hello(ctx: c_void_p) -> c_int32: + print("Hello, World!") + return c_int32(0) + + +LICENSE = "GPL"