xref: /openbsd-src/sys/sys/stacktrace.h (revision a28bb56f1e3b6564881b3d3de68367d380458694)
1 /*	$OpenBSD: stacktrace.h,v 1.4 2023/04/26 16:53:59 claudio Exp $	*/
2 
3 /*
4  * Copyright (c) 2017 Visa Hankala
5  *
6  * Permission to use, copy, modify, and/or 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 _SYS_STACKTRACE_H_
20 #define _SYS_STACKTRACE_H_
21 
22 #define STACKTRACE_MAX	19
23 
24 struct stacktrace {
25 	unsigned int	st_count;
26 	unsigned long	st_pc[STACKTRACE_MAX];
27 };
28 
29 #ifdef _KERNEL
30 void	stacktrace_print(struct stacktrace *, int (*)(const char *, ...));
31 void	stacktrace_save_at(struct stacktrace *, unsigned int);
32 void	stacktrace_save_utrace(struct stacktrace *);
33 
34 static inline void
stacktrace_save(struct stacktrace * st)35 stacktrace_save(struct stacktrace *st)
36 {
37 	stacktrace_save_at(st, 0);
38 }
39 #endif
40 
41 #endif /* _SYS_STACKTRACE_H_ */
42