xref: /openbsd/usr.sbin/btrace/btrace.h (revision 42858fb0)
1*42858fb0Smpi /*	$OpenBSD: btrace.h,v 1.7 2020/08/07 14:04:59 mpi 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 */
320dac42ecSmpi long			 ba2long(struct bt_arg *, struct dt_evt *);
3323160851Smpi const char		*ba2str(struct bt_arg *, struct dt_evt *);
3423160851Smpi long			 bacmp(struct bt_arg *, struct bt_arg *);
3523160851Smpi 
3623160851Smpi /* ksyms.c */
3723160851Smpi int			 kelf_open(void);
3823160851Smpi void			 kelf_close(void);
3923160851Smpi int			 kelf_snprintsym(char *, size_t, unsigned long);
4023160851Smpi 
4123160851Smpi /* map.c */
42244912e4Smpi struct map;
439c84395dSmpi struct hist;
44244912e4Smpi void			 map_clear(struct map *);
45244912e4Smpi void			 map_delete(struct map *, const char *);
46244912e4Smpi struct bt_arg		*map_get(struct map *, const char *);
47405649c2Smpi struct map		*map_insert(struct map *, const char *, struct bt_arg *,
489c84395dSmpi 			    struct dt_evt *);
49244912e4Smpi void			 map_print(struct map *, size_t, const char *);
50244912e4Smpi void			 map_zero(struct map *);
519c84395dSmpi struct hist		*hist_increment(struct hist *, const char *, long);
529c84395dSmpi void			 hist_print(struct hist *, const char *);
5323160851Smpi 
54*42858fb0Smpi #define KLEN	512	/* number of characters in a key */
55*42858fb0Smpi 
5623160851Smpi /* printf.c */
5723160851Smpi int			 stmt_printf(struct bt_stmt *, struct dt_evt *);
5823160851Smpi 
5923160851Smpi /* syscalls.c */
6023160851Smpi extern char		*syscallnames[];
6123160851Smpi 
6223160851Smpi #endif /* BTRACE_H */
63