Lines Matching refs:state

14 unsigned long unwind_get_return_address(struct unwind_state *state)
16 if (unwind_done(state))
19 return __kernel_text_address(state->ip) ? state->ip : 0;
23 unsigned long *unwind_get_return_address_ptr(struct unwind_state *state)
25 if (unwind_done(state))
28 return state->regs ? &state->regs->ip : state->bp + 1;
31 static void unwind_dump(struct unwind_state *state)
45 state->stack_info.type, state->stack_info.next_sp,
46 state->stack_mask, state->graph_idx);
48 for (sp = PTR_ALIGN(state->orig_sp, sizeof(long)); sp;
50 if (get_stack_info(sp, state->task, &stack_info, &visit_mask))
80 static inline unsigned long *last_frame(struct unwind_state *state)
82 return (unsigned long *)task_pt_regs(state->task) - 2;
85 static bool is_last_frame(struct unwind_state *state)
87 return state->bp == last_frame(state);
96 static inline unsigned long *last_aligned_frame(struct unwind_state *state)
98 return last_frame(state) - GCC_REALIGN_WORDS;
101 static bool is_last_aligned_frame(struct unwind_state *state)
103 unsigned long *last_bp = last_frame(state);
104 unsigned long *aligned_bp = last_aligned_frame(state);
129 return (state->bp == aligned_bp && *(aligned_bp + 1) == *(last_bp + 1));
132 static bool is_last_ftrace_frame(struct unwind_state *state)
134 unsigned long *last_bp = last_frame(state);
149 return (state->bp == last_ftrace_bp &&
150 *state->bp == *(state->bp + 2) &&
151 *(state->bp + 1) == *(state->bp + 4));
154 static bool is_last_task_frame(struct unwind_state *state)
156 return is_last_frame(state) || is_last_aligned_frame(state) ||
157 is_last_ftrace_frame(state);
196 static bool update_stack_state(struct unwind_state *state,
199 struct stack_info *info = &state->stack_info;
205 if (state->regs)
206 prev_frame_end = (void *)state->regs + sizeof(*state->regs);
208 prev_frame_end = (void *)state->bp + FRAME_HEADER_SIZE;
215 state->got_irq = true;
229 if (get_stack_info(info->next_sp, state->task, info,
230 &state->stack_mask))
234 if (state->orig_sp && state->stack_info.type == prev_type &&
238 /* Move state to the next frame: */
240 state->regs = regs;
241 state->bp = NULL;
243 state->bp = next_bp;
244 state->regs = NULL;
248 if (state->regs && user_mode(state->regs))
249 state->ip = 0;
251 addr_p = unwind_get_return_address_ptr(state);
252 addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
253 state->ip = unwind_recover_ret_addr(state, addr, addr_p);
257 if (!state->orig_sp)
258 state->orig_sp = frame;
264 bool unwind_next_frame(struct unwind_state *state)
269 if (unwind_done(state))
273 if (state->regs && user_mode(state->regs))
276 if (is_last_task_frame(state)) {
277 regs = task_pt_regs(state->task);
298 state->regs = regs;
299 state->bp = NULL;
300 state->ip = 0;
305 if (state->next_bp) {
306 next_bp = state->next_bp;
307 state->next_bp = NULL;
308 } else if (state->regs) {
309 next_bp = (unsigned long *)state->regs->bp;
311 next_bp = (unsigned long *)READ_ONCE_TASK_STACK(state->task, *state->bp);
315 if (!update_stack_state(state, next_bp))
321 state->error = true;
330 if (state->task != current)
337 if (state->got_irq && in_entry_code(state->ip))
339 if (state->regs &&
340 state->regs->sp >= (unsigned long)last_aligned_frame(state) &&
341 state->regs->sp < (unsigned long)task_pt_regs(state->task))
351 if (state->task != current)
354 if (state->regs) {
357 state->regs, state->task->comm,
358 state->task->pid, next_bp);
359 unwind_dump(state);
363 state->bp, state->task->comm,
364 state->task->pid, next_bp);
365 unwind_dump(state);
368 state->stack_info.type = STACK_TYPE_UNKNOWN;
373 void __unwind_start(struct unwind_state *state, struct task_struct *task,
378 memset(state, 0, sizeof(*state));
379 state->task = task;
380 state->got_irq = (regs);
384 state->stack_info.type = STACK_TYPE_UNKNOWN;
400 state->next_bp = bp;
405 get_stack_info(bp, state->task, &state->stack_info,
406 &state->stack_mask);
407 update_stack_state(state, bp);
414 while (!unwind_done(state) &&
415 (!on_stack(&state->stack_info, first_frame, sizeof(long)) ||
416 (state->next_bp == NULL && state->bp < first_frame)))
417 unwind_next_frame(state);