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 |
a8b7a923 | 16 | bool got_irq; |
8b5e99f0 | 17 | unsigned long *bp, *orig_sp; |
946c1911 | 18 | struct pt_regs *regs; |
6bcdf9d5 | 19 | unsigned long ip; |
7c7900f8 JP |
20 | #else |
21 | unsigned long *sp; | |
22 | #endif | |
23 | }; | |
24 | ||
25 | void __unwind_start(struct unwind_state *state, struct task_struct *task, | |
26 | struct pt_regs *regs, unsigned long *first_frame); | |
27 | ||
28 | bool unwind_next_frame(struct unwind_state *state); | |
29 | ||
cfee9edd JP |
30 | unsigned long unwind_get_return_address(struct unwind_state *state); |
31 | ||
7c7900f8 JP |
32 | static inline bool unwind_done(struct unwind_state *state) |
33 | { | |
34 | return state->stack_info.type == STACK_TYPE_UNKNOWN; | |
35 | } | |
36 | ||
37 | static inline | |
38 | void unwind_start(struct unwind_state *state, struct task_struct *task, | |
39 | struct pt_regs *regs, unsigned long *first_frame) | |
40 | { | |
41 | first_frame = first_frame ? : get_stack_pointer(task, regs); | |
42 | ||
43 | __unwind_start(state, task, regs, first_frame); | |
44 | } | |
45 | ||
af085d90 JP |
46 | static inline bool unwind_error(struct unwind_state *state) |
47 | { | |
48 | return state->error; | |
49 | } | |
50 | ||
7c7900f8 JP |
51 | #ifdef CONFIG_FRAME_POINTER |
52 | ||
53 | static inline | |
54 | unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) | |
55 | { | |
56 | if (unwind_done(state)) | |
57 | return NULL; | |
58 | ||
946c1911 JP |
59 | return state->regs ? &state->regs->ip : state->bp + 1; |
60 | } | |
61 | ||
62 | static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) | |
63 | { | |
64 | if (unwind_done(state)) | |
65 | return NULL; | |
66 | ||
67 | return state->regs; | |
7c7900f8 JP |
68 | } |
69 | ||
7c7900f8 JP |
70 | #else /* !CONFIG_FRAME_POINTER */ |
71 | ||
72 | static inline | |
73 | unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) | |
74 | { | |
75 | return NULL; | |
76 | } | |
77 | ||
946c1911 JP |
78 | static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) |
79 | { | |
80 | return NULL; | |
81 | } | |
82 | ||
7c7900f8 JP |
83 | #endif /* CONFIG_FRAME_POINTER */ |
84 | ||
85 | #endif /* _ASM_X86_UNWIND_H */ |