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 26struct dt_evt; 27struct bt_arg; 28struct bt_var; 29struct bt_stmt; 30 31/* btrace.c */ 32const char * ba_name(struct bt_arg *); 33long ba2long(struct bt_arg *, struct dt_evt *); 34const char *ba2str(struct bt_arg *, struct dt_evt *); 35long bacmp(struct bt_arg *, struct bt_arg *); 36unsigned long dt_get_offset(pid_t); 37 38/* ksyms.c */ 39struct syms; 40struct syms *kelf_open(const char *); 41void kelf_close(struct syms *); 42int kelf_snprintsym(struct syms *, char *, size_t, 43 unsigned long, unsigned long); 44 45/* map.c */ 46struct map; 47struct hist; 48struct map *map_new(void); 49void map_clear(struct map *); 50void map_delete(struct map *, const char *); 51struct bt_arg *map_get(struct map *, const char *); 52void map_insert(struct map *, const char *, void *); 53void map_print(struct map *, size_t, const char *); 54void map_zero(struct map *); 55struct hist *hist_new(long); 56void hist_increment(struct hist *, const char *); 57void 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 */ 63int stmt_printf(struct bt_stmt *, struct dt_evt *); 64 65/* syscalls.c */ 66extern const char *const syscallnames[]; 67 68#endif /* BTRACE_H */ 69