Add shorter examples

This commit is contained in:
Pragyansh Chaturvedi
2025-09-06 02:40:42 +05:30
parent c9e4910a89
commit 81f4a0a799
2 changed files with 24 additions and 0 deletions

10
examples/c-form/ex2.bpf.c Normal file
View File

@ -0,0 +1,10 @@
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
SEC("kprobe/sys_clone")
int hello(struct pt_regs *ctx) {
bpf_printk("Hello, World!");
return 0;
}
char LICENSE[] SEC("license") = "GPL";

14
examples/execve2.py Normal file
View File

@ -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"