~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/stacktrace.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __LINUX_STACKTRACE_H
  3 #define __LINUX_STACKTRACE_H
  4 
  5 #include <linux/types.h>
  6 #include <asm/errno.h>
  7 
  8 struct task_struct;
  9 struct pt_regs;
 10 
 11 #ifdef CONFIG_ARCH_STACKWALK
 12 
 13 /**
 14  * stack_trace_consume_fn - Callback for arch_stack_walk()
 15  * @cookie:     Caller supplied pointer handed back by arch_stack_walk()
 16  * @addr:       The stack entry address to consume
 17  *
 18  * Return:      True, if the entry was consumed or skipped
 19  *              False, if there is no space left to store
 20  */
 21 typedef bool (*stack_trace_consume_fn)(void *cookie, unsigned long addr);
 22 /**
 23  * arch_stack_walk - Architecture specific function to walk the stack
 24  * @consume_entry:      Callback which is invoked by the architecture code for
 25  *                      each entry.
 26  * @cookie:             Caller supplied pointer which is handed back to
 27  *                      @consume_entry
 28  * @task:               Pointer to a task struct, can be NULL
 29  * @regs:               Pointer to registers, can be NULL
 30  *
 31  * ============ ======= ============================================
 32  * task         regs
 33  * ============ ======= ============================================
 34  * task         NULL    Stack trace from task (can be current)
 35  * current      regs    Stack trace starting on regs->stackpointer
 36  * ============ ======= ============================================
 37  */
 38 void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
 39                      struct task_struct *task, struct pt_regs *regs);
 40 
 41 /**
 42  * arch_stack_walk_reliable - Architecture specific function to walk the
 43  *                            stack reliably
 44  *
 45  * @consume_entry:      Callback which is invoked by the architecture code for
 46  *                      each entry.
 47  * @cookie:             Caller supplied pointer which is handed back to
 48  *                      @consume_entry
 49  * @task:               Pointer to a task struct, can be NULL
 50  *
 51  * This function returns an error if it detects any unreliable
 52  * features of the stack. Otherwise it guarantees that the stack
 53  * trace is reliable.
 54  *
 55  * If the task is not 'current', the caller *must* ensure the task is
 56  * inactive and its stack is pinned.
 57  */
 58 int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie,
 59                              struct task_struct *task);
 60 
 61 void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie,
 62                           const struct pt_regs *regs);
 63 #endif /* CONFIG_ARCH_STACKWALK */
 64 
 65 #ifdef CONFIG_STACKTRACE
 66 void stack_trace_print(const unsigned long *trace, unsigned int nr_entries,
 67                        int spaces);
 68 int stack_trace_snprint(char *buf, size_t size, const unsigned long *entries,
 69                         unsigned int nr_entries, int spaces);
 70 unsigned int stack_trace_save(unsigned long *store, unsigned int size,
 71                               unsigned int skipnr);
 72 unsigned int stack_trace_save_tsk(struct task_struct *task,
 73                                   unsigned long *store, unsigned int size,
 74                                   unsigned int skipnr);
 75 unsigned int stack_trace_save_regs(struct pt_regs *regs, unsigned long *store,
 76                                    unsigned int size, unsigned int skipnr);
 77 unsigned int stack_trace_save_user(unsigned long *store, unsigned int size);
 78 unsigned int filter_irq_stacks(unsigned long *entries, unsigned int nr_entries);
 79 
 80 #ifndef CONFIG_ARCH_STACKWALK
 81 /* Internal interfaces. Do not use in generic code */
 82 struct stack_trace {
 83         unsigned int nr_entries, max_entries;
 84         unsigned long *entries;
 85         unsigned int skip;      /* input argument: How many entries to skip */
 86 };
 87 
 88 extern void save_stack_trace(struct stack_trace *trace);
 89 extern void save_stack_trace_regs(struct pt_regs *regs,
 90                                   struct stack_trace *trace);
 91 extern void save_stack_trace_tsk(struct task_struct *tsk,
 92                                 struct stack_trace *trace);
 93 extern int save_stack_trace_tsk_reliable(struct task_struct *tsk,
 94                                          struct stack_trace *trace);
 95 extern void save_stack_trace_user(struct stack_trace *trace);
 96 #endif /* !CONFIG_ARCH_STACKWALK */
 97 #endif /* CONFIG_STACKTRACE */
 98 
 99 #if defined(CONFIG_STACKTRACE) && defined(CONFIG_HAVE_RELIABLE_STACKTRACE)
100 int stack_trace_save_tsk_reliable(struct task_struct *tsk, unsigned long *store,
101                                   unsigned int size);
102 #else
103 static inline int stack_trace_save_tsk_reliable(struct task_struct *tsk,
104                                                 unsigned long *store,
105                                                 unsigned int size)
106 {
107         return -ENOSYS;
108 }
109 #endif
110 
111 #endif /* __LINUX_STACKTRACE_H */
112 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php