Commit | Line | Data |
---|---|---|
c9cf4dbb FW |
1 | /* |
2 | * Copyright (C) 1991, 1992 Linus Torvalds | |
3 | * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs | |
4 | */ | |
5 | ||
1965aae3 PA |
6 | #ifndef _ASM_X86_STACKTRACE_H |
7 | #define _ASM_X86_STACKTRACE_H | |
c0b766f1 | 8 | |
c9cf4dbb | 9 | #include <linux/uaccess.h> |
9c0729dc | 10 | #include <linux/ptrace.h> |
c9cf4dbb | 11 | |
0741f4d2 CE |
12 | extern int kstack_depth_to_print; |
13 | ||
61c1917f FW |
14 | struct thread_info; |
15 | struct stacktrace_ops; | |
16 | ||
17 | typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo, | |
18 | unsigned long *stack, | |
19 | unsigned long bp, | |
20 | const struct stacktrace_ops *ops, | |
21 | void *data, | |
22 | unsigned long *end, | |
23 | int *graph); | |
24 | ||
25 | extern unsigned long | |
26 | print_context_stack(struct thread_info *tinfo, | |
27 | unsigned long *stack, unsigned long bp, | |
28 | const struct stacktrace_ops *ops, void *data, | |
29 | unsigned long *end, int *graph); | |
30 | ||
06d65bda FW |
31 | extern unsigned long |
32 | print_context_stack_bp(struct thread_info *tinfo, | |
33 | unsigned long *stack, unsigned long bp, | |
34 | const struct stacktrace_ops *ops, void *data, | |
35 | unsigned long *end, int *graph); | |
36 | ||
c0b766f1 AK |
37 | /* Generic stack tracer with callbacks */ |
38 | ||
39 | struct stacktrace_ops { | |
40 | void (*warning)(void *data, char *msg); | |
41 | /* msg must contain %s for the symbol */ | |
42 | void (*warning_symbol)(void *data, char *msg, unsigned long symbol); | |
bc850d6b | 43 | void (*address)(void *data, unsigned long address, int reliable); |
c0b766f1 AK |
44 | /* On negative return stop dumping */ |
45 | int (*stack)(void *data, char *name); | |
61c1917f | 46 | walk_stack_t walk_stack; |
c0b766f1 AK |
47 | }; |
48 | ||
bc850d6b | 49 | void dump_trace(struct task_struct *tsk, struct pt_regs *regs, |
9c0729dc | 50 | unsigned long *stack, |
9689ba8a | 51 | const struct stacktrace_ops *ops, void *data); |
c0b766f1 | 52 | |
c9cf4dbb FW |
53 | #ifdef CONFIG_X86_32 |
54 | #define STACKSLOTS_PER_LINE 8 | |
55 | #define get_bp(bp) asm("movl %%ebp, %0" : "=r" (bp) :) | |
56 | #else | |
57 | #define STACKSLOTS_PER_LINE 4 | |
58 | #define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :) | |
59 | #endif | |
60 | ||
9c0729dc SSP |
61 | #ifdef CONFIG_FRAME_POINTER |
62 | static inline unsigned long | |
63 | stack_frame(struct task_struct *task, struct pt_regs *regs) | |
64 | { | |
65 | unsigned long bp; | |
66 | ||
67 | if (regs) | |
68 | return regs->bp; | |
69 | ||
70 | if (task == current) { | |
71 | /* Grab bp right from our regs */ | |
72 | get_bp(bp); | |
73 | return bp; | |
74 | } | |
75 | ||
76 | /* bp is the last reg pushed by switch_to */ | |
77 | return *(unsigned long *)task->thread.sp; | |
78 | } | |
79 | #else | |
80 | static inline unsigned long | |
81 | stack_frame(struct task_struct *task, struct pt_regs *regs) | |
82 | { | |
83 | return 0; | |
84 | } | |
85 | #endif | |
86 | ||
c9cf4dbb FW |
87 | extern void |
88 | show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, | |
9c0729dc | 89 | unsigned long *stack, char *log_lvl); |
c9cf4dbb FW |
90 | |
91 | extern void | |
92 | show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, | |
9c0729dc | 93 | unsigned long *sp, char *log_lvl); |
c9cf4dbb FW |
94 | |
95 | extern unsigned int code_bytes; | |
96 | ||
97 | /* The form of the top of the frame on the stack */ | |
98 | struct stack_frame { | |
99 | struct stack_frame *next_frame; | |
100 | unsigned long return_address; | |
101 | }; | |
102 | ||
103 | struct stack_frame_ia32 { | |
104 | u32 next_frame; | |
105 | u32 return_address; | |
106 | }; | |
107 | ||
b0f82b81 | 108 | static inline unsigned long caller_frame_pointer(void) |
c9cf4dbb FW |
109 | { |
110 | struct stack_frame *frame; | |
111 | ||
112 | get_bp(frame); | |
113 | ||
114 | #ifdef CONFIG_FRAME_POINTER | |
b0f82b81 | 115 | frame = frame->next_frame; |
c9cf4dbb FW |
116 | #endif |
117 | ||
118 | return (unsigned long)frame; | |
119 | } | |
120 | ||
1965aae3 | 121 | #endif /* _ASM_X86_STACKTRACE_H */ |