summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-08-23 19:46:17 +0000
committerFelix Fietkau2025-08-23 19:46:17 +0000
commit6e4ffe2c66578f5d497fb3f7e377079d3507cc38 (patch)
tree88778ff511db0e1b8a15dd93e619bfa40185ddf0
parent892647b81d30fcec8d275a2c5da05b94192c095d (diff)
ucode: add function for getting the number of entries in a snapshot
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--lib-ucode.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib-ucode.c b/lib-ucode.c
index 00ab1c8..b905cbe 100644
--- a/lib-ucode.c
+++ b/lib-ucode.c
@@ -468,6 +468,17 @@ uc_udebug_snapshot_get_ring(uc_vm_t *vm, size_t nargs)
}
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)
{
uc_value_t *arg = uc_fn_arg(0);
@@ -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[] = {