Add is_map in maps_pass

This commit is contained in:
Pragyansh Chaturvedi
2025-09-30 11:42:14 +05:30
committed by Pragyansh Chaturvedi
parent 0fb1cafd20
commit 0d691865bc

View File

@ -8,19 +8,20 @@ map_sym_tab = {}
def maps_proc(tree, module, chunks):
for func_node in chunks:
# Check if this function is a map
is_map = False
for decorator in func_node.decorator_list:
if isinstance(decorator, ast.Name) and decorator.id == "map":
is_map = True
break
if is_map:
if is_map(func_node):
print(f"Found BPF map: {func_node.name}")
process_bpf_map(func_node, module)
continue
return map_sym_tab
def is_map(func_node):
return any(
isinstance(decorator, ast.Name) and decorator.id == "map"
for decorator in func_node.decorator_list
)
BPF_MAP_MAPPINGS = {
"HASH": 1, # BPF_MAP_TYPE_HASH
"PERF_EVENT_ARRAY": 4, # BPF_MAP_TYPE_PERF_EVENT_ARRAY