diff options
Diffstat (limited to 'usr.sbin/btrace/btrace.c')
-rw-r--r-- | usr.sbin/btrace/btrace.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 4d9f316850a..1eb097dd7d2 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.13 2020/04/15 14:50:14 mpi Exp $ */ +/* $OpenBSD: btrace.c,v 1.14 2020/04/15 16:59:04 mpi Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> @@ -564,11 +564,18 @@ rule_printmaps(struct bt_rule *r) struct bt_arg *ba; SLIST_FOREACH(ba, &bs->bs_args, ba_next) { + struct bt_var *bv = ba->ba_value; + if (ba->ba_type != B_AT_MAP) continue; - map_print(ba->ba_value, SIZE_T_MAX); - map_clear(ba->ba_value); + if (bv->bv_value != NULL) { + struct map *map = (struct map *)bv->bv_value; + + map_print(map, SIZE_T_MAX, bv_name(bv)); + map_clear(map); + bv->bv_value = NULL; + } } } } @@ -646,7 +653,8 @@ stmt_clear(struct bt_stmt *bs) assert(bs->bs_var == NULL); assert(ba->ba_type == B_AT_VAR); - map_clear(bv); + map_clear((struct map *)bv->bv_value); + bv->bv_value = NULL; debug("map=%p '%s' clear\n", bv->bv_value, bv_name(bv)); } @@ -669,7 +677,7 @@ stmt_delete(struct bt_stmt *bs, struct dt_evt *dtev) debug("map=%p '%s' delete key=%p '%s'\n", bv->bv_value, bv_name(bv), bkey, ba2hash(bkey, dtev)); - map_delete(bv, ba2hash(bkey, dtev)); + map_delete((struct map *)bv->bv_value, ba2hash(bkey, dtev)); } /* @@ -692,7 +700,8 @@ stmt_insert(struct bt_stmt *bs, struct dt_evt *dtev) debug("map=%p '%s' insert key=%p '%s' bval=%p\n", bv->bv_value, bv_name(bv), bkey, ba2hash(bkey, dtev), bval); - map_insert(bv, ba2hash(bkey, dtev), bval); + bv->bv_value = (struct bt_arg *)map_insert((struct map *)bv->bv_value, + ba2hash(bkey, dtev), bval); } /* @@ -718,7 +727,7 @@ stmt_print(struct bt_stmt *bs, struct dt_evt *dtev) top = ba2long(btop, dtev); } - map_print(bv, top); + map_print((struct map *)bv->bv_value, top, bv_name(bv)); debug("map=%p '%s' print (top=%d)\n", bv->bv_value, bv_name(bv), top); } @@ -790,7 +799,7 @@ stmt_zero(struct bt_stmt *bs) assert(bs->bs_var == NULL); assert(ba->ba_type == B_AT_VAR); - map_zero(bv); + map_zero((struct map *)bv->bv_value); debug("map=%p '%s' zero\n", bv->bv_value, bv_name(bv)); } @@ -891,6 +900,7 @@ const char * ba2str(struct bt_arg *ba, struct dt_evt *dtev) { static char buf[sizeof("18446744073709551615")]; /* UINT64_MAX */ + struct bt_var *bv; const char *str; switch (ba->ba_type) { @@ -930,7 +940,9 @@ ba2str(struct bt_arg *ba, struct dt_evt *dtev) str = buf; break; case B_AT_MAP: - str = ba2str(map_get(ba->ba_value, ba2str(ba->ba_key, dtev)), dtev); + bv = ba->ba_value; + str = ba2str(map_get((struct map *)bv->bv_value, + ba2str(ba->ba_key, dtev)), dtev); break; case B_AT_VAR: str = ba2str(ba_read(ba), dtev); |