mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add is_map in maps_pass
This commit is contained in:
committed by
Pragyansh Chaturvedi
parent
0fb1cafd20
commit
0d691865bc
@ -8,19 +8,20 @@ map_sym_tab = {}
|
|||||||
|
|
||||||
def maps_proc(tree, module, chunks):
|
def maps_proc(tree, module, chunks):
|
||||||
for func_node in chunks:
|
for func_node in chunks:
|
||||||
# Check if this function is a map
|
if is_map(func_node):
|
||||||
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:
|
|
||||||
print(f"Found BPF map: {func_node.name}")
|
print(f"Found BPF map: {func_node.name}")
|
||||||
process_bpf_map(func_node, module)
|
process_bpf_map(func_node, module)
|
||||||
continue
|
continue
|
||||||
return map_sym_tab
|
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 = {
|
BPF_MAP_MAPPINGS = {
|
||||||
"HASH": 1, # BPF_MAP_TYPE_HASH
|
"HASH": 1, # BPF_MAP_TYPE_HASH
|
||||||
"PERF_EVENT_ARRAY": 4, # BPF_MAP_TYPE_PERF_EVENT_ARRAY
|
"PERF_EVENT_ARRAY": 4, # BPF_MAP_TYPE_PERF_EVENT_ARRAY
|
||||||
|
|||||||
Reference in New Issue
Block a user