1*ce7279d8Sjsg /* $OpenBSD: btrace.h,v 1.15 2024/05/21 05:00:48 jsg Exp $ */ 223160851Smpi 323160851Smpi /* 423160851Smpi * Copyright (c) 2019 - 2020 Martin Pieuchot <mpi@openbsd.org> 523160851Smpi * 623160851Smpi * Permission to use, copy, modify, and distribute this software for any 723160851Smpi * purpose with or without fee is hereby granted, provided that the above 823160851Smpi * copyright notice and this permission notice appear in all copies. 923160851Smpi * 1023160851Smpi * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1123160851Smpi * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1223160851Smpi * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1323160851Smpi * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1423160851Smpi * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1523160851Smpi * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1623160851Smpi * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1723160851Smpi */ 1823160851Smpi 1923160851Smpi #ifndef BTRACE_H 2023160851Smpi #define BTRACE_H 2123160851Smpi 2223160851Smpi #ifndef nitems 2323160851Smpi #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 2423160851Smpi #endif 2523160851Smpi 2623160851Smpi struct dt_evt; 2723160851Smpi struct bt_arg; 2823160851Smpi struct bt_var; 2923160851Smpi struct bt_stmt; 3023160851Smpi 3123160851Smpi /* btrace.c */ 32a31d03f7Smpi const char * ba_name(struct bt_arg *); 330dac42ecSmpi long ba2long(struct bt_arg *, struct dt_evt *); 3423160851Smpi const char *ba2str(struct bt_arg *, struct dt_evt *); 3523160851Smpi long bacmp(struct bt_arg *, struct bt_arg *); 365e6104a1Sclaudio unsigned long dt_get_offset(pid_t); 3723160851Smpi 3823160851Smpi /* ksyms.c */ 395e6104a1Sclaudio struct syms; 405e6104a1Sclaudio struct syms *kelf_open(const char *); 415e6104a1Sclaudio void kelf_close(struct syms *); 425e6104a1Sclaudio int kelf_snprintsym(struct syms *, char *, size_t, 435e6104a1Sclaudio unsigned long, unsigned long); 4423160851Smpi 4523160851Smpi /* map.c */ 46244912e4Smpi struct map; 479c84395dSmpi struct hist; 4866f34ae4Smpi struct map *map_new(void); 49244912e4Smpi void map_clear(struct map *); 50244912e4Smpi void map_delete(struct map *, const char *); 51244912e4Smpi struct bt_arg *map_get(struct map *, const char *); 5266f34ae4Smpi void map_insert(struct map *, const char *, void *); 53244912e4Smpi void map_print(struct map *, size_t, const char *); 54244912e4Smpi void map_zero(struct map *); 5566f34ae4Smpi struct hist *hist_new(long); 5666f34ae4Smpi void hist_increment(struct hist *, const char *); 579c84395dSmpi void hist_print(struct hist *, const char *); 5823160851Smpi 595e6104a1Sclaudio #define KLEN 1024 /* # of characters in map key, contain a stack trace */ 608420ddd2Smpi #define STRLEN 128 /* maximum # of bytes to output via str() function */ 6142858fb0Smpi 6223160851Smpi /* printf.c */ 6323160851Smpi int stmt_printf(struct bt_stmt *, struct dt_evt *); 6423160851Smpi 6523160851Smpi /* syscalls.c */ 664ed6f7c2Sguenther extern const char *const syscallnames[]; 6723160851Smpi 6823160851Smpi #endif /* BTRACE_H */ 69