0001
0002 #ifndef __LINUX_STACKTRACE_H
0003 #define __LINUX_STACKTRACE_H
0004
0005 #include <linux/types.h>
0006 #include <asm/errno.h>
0007
0008 struct task_struct;
0009 struct pt_regs;
0010
0011 #ifdef CONFIG_ARCH_STACKWALK
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr);
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
0039 struct task_struct *task, struct pt_regs *regs);
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie,
0059 struct task_struct *task);
0060
0061 void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
0062 const struct pt_regs *regs);
0063 #endif
0064
0065 #ifdef CONFIG_STACKTRACE
0066 void stack_trace_print(const unsigned long *trace, unsigned int nr_entries,
0067 int spaces);
0068 int stack_trace_snprint(char *buf, size_t size, const unsigned long *entries,
0069 unsigned int nr_entries, int spaces);
0070 unsigned int stack_trace_save(unsigned long *store, unsigned int size,
0071 unsigned int skipnr);
0072 unsigned int stack_trace_save_tsk(struct task_struct *task,
0073 unsigned long *store, unsigned int size,
0074 unsigned int skipnr);
0075 unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store,
0076 unsigned int size, unsigned int skipnr);
0077 unsigned int stack_trace_save_user(unsigned long *store, unsigned int size);
0078 unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries);
0079
0080 #ifndef CONFIG_ARCH_STACKWALK
0081
0082 struct stack_trace {
0083 unsigned int nr_entries, max_entries;
0084 unsigned long *entries;
0085 unsigned int skip;
0086 };
0087
0088 extern void save_stack_trace(struct stack_trace *trace);
0089 extern void save_stack_trace_regs(struct pt_regs *regs,
0090 struct stack_trace *trace);
0091 extern void save_stack_trace_tsk(struct task_struct *tsk,
0092 struct stack_trace *trace);
0093 extern int save_stack_trace_tsk_reliable(struct task_struct *tsk,
0094 struct stack_trace *trace);
0095 extern void save_stack_trace_user(struct stack_trace *trace);
0096 #endif
0097 #endif
0098
0099 #if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE)
0100 int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store,
0101 unsigned int size);
0102 #else
0103 static inline int stack_trace_save_tsk_reliable(struct task_struct *tsk,
0104 unsigned long *store,
0105 unsigned int size)
0106 {
0107 return -ENOSYS;
0108 }
0109 #endif
0110
0111 #endif