diff --git a/examples/c-form/ex3-2.bpf.c b/examples/c-form/ex3-2.bpf.c index 3091e6a..909bf45 100644 --- a/examples/c-form/ex3-2.bpf.c +++ b/examples/c-form/ex3-2.bpf.c @@ -8,7 +8,7 @@ struct { __uint(type, BPF_MAP_TYPE_HASH); __type(key, u64); __type(value, u64); - __uint(max_entries, 1); + __uint(max_entries, 4); } last SEC(".maps"); // Handler for syscall entry diff --git a/examples/execve3.py b/examples/execve3.py index cfa4dc3..eadfd47 100644 --- a/examples/execve3.py +++ b/examples/execve3.py @@ -8,7 +8,7 @@ from ctypes import c_void_p, c_int64, c_int32, c_uint64 @bpf @map def last() -> HashMap: - return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=1) + return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=3) @bpf @@ -37,7 +37,13 @@ def hello_again(ctx: c_void_p) -> c_int64: if x: print("we did not prevail") ts = ktime() - last().update(key, ts, 0) + last().update(key, ts) + keys = 2 + last().update(keys, ts) + key = 4 + last().update(key, ts) + key = 5 + last().update(key, ts) return c_int64(0) diff --git a/pythonbpf/maps_pass.py b/pythonbpf/maps_pass.py index cb5528a..d9977dc 100644 --- a/pythonbpf/maps_pass.py +++ b/pythonbpf/maps_pass.py @@ -74,6 +74,14 @@ def create_map_debug_info(module, map_global, map_name, map_params): "size": 32, "elements": [array_subrange] }) + + array_subrange_max_entries = module.add_debug_info("DISubrange", {"count": map_params["max_entries"]}) + array_type_max_entries = module.add_debug_info("DICompositeType", { + "tag": dc.DW_TAG_array_type, + "baseType": uint_type, + "size": 32, + "elements": [array_subrange_max_entries] + }) # Create pointer types type_ptr = module.add_debug_info("DIDerivedType", { @@ -84,7 +92,7 @@ def create_map_debug_info(module, map_global, map_name, map_params): max_entries_ptr = module.add_debug_info("DIDerivedType", { "tag": dc.DW_TAG_pointer_type, - "baseType": array_type, + "baseType": array_type_max_entries, "size": 64 })