Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ingo Molnar | 8637c09 | 2006-07-03 00:24:38 -0700 | [diff] [blame] | 2 | #ifndef __LINUX_STACKTRACE_H |
| 3 | #define __LINUX_STACKTRACE_H |
| 4 | |
Joonsoo Kim | 9a92a6c | 2014-12-12 16:55:58 -0800 | [diff] [blame] | 5 | #include <linux/types.h> |
| 6 | |
Andrew Morton | 897312b | 2008-10-03 15:23:41 -0700 | [diff] [blame] | 7 | struct task_struct; |
Soeren Sandmann Pedersen | 9c0729d | 2010-11-05 05:59:39 -0400 | [diff] [blame] | 8 | struct pt_regs; |
Andrew Morton | 897312b | 2008-10-03 15:23:41 -0700 | [diff] [blame] | 9 | |
Ingo Molnar | 8637c09 | 2006-07-03 00:24:38 -0700 | [diff] [blame] | 10 | #ifdef CONFIG_STACKTRACE |
| 11 | struct stack_trace { |
| 12 | unsigned int nr_entries, max_entries; |
| 13 | unsigned long *entries; |
Andi Kleen | 5a1b399 | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 14 | int skip; /* input argument: How many entries to skip */ |
Ingo Molnar | 8637c09 | 2006-07-03 00:24:38 -0700 | [diff] [blame] | 15 | }; |
| 16 | |
Christoph Hellwig | ab1b6f0 | 2007-05-08 00:23:29 -0700 | [diff] [blame] | 17 | extern void save_stack_trace(struct stack_trace *trace); |
Masami Hiramatsu | 3958106 | 2011-06-08 16:09:21 +0900 | [diff] [blame] | 18 | extern void save_stack_trace_regs(struct pt_regs *regs, |
| 19 | struct stack_trace *trace); |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 20 | extern void save_stack_trace_tsk(struct task_struct *tsk, |
| 21 | struct stack_trace *trace); |
Josh Poimboeuf | af085d9 | 2017-02-13 19:42:28 -0600 | [diff] [blame] | 22 | extern int save_stack_trace_tsk_reliable(struct task_struct *tsk, |
| 23 | struct stack_trace *trace); |
Ingo Molnar | 8637c09 | 2006-07-03 00:24:38 -0700 | [diff] [blame] | 24 | |
| 25 | extern void print_stack_trace(struct stack_trace *trace, int spaces); |
Joonsoo Kim | 9a92a6c | 2014-12-12 16:55:58 -0800 | [diff] [blame] | 26 | extern int snprint_stack_trace(char *buf, size_t size, |
| 27 | struct stack_trace *trace, int spaces); |
Török Edwin | 02b6751 | 2008-11-22 13:28:47 +0200 | [diff] [blame] | 28 | |
Török Edwin | 8d26487 | 2008-11-23 12:39:08 +0200 | [diff] [blame] | 29 | #ifdef CONFIG_USER_STACKTRACE_SUPPORT |
Török Edwin | 02b6751 | 2008-11-22 13:28:47 +0200 | [diff] [blame] | 30 | extern void save_stack_trace_user(struct stack_trace *trace); |
| 31 | #else |
| 32 | # define save_stack_trace_user(trace) do { } while (0) |
| 33 | #endif |
| 34 | |
Josh Poimboeuf | af085d9 | 2017-02-13 19:42:28 -0600 | [diff] [blame] | 35 | #else /* !CONFIG_STACKTRACE */ |
Christoph Hellwig | ab1b6f0 | 2007-05-08 00:23:29 -0700 | [diff] [blame] | 36 | # define save_stack_trace(trace) do { } while (0) |
Arjan van de Ven | 9745512 | 2008-01-25 21:08:34 +0100 | [diff] [blame] | 37 | # define save_stack_trace_tsk(tsk, trace) do { } while (0) |
Török Edwin | 8d7c6a9 | 2008-11-23 12:39:06 +0200 | [diff] [blame] | 38 | # define save_stack_trace_user(trace) do { } while (0) |
Johannes Berg | 3b5ad07 | 2007-07-19 01:49:02 -0700 | [diff] [blame] | 39 | # define print_stack_trace(trace, spaces) do { } while (0) |
Joonsoo Kim | 9a92a6c | 2014-12-12 16:55:58 -0800 | [diff] [blame] | 40 | # define snprint_stack_trace(buf, size, trace, spaces) do { } while (0) |
Josh Poimboeuf | af085d9 | 2017-02-13 19:42:28 -0600 | [diff] [blame] | 41 | # define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; }) |
| 42 | #endif /* CONFIG_STACKTRACE */ |
Ingo Molnar | 8637c09 | 2006-07-03 00:24:38 -0700 | [diff] [blame] | 43 | |
Josh Poimboeuf | af085d9 | 2017-02-13 19:42:28 -0600 | [diff] [blame] | 44 | #endif /* __LINUX_STACKTRACE_H */ |