mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-03-25 14:41:29 +00:00
Compare commits
4 Commits
refactor_a
...
21ce041353
| Author | SHA1 | Date | |
|---|---|---|---|
| 21ce041353 | |||
| 6402cf7be5 | |||
| 9a96e1247b | |||
| 989134f4be |
@ -83,14 +83,14 @@ def hist() -> HashMap:
|
|||||||
def hello(ctx: c_void_p) -> c_int64:
|
def hello(ctx: c_void_p) -> c_int64:
|
||||||
process_id = pid()
|
process_id = pid()
|
||||||
one = 1
|
one = 1
|
||||||
prev = hist().lookup(process_id)
|
prev = hist.lookup(process_id)
|
||||||
if prev:
|
if prev:
|
||||||
previous_value = prev + 1
|
previous_value = prev + 1
|
||||||
print(f"count: {previous_value} with {process_id}")
|
print(f"count: {previous_value} with {process_id}")
|
||||||
hist().update(process_id, previous_value)
|
hist.update(process_id, previous_value)
|
||||||
return c_int64(0)
|
return c_int64(0)
|
||||||
else:
|
else:
|
||||||
hist().update(process_id, one)
|
hist.update(process_id, one)
|
||||||
return c_int64(0)
|
return c_int64(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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
|
|
||||||
- Add oneline IfExpr conditionals (wishlist)
|
|
||||||
|
|
||||||
## 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
|
|
||||||
@ -243,6 +243,17 @@ class BTFConverter:
|
|||||||
data
|
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
|
# Remove ctypes. prefix from invalid entries
|
||||||
invalid_ctypes = ["bpf_iter_state", "_cache_type", "fs_context_purpose"]
|
invalid_ctypes = ["bpf_iter_state", "_cache_type", "fs_context_purpose"]
|
||||||
for name in invalid_ctypes:
|
for name in invalid_ctypes:
|
||||||
|
|||||||
Reference in New Issue
Block a user