Frederic Weisbecker | c9cf4db | 2010-05-19 21:35:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 3 | * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs |
| 4 | */ |
| 5 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 6 | #ifndef _ASM_X86_STACKTRACE_H |
| 7 | #define _ASM_X86_STACKTRACE_H |
Andi Kleen | c0b766f | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 8 | |
Frederic Weisbecker | c9cf4db | 2010-05-19 21:35:17 +0200 | [diff] [blame] | 9 | #include <linux/uaccess.h> |
| 10 | |
Chuck Ebbert | 0741f4d | 2006-12-07 02:14:11 +0100 | [diff] [blame] | 11 | extern int kstack_depth_to_print; |
| 12 | |
Frederic Weisbecker | 61c1917 | 2009-12-17 05:40:33 +0100 | [diff] [blame] | 13 | struct thread_info; |
| 14 | struct stacktrace_ops; |
| 15 | |
| 16 | typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo, |
| 17 | unsigned long *stack, |
| 18 | unsigned long bp, |
| 19 | const struct stacktrace_ops *ops, |
| 20 | void *data, |
| 21 | unsigned long *end, |
| 22 | int *graph); |
| 23 | |
| 24 | extern unsigned long |
| 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); |
| 29 | |
Frederic Weisbecker | 06d65bd | 2009-12-17 05:40:34 +0100 | [diff] [blame] | 30 | extern unsigned long |
| 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); |
| 35 | |
Andi Kleen | c0b766f | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 36 | /* Generic stack tracer with callbacks */ |
| 37 | |
| 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); |
Arjan van de Ven | bc850d6 | 2008-01-30 13:33:07 +0100 | [diff] [blame] | 42 | void (*address)(void *data, unsigned long address, int reliable); |
Andi Kleen | c0b766f | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 43 | /* On negative return stop dumping */ |
| 44 | int (*stack)(void *data, char *name); |
Frederic Weisbecker | 61c1917 | 2009-12-17 05:40:33 +0100 | [diff] [blame] | 45 | walk_stack_t walk_stack; |
Andi Kleen | c0b766f | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 46 | }; |
| 47 | |
Arjan van de Ven | bc850d6 | 2008-01-30 13:33:07 +0100 | [diff] [blame] | 48 | void dump_trace(struct task_struct *tsk, struct pt_regs *regs, |
| 49 | unsigned long *stack, unsigned long bp, |
Jan Beulich | 9689ba8 | 2007-10-17 18:04:37 +0200 | [diff] [blame] | 50 | const struct stacktrace_ops *ops, void *data); |
Andi Kleen | c0b766f | 2006-09-26 10:52:34 +0200 | [diff] [blame] | 51 | |
Frederic Weisbecker | c9cf4db | 2010-05-19 21:35:17 +0200 | [diff] [blame] | 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 | |
Frederic Weisbecker | b0f82b8 | 2010-05-20 07:47:21 +0200 | [diff] [blame] | 81 | static inline unsigned long caller_frame_pointer(void) |
Frederic Weisbecker | c9cf4db | 2010-05-19 21:35:17 +0200 | [diff] [blame] | 82 | { |
| 83 | struct stack_frame *frame; |
| 84 | |
| 85 | get_bp(frame); |
| 86 | |
| 87 | #ifdef CONFIG_FRAME_POINTER |
Frederic Weisbecker | b0f82b8 | 2010-05-20 07:47:21 +0200 | [diff] [blame] | 88 | frame = frame->next_frame; |
Frederic Weisbecker | c9cf4db | 2010-05-19 21:35:17 +0200 | [diff] [blame] | 89 | #endif |
| 90 | |
| 91 | return (unsigned long)frame; |
| 92 | } |
| 93 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 94 | #endif /* _ASM_X86_STACKTRACE_H */ |