1 /* $OpenBSD: btrace.h,v 1.15 2024/05/21 05:00:48 jsg 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 unsigned long dt_get_offset(pid_t); 37 38 /* ksyms.c */ 39 struct syms; 40 struct syms *kelf_open(const char *); 41 void kelf_close(struct syms *); 42 int kelf_snprintsym(struct syms *, char *, size_t, 43 unsigned long, unsigned long); 44 45 /* map.c */ 46 struct map; 47 struct hist; 48 struct map *map_new(void); 49 void map_clear(struct map *); 50 void map_delete(struct map *, const char *); 51 struct bt_arg *map_get(struct map *, const char *); 52 void map_insert(struct map *, const char *, void *); 53 void map_print(struct map *, size_t, const char *); 54 void map_zero(struct map *); 55 struct hist *hist_new(long); 56 void hist_increment(struct hist *, const char *); 57 void hist_print(struct hist *, const char *); 58 59 #define KLEN 1024 /* # of characters in map key, contain a stack trace */ 60 #define STRLEN 128 /* maximum # of bytes to output via str() function */ 61 62 /* printf.c */ 63 int stmt_printf(struct bt_stmt *, struct dt_evt *); 64 65 /* syscalls.c */ 66 extern const char *const syscallnames[]; 67 68 #endif /* BTRACE_H */ 69