summaryrefslogtreecommitdiff
path: root/usr.sbin/btrace/btrace.h
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2020-07-11 14:52:15 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2020-07-11 14:52:15 +0000
commit646be632a6616f0fa1d651a480810494e78d6931 (patch)
tree397eaaf62704f00913f0a12109deec43568970b7 /usr.sbin/btrace/btrace.h
parent66c2d51d0f0296d5cc3a7e05b620dc0e31972ba3 (diff)
Implement linear and power-of-two histograms: hist() and lhist() keywords.
This is built on top of maps which are currently built on top of RB-trees. Improvements are welcome! For example the use of a hashing table as pointed by espie@. The following one-liner produce an histogram of power-of-two values returned by the read(2) syscall: btrace 'syscall:read:return { @bytes = hist(retval); }' ^C @bytes: [0] 19 |@@@@@@@@@@@@@@@@@@@@@@@@@@ | [1] 26 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [1, 2) 1 |@ | [2, 4) 13 |@@@@@@@@@@@@@@@@@@ | [4, 8) 4 |@@@@@ | [8, 16) 3 |@@@@ | [16, 32) 1 |@ | [32, 64) 8 |@@@@@@@@@@@ | [64, 128) 14 |@@@@@@@@@@@@@@@@@@@ | [128, 256) 7 |@@@@@@@@@ | [256, 512) 37 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [512, 1K) 1 |@ | [1K, 2K) 10 |@@@@@@@@@@@@@@ | [2K, 4K) 11 |@@@@@@@@@@@@@@@ | [8K, 16K) 1 |@ |
Diffstat (limited to 'usr.sbin/btrace/btrace.h')
-rw-r--r--usr.sbin/btrace/btrace.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/btrace/btrace.h b/usr.sbin/btrace/btrace.h
index 27f4de57843..cd9001a44d8 100644
--- a/usr.sbin/btrace/btrace.h
+++ b/usr.sbin/btrace/btrace.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: btrace.h,v 1.5 2020/07/04 10:16:15 mpi Exp $ */
+/* $OpenBSD: btrace.h,v 1.6 2020/07/11 14:52:14 mpi Exp $ */
/*
* Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org>
@@ -40,13 +40,16 @@ int kelf_snprintsym(char *, size_t, unsigned long);
/* map.c */
struct map;
+struct hist;
void map_clear(struct map *);
void map_delete(struct map *, const char *);
struct bt_arg *map_get(struct map *, const char *);
struct map *map_insert(struct map *, const char *, struct bt_arg *,
- long);
+ struct dt_evt *);
void map_print(struct map *, size_t, const char *);
void map_zero(struct map *);
+struct hist *hist_increment(struct hist *, const char *, long);
+void hist_print(struct hist *, const char *);
/* printf.c */
int stmt_printf(struct bt_stmt *, struct dt_evt *);