Neil Horman | 878719e | 2008-10-23 10:40:06 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 3 | * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs |
| 4 | */ |
| 5 | |
| 6 | #ifndef DUMPSTACK_H |
| 7 | #define DUMPSTACK_H |
| 8 | |
| 9 | #ifdef CONFIG_X86_32 |
| 10 | #define STACKSLOTS_PER_LINE 8 |
| 11 | #define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :) |
| 12 | #else |
| 13 | #define STACKSLOTS_PER_LINE 4 |
| 14 | #define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :) |
| 15 | #endif |
| 16 | |
Frederic Weisbecker | ab285f2 | 2010-04-08 14:05:50 +0200 | [diff] [blame] | 17 | #include <linux/uaccess.h> |
| 18 | |
Neil Horman | 878719e | 2008-10-23 10:40:06 -0400 | [diff] [blame] | 19 | extern void |
| 20 | show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, |
| 21 | unsigned long *stack, unsigned long bp, char *log_lvl); |
| 22 | |
| 23 | extern void |
| 24 | show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, |
| 25 | unsigned long *sp, unsigned long bp, char *log_lvl); |
| 26 | |
| 27 | extern unsigned int code_bytes; |
Neil Horman | 878719e | 2008-10-23 10:40:06 -0400 | [diff] [blame] | 28 | |
| 29 | /* The form of the top of the frame on the stack */ |
| 30 | struct stack_frame { |
| 31 | struct stack_frame *next_frame; |
| 32 | unsigned long return_address; |
| 33 | }; |
Frederic Weisbecker | 5331d7b | 2010-03-04 21:15:56 +0100 | [diff] [blame] | 34 | |
Torok Edwin | 257ef9d | 2010-03-17 12:07:16 +0200 | [diff] [blame] | 35 | struct stack_frame_ia32 { |
| 36 | u32 next_frame; |
| 37 | u32 return_address; |
| 38 | }; |
| 39 | |
Frederic Weisbecker | 5331d7b | 2010-03-04 21:15:56 +0100 | [diff] [blame] | 40 | static inline unsigned long rewind_frame_pointer(int n) |
| 41 | { |
| 42 | struct stack_frame *frame; |
| 43 | |
| 44 | get_bp(frame); |
| 45 | |
| 46 | #ifdef CONFIG_FRAME_POINTER |
Frederic Weisbecker | ab285f2 | 2010-04-08 14:05:50 +0200 | [diff] [blame] | 47 | while (n--) { |
| 48 | if (probe_kernel_address(&frame->next_frame, frame)) |
| 49 | break; |
| 50 | } |
Neil Horman | 878719e | 2008-10-23 10:40:06 -0400 | [diff] [blame] | 51 | #endif |
Frederic Weisbecker | 5331d7b | 2010-03-04 21:15:56 +0100 | [diff] [blame] | 52 | |
| 53 | return (unsigned long)frame; |
| 54 | } |
| 55 | |
| 56 | #endif /* DUMPSTACK_H */ |