]>
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> |
7b32aead | 11 | #include <asm/switch_to.h> |
c9cf4dbb | 12 | |
0741f4d2 CE |
13 | extern int kstack_depth_to_print; |
14 | ||
61c1917f FW |
15 | struct thread_info; |
16 | struct stacktrace_ops; | |
17 | ||
da01e18a | 18 | typedef unsigned long (*walk_stack_t)(struct task_struct *task, |
61c1917f FW |
19 | unsigned long *stack, |
20 | unsigned long bp, | |
21 | const struct stacktrace_ops *ops, | |
22 | void *data, | |
23 | unsigned long *end, | |
24 | int *graph); | |
25 | ||
26 | extern unsigned long | |
da01e18a | 27 | print_context_stack(struct task_struct *task, |
61c1917f FW |
28 | unsigned long *stack, unsigned long bp, |
29 | const struct stacktrace_ops *ops, void *data, | |
30 | unsigned long *end, int *graph); | |
31 | ||
06d65bda | 32 | extern unsigned long |
da01e18a | 33 | print_context_stack_bp(struct task_struct *task, |
06d65bda FW |
34 | unsigned long *stack, unsigned long bp, |
35 | const struct stacktrace_ops *ops, void *data, | |
36 | unsigned long *end, int *graph); | |
37 | ||
c0b766f1 AK |
38 | /* Generic stack tracer with callbacks */ |
39 | ||
40 | struct stacktrace_ops { | |
568b329a | 41 | int (*address)(void *data, unsigned long address, int reliable); |
c0b766f1 AK |
42 | /* On negative return stop dumping */ |
43 | int (*stack)(void *data, char *name); | |
61c1917f | 44 | walk_stack_t walk_stack; |
c0b766f1 AK |
45 | }; |
46 | ||
bc850d6b | 47 | void dump_trace(struct task_struct *tsk, struct pt_regs *regs, |
e8e999cf | 48 | unsigned long *stack, unsigned long bp, |
9689ba8a | 49 | const struct stacktrace_ops *ops, void *data); |
c0b766f1 | 50 | |
c9cf4dbb FW |
51 | #ifdef CONFIG_X86_32 |
52 | #define STACKSLOTS_PER_LINE 8 | |
c9cf4dbb FW |
53 | #else |
54 | #define STACKSLOTS_PER_LINE 4 | |
c9cf4dbb FW |
55 | #endif |
56 | ||
9c0729dc | 57 | #ifdef CONFIG_FRAME_POINTER |
4b8afafb JP |
58 | static inline unsigned long * |
59 | get_frame_pointer(struct task_struct *task, struct pt_regs *regs) | |
9c0729dc | 60 | { |
9c0729dc | 61 | if (regs) |
4b8afafb | 62 | return (unsigned long *)regs->bp; |
9c0729dc | 63 | |
4b8afafb JP |
64 | if (!task || task == current) |
65 | return __builtin_frame_address(0); | |
9c0729dc | 66 | |
4b8afafb | 67 | return (unsigned long *)((struct inactive_task_frame *)task->thread.sp)->bp; |
9c0729dc SSP |
68 | } |
69 | #else | |
4b8afafb JP |
70 | static inline unsigned long * |
71 | get_frame_pointer(struct task_struct *task, struct pt_regs *regs) | |
9c0729dc | 72 | { |
4b8afafb JP |
73 | return NULL; |
74 | } | |
75 | #endif /* CONFIG_FRAME_POINTER */ | |
76 | ||
77 | static inline unsigned long * | |
78 | get_stack_pointer(struct task_struct *task, struct pt_regs *regs) | |
79 | { | |
80 | if (regs) | |
81 | return (unsigned long *)kernel_stack_pointer(regs); | |
82 | ||
83 | if (!task || task == current) | |
84 | return __builtin_frame_address(0); | |
85 | ||
86 | return (unsigned long *)task->thread.sp; | |
9c0729dc | 87 | } |
9c0729dc | 88 | |
c9cf4dbb FW |
89 | extern void |
90 | show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, | |
e8e999cf | 91 | unsigned long *stack, unsigned long bp, char *log_lvl); |
c9cf4dbb FW |
92 | |
93 | extern void | |
94 | show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, | |
e8e999cf | 95 | unsigned long *sp, unsigned long bp, char *log_lvl); |
c9cf4dbb FW |
96 | |
97 | extern unsigned int code_bytes; | |
98 | ||
99 | /* The form of the top of the frame on the stack */ | |
100 | struct stack_frame { | |
101 | struct stack_frame *next_frame; | |
102 | unsigned long return_address; | |
103 | }; | |
104 | ||
105 | struct stack_frame_ia32 { | |
106 | u32 next_frame; | |
107 | u32 return_address; | |
108 | }; | |
109 | ||
b0f82b81 | 110 | static inline unsigned long caller_frame_pointer(void) |
c9cf4dbb FW |
111 | { |
112 | struct stack_frame *frame; | |
113 | ||
4b8afafb | 114 | frame = __builtin_frame_address(0); |
c9cf4dbb FW |
115 | |
116 | #ifdef CONFIG_FRAME_POINTER | |
b0f82b81 | 117 | frame = frame->next_frame; |
c9cf4dbb FW |
118 | #endif |
119 | ||
120 | return (unsigned long)frame; | |
121 | } | |
122 | ||
1965aae3 | 123 | #endif /* _ASM_X86_STACKTRACE_H */ |