mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
74 lines
1.5 KiB
Plaintext
74 lines
1.5 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "bb49598f-b9cc-4ea8-8391-923cad513711",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from pythonbpf import bpf, section, bpfglobal, BPF, trace_pipe\n",
|
|
"from ctypes import c_void_p, c_int64"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5da237b0-1c7d-4ec5-8c24-696b1c1d97fa",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"@bpf\n",
|
|
"@section(\"tracepoint/syscalls/sys_enter_sync\")\n",
|
|
"def hello_world(ctx: c_void_p) -> c_int64:\n",
|
|
" print(\"sys_sync() called\")\n",
|
|
" return 0\n",
|
|
"\n",
|
|
"\n",
|
|
"@bpf\n",
|
|
"@bpfglobal\n",
|
|
"def LICENSE() -> str:\n",
|
|
" return \"GPL\"\n",
|
|
"\n",
|
|
"\n",
|
|
"# Compile and load\n",
|
|
"b = BPF()\n",
|
|
"b.load()\n",
|
|
"b.attach_all()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e4c218ac-fe47-4fd1-a27b-c07e02f3cd05",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(\"Tracing sys_sync()... Ctrl-C to end.\")\n",
|
|
"trace_pipe()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.13.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|