diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2021-01-21 13:19:26 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2021-01-21 13:19:26 +0000 |
commit | d1e7795de85a2be1fc02b22a8d782641d0a9f802 (patch) | |
tree | 38f002b3b4613640acf4989dcf4355d6d47717a3 /usr.sbin/btrace | |
parent | 9f79ee7c90db0af74f626b71457c649005e032a5 (diff) |
Make it possible to convert map arguments to long and insert nsecs in maps.
Necessary to measure latency, example below to better understand the kqueue
select(2) regression:
syscall:select:entry { @start[pid] = nsecs; }
syscall:select:return { @usecs = hist((nsecs - @start[pid]) / 1000); }
Diffstat (limited to 'usr.sbin/btrace')
-rw-r--r-- | usr.sbin/btrace/btrace.c | 8 | ||||
-rw-r--r-- | usr.sbin/btrace/map.c | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 64acf9eaef6..3eda0a638fd 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.26 2020/12/07 18:28:09 bluhm Exp $ */ +/* $OpenBSD: btrace.c,v 1.27 2021/01/21 13:19:25 mpi Exp $ */ /* * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> @@ -1030,6 +1030,7 @@ baexpr2long(struct bt_arg *ba, struct dt_evt *dtev) long ba2long(struct bt_arg *ba, struct dt_evt *dtev) { + struct bt_var *bv; long val; switch (ba->ba_type) { @@ -1040,6 +1041,11 @@ ba2long(struct bt_arg *ba, struct dt_evt *dtev) ba = ba_read(ba); val = (long)ba->ba_value; break; + case B_AT_MAP: + bv = ba->ba_value; + val = ba2long(map_get((struct map *)bv->bv_value, + ba2str(ba->ba_key, dtev)), dtev); + break; case B_AT_BI_NSECS: val = builtin_nsecs(dtev); break; diff --git a/usr.sbin/btrace/map.c b/usr.sbin/btrace/map.c index f50f9abdca7..85e675d94f4 100644 --- a/usr.sbin/btrace/map.c +++ b/usr.sbin/btrace/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.11 2020/09/18 19:19:38 jasper Exp $ */ +/* $OpenBSD: map.c,v 1.12 2021/01/21 13:19:25 mpi Exp $ */ /* * Copyright (c) 2020 Martin Pieuchot <mpi@openbsd.org> @@ -138,6 +138,7 @@ map_insert(struct map *map, const char *key, struct bt_arg *bval, free(mep->mval); mep->mval = bval; break; + case B_AT_BI_NSECS: case B_AT_BI_RETVAL: free(mep->mval); mep->mval = ba_new(ba2long(bval, dtev), B_AT_LONG); |