Lines Matching +full:- +full:state

1 // SPDX-License-Identifier: GPL-2.0
11 unsigned long unwind_get_return_address(struct unwind_state *state) in unwind_get_return_address() argument
14 if (unwind_done(state)) in unwind_get_return_address()
16 else if (state->type) in unwind_get_return_address()
17 return state->pc; in unwind_get_return_address()
18 else if (state->first) in unwind_get_return_address()
19 return state->pc; in unwind_get_return_address()
21 return *(unsigned long *)(state->sp); in unwind_get_return_address()
26 static bool unwind_by_guess(struct unwind_state *state) in unwind_by_guess() argument
28 struct stack_info *info = &state->stack_info; in unwind_by_guess()
31 for (state->sp += sizeof(unsigned long); in unwind_by_guess()
32 state->sp < info->end; in unwind_by_guess()
33 state->sp += sizeof(unsigned long)) { in unwind_by_guess()
34 addr = *(unsigned long *)(state->sp); in unwind_by_guess()
42 static bool unwind_by_prologue(struct unwind_state *state) in unwind_by_prologue() argument
44 struct stack_info *info = &state->stack_info; in unwind_by_prologue()
46 long frame_ra = -1; in unwind_by_prologue()
48 unsigned long size, offset, pc = state->pc; in unwind_by_prologue()
50 if (state->sp >= info->end || state->sp < info->begin) in unwind_by_prologue()
56 ip = (union loongarch_instruction *)(pc - offset); in unwind_by_prologue()
61 frame_size = (1 << 12) - ip->reg2i12_format.immediate; in unwind_by_prologue()
69 if (state->first) in unwind_by_prologue()
77 frame_ra = ip->reg2i12_format.immediate; in unwind_by_prologue()
86 if (state->first) { in unwind_by_prologue()
87 state->sp = state->sp + frame_size; in unwind_by_prologue()
93 if (state->first) in unwind_by_prologue()
94 state->first = false; in unwind_by_prologue()
96 state->pc = *(unsigned long *)(state->sp + frame_ra); in unwind_by_prologue()
97 state->sp = state->sp + frame_size; in unwind_by_prologue()
98 return !!__kernel_text_address(state->pc); in unwind_by_prologue()
101 state->first = false; in unwind_by_prologue()
102 if (state->pc == state->ra) in unwind_by_prologue()
105 state->pc = state->ra; in unwind_by_prologue()
107 return !!__kernel_text_address(state->ra); in unwind_by_prologue()
110 void unwind_start(struct unwind_state *state, struct task_struct *task, in unwind_start() argument
113 memset(state, 0, sizeof(*state)); in unwind_start()
115 if (regs && __kernel_text_address(regs->csr_era)) { in unwind_start()
116 state->pc = regs->csr_era; in unwind_start()
117 state->sp = regs->regs[3]; in unwind_start()
118 state->ra = regs->regs[1]; in unwind_start()
119 state->type = UNWINDER_PROLOGUE; in unwind_start()
122 state->task = task; in unwind_start()
123 state->first = true; in unwind_start()
125 get_stack_info(state->sp, state->task, &state->stack_info); in unwind_start()
127 if (!unwind_done(state) && !__kernel_text_address(state->pc)) in unwind_start()
128 unwind_next_frame(state); in unwind_start()
132 bool unwind_next_frame(struct unwind_state *state) in unwind_next_frame() argument
134 struct stack_info *info = &state->stack_info; in unwind_next_frame()
138 if (unwind_done(state)) in unwind_next_frame()
142 switch (state->type) { in unwind_next_frame()
144 state->first = false; in unwind_next_frame()
145 if (unwind_by_guess(state)) in unwind_next_frame()
150 if (unwind_by_prologue(state)) in unwind_next_frame()
153 if (info->type == STACK_TYPE_IRQ && in unwind_next_frame()
154 info->end == state->sp) { in unwind_next_frame()
155 regs = (struct pt_regs *)info->next_sp; in unwind_next_frame()
156 pc = regs->csr_era; in unwind_next_frame()
161 state->pc = pc; in unwind_next_frame()
162 state->sp = regs->regs[3]; in unwind_next_frame()
163 state->ra = regs->regs[1]; in unwind_next_frame()
164 state->first = true; in unwind_next_frame()
165 get_stack_info(state->sp, state->task, info); in unwind_next_frame()
171 state->sp = info->next_sp; in unwind_next_frame()
173 } while (!get_stack_info(state->sp, state->task, info)); in unwind_next_frame()