blob: ba29a0613e66ffa83162692f05e367e7dd129d82 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Ingo Molnar8637c092006-07-03 00:24:38 -07002#ifndef __LINUX_STACKTRACE_H
3#define __LINUX_STACKTRACE_H
4
Joonsoo Kim9a92a6c2014-12-12 16:55:58 -08005#include <linux/types.h>
6
Andrew Morton897312b2008-10-03 15:23:41 -07007struct task_struct;
Soeren Sandmann Pedersen9c0729d2010-11-05 05:59:39 -04008struct pt_regs;
Andrew Morton897312b2008-10-03 15:23:41 -07009
Ingo Molnar8637c092006-07-03 00:24:38 -070010#ifdef CONFIG_STACKTRACE
11struct stack_trace {
12 unsigned int nr_entries, max_entries;
13 unsigned long *entries;
Andi Kleen5a1b3992006-09-26 10:52:34 +020014 int skip; /* input argument: How many entries to skip */
Ingo Molnar8637c092006-07-03 00:24:38 -070015};
16
Christoph Hellwigab1b6f02007-05-08 00:23:29 -070017extern void save_stack_trace(struct stack_trace *trace);
Masami Hiramatsu39581062011-06-08 16:09:21 +090018extern void save_stack_trace_regs(struct pt_regs *regs,
19 struct stack_trace *trace);
Arjan van de Ven97455122008-01-25 21:08:34 +010020extern void save_stack_trace_tsk(struct task_struct *tsk,
21 struct stack_trace *trace);
Josh Poimboeufaf085d92017-02-13 19:42:28 -060022extern int save_stack_trace_tsk_reliable(struct task_struct *tsk,
23 struct stack_trace *trace);
Ingo Molnar8637c092006-07-03 00:24:38 -070024
25extern void print_stack_trace(struct stack_trace *trace, int spaces);
Joonsoo Kim9a92a6c2014-12-12 16:55:58 -080026extern int snprint_stack_trace(char *buf, size_t size,
27 struct stack_trace *trace, int spaces);
Török Edwin02b67512008-11-22 13:28:47 +020028
Török Edwin8d264872008-11-23 12:39:08 +020029#ifdef CONFIG_USER_STACKTRACE_SUPPORT
Török Edwin02b67512008-11-22 13:28:47 +020030extern 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 Poimboeufaf085d92017-02-13 19:42:28 -060035#else /* !CONFIG_STACKTRACE */
Christoph Hellwigab1b6f02007-05-08 00:23:29 -070036# define save_stack_trace(trace) do { } while (0)
Arjan van de Ven97455122008-01-25 21:08:34 +010037# define save_stack_trace_tsk(tsk, trace) do { } while (0)
Török Edwin8d7c6a92008-11-23 12:39:06 +020038# define save_stack_trace_user(trace) do { } while (0)
Johannes Berg3b5ad072007-07-19 01:49:02 -070039# define print_stack_trace(trace, spaces) do { } while (0)
Joonsoo Kim9a92a6c2014-12-12 16:55:58 -080040# define snprint_stack_trace(buf, size, trace, spaces) do { } while (0)
Josh Poimboeufaf085d92017-02-13 19:42:28 -060041# define save_stack_trace_tsk_reliable(tsk, trace) ({ -ENOSYS; })
42#endif /* CONFIG_STACKTRACE */
Ingo Molnar8637c092006-07-03 00:24:38 -070043
Josh Poimboeufaf085d92017-02-13 19:42:28 -060044#endif /* __LINUX_STACKTRACE_H */