xref: /openbsd-src/usr.sbin/btrace/btrace.h (revision 1a8dbaac879b9f3335ad7fb25429ce63ac1d6bac)
1 /*	$OpenBSD: btrace.h,v 1.8 2020/08/13 11:29:39 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 long			 ba2long(struct bt_arg *, struct dt_evt *);
33 const char		*ba2str(struct bt_arg *, struct dt_evt *);
34 long			 bacmp(struct bt_arg *, struct bt_arg *);
35 
36 /* ksyms.c */
37 int			 kelf_open(void);
38 void			 kelf_close(void);
39 int			 kelf_snprintsym(char *, size_t, unsigned long);
40 
41 /* map.c */
42 struct map;
43 struct hist;
44 void			 map_clear(struct map *);
45 void			 map_delete(struct map *, const char *);
46 struct bt_arg		*map_get(struct map *, const char *);
47 struct map		*map_insert(struct map *, const char *, struct bt_arg *,
48 			    struct dt_evt *);
49 void			 map_print(struct map *, size_t, const char *);
50 void			 map_zero(struct map *);
51 struct hist		*hist_increment(struct hist *, const char *, long);
52 void			 hist_print(struct hist *, const char *);
53 
54 #define KLEN	512	/* # of characters in map key, contain a stack trace */
55 
56 /* printf.c */
57 int			 stmt_printf(struct bt_stmt *, struct dt_evt *);
58 
59 /* syscalls.c */
60 extern char		*syscallnames[];
61 
62 #endif /* BTRACE_H */
63