Skip to content

Commit 780f53c

Browse files
committed
Make bpf structs discoverable during chunk exploration
1 parent 48c0a1f commit 780f53c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pythonbpf/codegen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def find_bpf_chunks(tree):
1414
"""Find all functions decorated with @bpf in the AST."""
1515
bpf_functions = []
1616
for node in ast.walk(tree):
17-
if isinstance(node, ast.FunctionDef):
17+
if isinstance(node, ast.FunctionDef) or isinstance(node, ast.ClassDef):
1818
for decorator in node.decorator_list:
1919
if isinstance(decorator, ast.Name) and decorator.id == "bpf":
2020
bpf_functions.append(node)
@@ -28,7 +28,7 @@ def processor(source_code, filename, module):
2828

2929
bpf_chunks = find_bpf_chunks(tree)
3030
for func_node in bpf_chunks:
31-
print(f"Found BPF function: {func_node.name}")
31+
print(f"Found BPF function/struct: {func_node.name}")
3232

3333
map_sym_tab = maps_proc(tree, module, bpf_chunks)
3434
func_proc(tree, module, bpf_chunks, map_sym_tab)

0 commit comments

Comments
 (0)