|
| 1 | +/* |
| 2 | + * Copyright (C) 1991, 1992 Linus Torvalds |
| 3 | + * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs |
| 4 | + */ |
| 5 | + |
1 | 6 | #ifndef _ASM_X86_STACKTRACE_H |
2 | 7 | #define _ASM_X86_STACKTRACE_H |
3 | 8 |
|
| 9 | +#include <linux/uaccess.h> |
| 10 | + |
4 | 11 | extern int kstack_depth_to_print; |
5 | 12 |
|
6 | 13 | struct thread_info; |
@@ -42,4 +49,49 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, |
42 | 49 | unsigned long *stack, unsigned long bp, |
43 | 50 | const struct stacktrace_ops *ops, void *data); |
44 | 51 |
|
| 52 | +#ifdef CONFIG_X86_32 |
| 53 | +#define STACKSLOTS_PER_LINE 8 |
| 54 | +#define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :) |
| 55 | +#else |
| 56 | +#define STACKSLOTS_PER_LINE 4 |
| 57 | +#define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :) |
| 58 | +#endif |
| 59 | + |
| 60 | +extern void |
| 61 | +show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, |
| 62 | + unsigned long *stack, unsigned long bp, char *log_lvl); |
| 63 | + |
| 64 | +extern void |
| 65 | +show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, |
| 66 | + unsigned long *sp, unsigned long bp, char *log_lvl); |
| 67 | + |
| 68 | +extern unsigned int code_bytes; |
| 69 | + |
| 70 | +/* The form of the top of the frame on the stack */ |
| 71 | +struct stack_frame { |
| 72 | + struct stack_frame *next_frame; |
| 73 | + unsigned long return_address; |
| 74 | +}; |
| 75 | + |
| 76 | +struct stack_frame_ia32 { |
| 77 | + u32 next_frame; |
| 78 | + u32 return_address; |
| 79 | +}; |
| 80 | + |
| 81 | +static inline unsigned long rewind_frame_pointer(int n) |
| 82 | +{ |
| 83 | + struct stack_frame *frame; |
| 84 | + |
| 85 | + get_bp(frame); |
| 86 | + |
| 87 | +#ifdef CONFIG_FRAME_POINTER |
| 88 | + while (n--) { |
| 89 | + if (probe_kernel_address(&frame->next_frame, frame)) |
| 90 | + break; |
| 91 | + } |
| 92 | +#endif |
| 93 | + |
| 94 | + return (unsigned long)frame; |
| 95 | +} |
| 96 | + |
45 | 97 | #endif /* _ASM_X86_STACKTRACE_H */ |
0 commit comments