2 * Copyright (C) 1991, 1992 Linus Torvalds
3 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
6 #ifndef _ASM_X86_STACKTRACE_H
7 #define _ASM_X86_STACKTRACE_H
9 #include <linux/uaccess.h>
11 extern int kstack_depth_to_print;
14 struct stacktrace_ops;
16 typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
19 const struct stacktrace_ops *ops,
25 print_context_stack(struct thread_info *tinfo,
26 unsigned long *stack, unsigned long bp,
27 const struct stacktrace_ops *ops, void *data,
28 unsigned long *end, int *graph);
31 print_context_stack_bp(struct thread_info *tinfo,
32 unsigned long *stack, unsigned long bp,
33 const struct stacktrace_ops *ops, void *data,
34 unsigned long *end, int *graph);
36 /* Generic stack tracer with callbacks */
38 struct stacktrace_ops {
39 void (*warning)(void *data, char *msg);
40 /* msg must contain %s for the symbol */
41 void (*warning_symbol)(void *data, char *msg, unsigned long symbol);
42 void (*address)(void *data, unsigned long address, int reliable);
43 /* On negative return stop dumping */
44 int (*stack)(void *data, char *name);
45 walk_stack_t walk_stack;
48 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
49 unsigned long *stack, unsigned long bp,
50 const struct stacktrace_ops *ops, void *data);
53 #define STACKSLOTS_PER_LINE 8
54 #define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :)
56 #define STACKSLOTS_PER_LINE 4
57 #define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
61 show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
62 unsigned long *stack, unsigned long bp, char *log_lvl);
65 show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
66 unsigned long *sp, unsigned long bp, char *log_lvl);
68 extern unsigned int code_bytes;
70 /* The form of the top of the frame on the stack */
72 struct stack_frame *next_frame;
73 unsigned long return_address;
76 struct stack_frame_ia32 {
81 static inline unsigned long caller_frame_pointer(void)
83 struct stack_frame *frame;
87 #ifdef CONFIG_FRAME_POINTER
88 frame = frame->next_frame;
91 return (unsigned long)frame;
94 #endif /* _ASM_X86_STACKTRACE_H */