Skip to content

Commit 69d8669

Browse files
Merge pull request #28 from pythonbpf/vmlinux-working
Add compilation mechanism from vmlinux Still does not compile to IR. only does semantic analysis. Another PR will be opened soon for IR generation.
2 parents b2a57ed + d4f5a9c commit 69d8669

23 files changed

+847
-248520
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ __pycache__/
77
*.ll
88
*.o
99
.ipynb_checkpoints/
10+
vmlinux.py
11+
~*
12+
vmlinux.h

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313
# See https://github.com/pre-commit/pre-commit
1414

15-
exclude: 'vmlinux.*\.py$'
15+
exclude: 'vmlinux.py'
1616

1717
ci:
1818
autoupdate_commit_msg: "chore: update pre-commit hooks"
@@ -41,7 +41,7 @@ repos:
4141
- id: ruff
4242
args: ["--fix", "--show-fixes"]
4343
- id: ruff-format
44-
exclude: ^(docs)|^(tests)|^(examples)
44+
# exclude: ^(docs)|^(tests)|^(examples)
4545

4646
# Checking static types
4747
- repo: https://github.com/pre-commit/mirrors-mypy

examples/clone-matplotlib.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@
308308
"def hist() -> HashMap:\n",
309309
" return HashMap(key=c_int32, value=c_uint64, max_entries=4096)\n",
310310
"\n",
311+
"\n",
311312
"@bpf\n",
312313
"@section(\"tracepoint/syscalls/sys_enter_clone\")\n",
313314
"def hello(ctx: c_void_p) -> c_int64:\n",
@@ -329,6 +330,7 @@
329330
"def LICENSE() -> str:\n",
330331
" return \"GPL\"\n",
331332
"\n",
333+
"\n",
332334
"b = BPF()"
333335
]
334336
},
@@ -357,7 +359,6 @@
357359
}
358360
],
359361
"source": [
360-
"\n",
361362
"b.load_and_attach()\n",
362363
"hist = BpfMap(b, hist)\n",
363364
"print(\"Recording\")\n",

examples/kprobes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ def hello_world(ctx: c_void_p) -> c_int64:
88
print("Hello, World!")
99
return c_int64(0)
1010

11+
1112
@bpf
1213
@section("kprobe/do_unlinkat")
1314
def hello_world2(ctx: c_void_p) -> c_int64:
1415
print("Hello, World!")
1516
return c_int64(0)
1617

18+
1719
@bpf
1820
@bpfglobal
1921
def LICENSE() -> str:

examples/struct_and_perf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def hello(ctx: c_void_p) -> c_int32:
2727
dataobj.pid = pid()
2828
dataobj.ts = ktime()
2929
# dataobj.comm = strobj
30-
print(f"clone called at {dataobj.ts} by pid" f"{dataobj.pid}, comm {strobj}")
30+
print(f"clone called at {dataobj.ts} by pid{dataobj.pid}, comm {strobj}")
3131
events.output(dataobj)
3232
return c_int32(0)
3333

0 commit comments

Comments
 (0)