restructure maps dir, fix imports

This commit is contained in:
Pragyansh Chaturvedi
2025-09-30 19:01:46 +05:30
parent 9ae1b6ce15
commit cbc6b93cd8
6 changed files with 55 additions and 14 deletions

View File

@ -2,7 +2,7 @@ import ast
from llvmlite import ir
from .license_pass import license_processing
from .functions_pass import func_proc
from .maps_pass import maps_proc
from pythonbpf.maps.maps_pass import maps_proc
from .structs.structs_pass import structs_proc
from .globals_pass import globals_processing
import os
@ -125,8 +125,8 @@ def BPF() -> BpfProgram:
caller_frame = inspect.stack()[1]
src = inspect.getsource(caller_frame.frame)
with tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".py") as f, \
tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".ll") as inter, \
tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".o") as obj_file:
tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".ll") as inter, \
tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".o") as obj_file:
f.write(src)
f.flush()
source = f.name

View File

@ -1,7 +1,7 @@
import ast
from llvmlite import ir
from .type_deducer import ctypes_to_ir
from . import dwarf_constants as dc
from pythonbpf.type_deducer import ctypes_to_ir
from pythonbpf import dwarf_constants as dc
from enum import Enum
map_sym_tab = {}
@ -28,12 +28,6 @@ class BPFMapType(Enum):
PERF_EVENT_ARRAY = 4
BPF_MAP_MAPPINGS = {
"HASH": 1, # BPF_MAP_TYPE_HASH
"PERF_EVENT_ARRAY": 4, # BPF_MAP_TYPE_PERF_EVENT_ARRAY
}
def create_bpf_map(module, map_name, map_params):
"""Create a BPF map in the module with the given parameters and debug info"""
@ -191,7 +185,7 @@ def create_map_debug_info(module, map_global, map_name, map_params):
def process_hash_map(map_name, rval, module):
print(f"Creating HashMap map: {map_name}")
map_params: = {"type": BPFMapType.HASH}
map_params = {"type": BPFMapType.HASH}
# Assuming order: key_type, value_type, max_entries
if len(rval.args) >= 1 and isinstance(rval.args[0], ast.Name):