mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
Add IR and debug info generation for multiple MAP types
This commit is contained in:
@ -21,9 +21,18 @@ def maps_proc(tree, module, chunks):
|
|||||||
return map_sym_tab
|
return map_sym_tab
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
def create_bpf_map(module, map_name, map_params):
|
||||||
"""Create a BPF map in the module with the given parameters and debug info"""
|
"""Create a BPF map in the module with the given parameters and debug info"""
|
||||||
|
|
||||||
|
map_type_str = map_params.get("map_type", "HASH")
|
||||||
|
map_type = BPF_MAP_MAPPINGS.get(map_type_str)
|
||||||
|
|
||||||
# Create the anonymous struct type for BPF map
|
# Create the anonymous struct type for BPF map
|
||||||
map_struct_type = ir.LiteralStructType([
|
map_struct_type = ir.LiteralStructType([
|
||||||
ir.PointerType(),
|
ir.PointerType(),
|
||||||
@ -69,7 +78,8 @@ def create_map_debug_info(module, map_global, map_name, map_params):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Create array type for map type field (array of 1 unsigned int)
|
# Create array type for map type field (array of 1 unsigned int)
|
||||||
array_subrange = module.add_debug_info("DISubrange", {"count": 1})
|
array_subrange = module.add_debug_info(
|
||||||
|
"DISubrange", {"count": BPF_MAP_MAPPINGS[map_params.get("map_type", "HASH")]})
|
||||||
array_type = module.add_debug_info("DICompositeType", {
|
array_type = module.add_debug_info("DICompositeType", {
|
||||||
"tag": dc.DW_TAG_array_type,
|
"tag": dc.DW_TAG_array_type,
|
||||||
"baseType": uint_type,
|
"baseType": uint_type,
|
||||||
|
|||||||
Reference in New Issue
Block a user