mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-03-24 14:11:29 +00:00
Compare commits
5 Commits
refactor_a
...
31645f0316
| Author | SHA1 | Date | |
|---|---|---|---|
| 31645f0316 | |||
| 21ce041353 | |||
| 6402cf7be5 | |||
| 9a96e1247b | |||
| 989134f4be |
@ -83,14 +83,14 @@ def hist() -> HashMap:
|
||||
def hello(ctx: c_void_p) -> c_int64:
|
||||
process_id = pid()
|
||||
one = 1
|
||||
prev = hist().lookup(process_id)
|
||||
prev = hist.lookup(process_id)
|
||||
if prev:
|
||||
previous_value = prev + 1
|
||||
print(f"count: {previous_value} with {process_id}")
|
||||
hist().update(process_id, previous_value)
|
||||
hist.update(process_id, previous_value)
|
||||
return c_int64(0)
|
||||
else:
|
||||
hist().update(process_id, one)
|
||||
hist.update(process_id, one)
|
||||
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
|
||||
)
|
||||
|
||||
# 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