mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add shorter examples
This commit is contained in:
10
examples/c-form/ex2.bpf.c
Normal file
10
examples/c-form/ex2.bpf.c
Normal 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
14
examples/execve2.py
Normal 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"
|
||||||
Reference in New Issue
Block a user