]>
Commit | Line | Data |
---|---|---|
7c7900f8 JP |
1 | #ifndef _ASM_X86_UNWIND_H |
2 | #define _ASM_X86_UNWIND_H | |
3 | ||
4 | #include <linux/sched.h> | |
5 | #include <linux/ftrace.h> | |
6 | #include <asm/ptrace.h> | |
7 | #include <asm/stacktrace.h> | |
8 | ||
9 | struct unwind_state { | |
10 | struct stack_info stack_info; | |
11 | unsigned long stack_mask; | |
12 | struct task_struct *task; | |
13 | int graph_idx; | |
af085d90 | 14 | bool error; |
7c7900f8 | 15 | #ifdef CONFIG_FRAME_POINTER |
8b5e99f0 | 16 | unsigned long *bp, *orig_sp; |
946c1911 | 17 | struct pt_regs *regs; |
7c7900f8 JP |
18 | #else |
19 | unsigned long *sp; | |
20 | #endif | |
21 | }; | |
22 | ||
23 | void __unwind_start(struct unwind_state *state, struct task_struct *task, | |
24 | struct pt_regs *regs, unsigned long *first_frame); | |
25 | ||
26 | bool unwind_next_frame(struct unwind_state *state); | |
27 | ||
cfee9edd JP |
28 | unsigned long unwind_get_return_address(struct unwind_state *state); |
29 | ||
7c7900f8 JP |
30 | static inline bool unwind_done(struct unwind_state *state) |
31 | { | |
32 | return state->stack_info.type == STACK_TYPE_UNKNOWN; | |
33 | } | |
34 | ||
35 | static inline | |
36 | void unwind_start(struct unwind_state *state, struct task_struct *task, | |
37 | struct pt_regs *regs, unsigned long *first_frame) | |
38 | { | |
39 | first_frame = first_frame ? : get_stack_pointer(task, regs); | |
40 | ||
41 | __unwind_start(state, task, regs, first_frame); | |
42 | } | |
43 | ||
af085d90 JP |
44 | static inline bool unwind_error(struct unwind_state *state) |
45 | { | |
46 | return state->error; | |
47 | } | |
48 | ||
7c7900f8 JP |
49 | #ifdef CONFIG_FRAME_POINTER |
50 | ||
51 | static inline | |
52 | unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) | |
53 | { | |
54 | if (unwind_done(state)) | |
55 | return NULL; | |
56 | ||
946c1911 JP |
57 | return state->regs ? &state->regs->ip : state->bp + 1; |
58 | } | |
59 | ||
60 | static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) | |
61 | { | |
62 | if (unwind_done(state)) | |
63 | return NULL; | |
64 | ||
65 | return state->regs; | |
7c7900f8 JP |
66 | } |
67 | ||
7c7900f8 JP |
68 | #else /* !CONFIG_FRAME_POINTER */ |
69 | ||
70 | static inline | |
71 | unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) | |
72 | { | |
73 | return NULL; | |
74 | } | |
75 | ||
946c1911 JP |
76 | static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) |
77 | { | |
78 | return NULL; | |
79 | } | |
80 | ||
7c7900f8 JP |
81 | #endif /* CONFIG_FRAME_POINTER */ |
82 | ||
83 | #endif /* _ASM_X86_UNWIND_H */ |