Skip to content

Commit 431921d

Browse files
multiple map elements support
1 parent 7de3a38 commit 431921d

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

examples/c-form/ex3-2.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct {
88
__uint(type, BPF_MAP_TYPE_HASH);
99
__type(key, u64);
1010
__type(value, u64);
11-
__uint(max_entries, 1);
11+
__uint(max_entries, 4);
1212
} last SEC(".maps");
1313

1414
// Handler for syscall entry

examples/execve3.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@bpf
99
@map
1010
def last() -> HashMap:
11-
return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=1)
11+
return HashMap(key_type=c_uint64, value_type=c_uint64, max_entries=3)
1212

1313

1414
@bpf
@@ -37,7 +37,13 @@ def hello_again(ctx: c_void_p) -> c_int64:
3737
if x:
3838
print("we did not prevail")
3939
ts = ktime()
40-
last().update(key, ts, 0)
40+
last().update(key, ts)
41+
keys = 2
42+
last().update(keys, ts)
43+
key = 4
44+
last().update(key, ts)
45+
key = 5
46+
last().update(key, ts)
4147
return c_int64(0)
4248

4349

pythonbpf/maps_pass.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ def create_map_debug_info(module, map_global, map_name, map_params):
7474
"size": 32,
7575
"elements": [array_subrange]
7676
})
77+
78+
array_subrange_max_entries = module.add_debug_info("DISubrange", {"count": map_params["max_entries"]})
79+
array_type_max_entries = module.add_debug_info("DICompositeType", {
80+
"tag": dc.DW_TAG_array_type,
81+
"baseType": uint_type,
82+
"size": 32,
83+
"elements": [array_subrange_max_entries]
84+
})
7785

7886
# Create pointer types
7987
type_ptr = module.add_debug_info("DIDerivedType", {
@@ -84,7 +92,7 @@ def create_map_debug_info(module, map_global, map_name, map_params):
8492

8593
max_entries_ptr = module.add_debug_info("DIDerivedType", {
8694
"tag": dc.DW_TAG_pointer_type,
87-
"baseType": array_type,
95+
"baseType": array_type_max_entries,
8896
"size": 64
8997
})
9098

0 commit comments

Comments
 (0)