diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2024-02-24 17:06:00 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2024-02-24 17:06:00 +0000 |
commit | 004256b1b6189d447fc5a30027c51933607beec4 (patch) | |
tree | 350097346f9da382b9a0981d6a25d9e413293f83 /usr.sbin/btrace | |
parent | bf486990aec267dc4291af4319294d77d2b418e1 (diff) |
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.
Diffstat (limited to 'usr.sbin/btrace')
-rw-r--r-- | usr.sbin/btrace/btrace.c | 13 |
1 files changed, 12 insertions, 1 deletions
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 <mpi@openbsd.org> @@ -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; |