1 /* $OpenBSD: btrace.h,v 1.9 2021/02/08 09:46:45 mpi Exp $ */ 2 3 /* 4 * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef BTRACE_H 20 #define BTRACE_H 21 22 #ifndef nitems 23 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 24 #endif 25 26 struct dt_evt; 27 struct bt_arg; 28 struct bt_var; 29 struct bt_stmt; 30 31 /* btrace.c */ 32 const char * ba_name(struct bt_arg *); 33 long ba2long(struct bt_arg *, struct dt_evt *); 34 const char *ba2str(struct bt_arg *, struct dt_evt *); 35 long bacmp(struct bt_arg *, struct bt_arg *); 36 37 /* ksyms.c */ 38 int kelf_open(void); 39 void kelf_close(void); 40 int kelf_snprintsym(char *, size_t, unsigned long); 41 42 /* map.c */ 43 struct map; 44 struct hist; 45 void map_clear(struct map *); 46 void map_delete(struct map *, const char *); 47 struct bt_arg *map_get(struct map *, const char *); 48 struct map *map_insert(struct map *, const char *, struct bt_arg *, 49 struct dt_evt *); 50 void map_print(struct map *, size_t, const char *); 51 void map_zero(struct map *); 52 struct hist *hist_increment(struct hist *, const char *, long); 53 void hist_print(struct hist *, const char *); 54 55 #define KLEN 512 /* # of characters in map key, contain a stack trace */ 56 57 /* printf.c */ 58 int stmt_printf(struct bt_stmt *, struct dt_evt *); 59 60 /* syscalls.c */ 61 extern char *syscallnames[]; 62 63 #endif /* BTRACE_H */ 64