From 6e4ffe2c66578f5d497fb3f7e377079d3507cc38 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 23 Aug 2025 21:46:17 +0200 Subject: [PATCH] ucode: add function for getting the number of entries in a snapshot Signed-off-by: Felix Fietkau --- lib-ucode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib-ucode.c b/lib-ucode.c index 00ab1c8..b905cbe 100644 --- a/lib-ucode.c +++ b/lib-ucode.c @@ -467,6 +467,17 @@ uc_udebug_snapshot_get_ring(uc_vm_t *vm, size_t nargs) return ucv_get(rb->priv); } +static uc_value_t * +uc_udebug_snapshot_entries(uc_vm_t *vm, size_t nargs) +{ + struct udebug_snapshot *s = uc_fn_thisval("udebug.snapshot"); + + if (!s) + return NULL; + + return ucv_int64_new(s->n_entries); +} + static uc_value_t * uc_udebug_foreach_packet(uc_vm_t *vm, size_t nargs) { @@ -667,7 +678,8 @@ static const uc_function_list_t pcap_fns[] = { }; static const uc_function_list_t snapshot_fns[] = { - { "get_ring", uc_udebug_snapshot_get_ring } + { "get_ring", uc_udebug_snapshot_get_ring }, + { "entries", uc_udebug_snapshot_entries } }; static const uc_function_list_t wbuf_fns[] = { -- 2.30.2