From db30eb4f0630714296dba474b3b2a5a239a8b9d9 Mon Sep 17 00:00:00 2001 From: mpi Date: Sat, 24 Feb 2024 17:05:59 +0000 Subject: [PATCH] Implement 'store' for maps. A current limitation is the value read from a map is converted to an integer. To preserve the original type we have to make maps aware of the type of its elements. --- usr.sbin/btrace/btrace.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index a7285a4ebb9..5e5f23f2f2a 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.86 2024/02/24 16:19:49 mpi Exp $ */ +/* $OpenBSD: btrace.c,v 1.87 2024/02/24 17:05:59 mpi Exp $ */ /* * Copyright (c) 2019 - 2023 Martin Pieuchot @@ -1089,6 +1089,7 @@ stmt_store(struct bt_stmt *bs, struct dt_evt *dtev) { struct bt_arg *ba = SLIST_FIRST(&bs->bs_args); struct bt_var *bvar, *bv = bs->bs_var; + struct map *map; assert(SLIST_NEXT(ba, ba_next) == NULL); @@ -1106,6 +1107,16 @@ stmt_store(struct bt_stmt *bs, struct dt_evt *dtev) bv->bv_type = bvar->bv_type; bv->bv_value = bvar->bv_value; break; + case B_AT_MAP: + bvar = ba->ba_value; + map = (struct map *)bvar->bv_value; + /* Uninitialized map */ + if (map == NULL) + bv->bv_value = 0; + else + bv->bv_value = map_get(map, ba2hash(ba->ba_key, dtev)); + bv->bv_type = B_VT_LONG; /* XXX should we type map? */ + break; case B_AT_TUPLE: bv->bv_value = baeval(ba, dtev); bv->bv_type = B_VT_TUPLE; -- 2.20.1