mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Compare commits
5 Commits
32dc8e6636
...
6402cf7be5
| Author | SHA1 | Date | |
|---|---|---|---|
| 6402cf7be5 | |||
| 9a96e1247b | |||
| 989134f4be | |||
| 120aec08da | |||
| e66ae7cc89 |
13
TODO.md
13
TODO.md
@ -1,13 +0,0 @@
|
||||
## Short term
|
||||
|
||||
- Implement enough functionality to port the BCC tutorial examples in PythonBPF
|
||||
- Add all maps
|
||||
- XDP support in pylibbpf
|
||||
- ringbuf support
|
||||
- recursive expression resolution
|
||||
|
||||
## Long term
|
||||
|
||||
- Refactor the codebase to be better than a hackathon project
|
||||
- Port to C++ and use actual LLVM?
|
||||
- Fix struct_kioctx issue in the vmlinux transpiler
|
||||
18
tests/failing_tests/conditionals/oneline.py
Normal file
18
tests/failing_tests/conditionals/oneline.py
Normal file
@ -0,0 +1,18 @@
|
||||
from pythonbpf import bpf, section, bpfglobal, compile
|
||||
from ctypes import c_void_p, c_int64
|
||||
|
||||
|
||||
@bpf
|
||||
@section("tracepoint/syscalls/sys_enter_execve")
|
||||
def hello_world(ctx: c_void_p) -> c_int64:
|
||||
print("Hello, World!") if True else print("Goodbye, World!")
|
||||
return
|
||||
|
||||
|
||||
@bpf
|
||||
@bpfglobal
|
||||
def LICENSE() -> str:
|
||||
return "GPL"
|
||||
|
||||
|
||||
compile()
|
||||
@ -243,6 +243,17 @@ class BTFConverter:
|
||||
data
|
||||
)
|
||||
|
||||
# below to replace those c_bool with bitfield greater than 8
|
||||
def repl(m):
|
||||
name, bits = m.groups()
|
||||
return f"('{name}', ctypes.c_uint32, {bits})" if int(bits) > 8 else m.group(0)
|
||||
|
||||
data = re.sub(
|
||||
r"\('([^']+)',\s*ctypes\.c_bool,\s*(\d+)\)",
|
||||
repl,
|
||||
data
|
||||
)
|
||||
|
||||
# Remove ctypes. prefix from invalid entries
|
||||
invalid_ctypes = ["bpf_iter_state", "_cache_type", "fs_context_purpose"]
|
||||
for name in invalid_ctypes:
|
||||
|
||||
Reference in New Issue
Block a user