#ifdefined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) /* * Unwind the current stack frame and store the new register values in the * structure passed as argument. Unwinding is equivalent to a function return, * hence the new PC value rather than LR should be used for backtrace. * * With framepointer enabled, a simple function prologue looks like this: * mov ip, sp * stmdb sp!, {fp, ip, lr, pc} * sub fp, ip, #4 * * A simple function epilogue looks like this: * ldm sp, {fp, sp, pc} * * When compiled with clang, pc and sp are not pushed. A simple function * prologue looks like this when built with clang: * * stmdb {..., fp, lr} * add fp, sp, #x * sub sp, sp, #y * * A simple function epilogue looks like this when built with clang: * * sub sp, fp, #x * ldm {..., fp, pc} * * * Note that with framepointer enabled, even the leaf functions have the same * prologue and epilogue, therefore we can ignore the LR value in this case.
*/
/* * call_with_stack() is the only place we allow SP to jump from one * stack to another, with FP and SP pointing to different stacks, * skipping the FP boundary check at this point.
*/ if (pc >= (unsignedlong)&call_with_stack &&
pc < (unsignedlong)&call_with_stack_end) return 0;
/* only go to a higher address on the stack */
low = frame->sp;
high = ALIGN(low, THREAD_SIZE);
/* check current frame pointer is within bounds */ #ifdef CONFIG_CC_IS_CLANG if (fp < low + 4 || fp > high - 4) return -EINVAL; #else if (fp < low + 12 || fp > high - 4) return -EINVAL; #endif
return 0;
}
int notrace unwind_frame(struct stackframe *frame)
{ unsignedlong fp = frame->fp;
if (frame_pointer_check(frame)) return -EINVAL;
/* * When we unwind through an exception stack, include the saved PC * value into the stack trace.
*/ if (frame->ex_frame) { struct pt_regs *regs = (struct pt_regs *)frame->sp;
/* * We check that 'regs + sizeof(struct pt_regs)' (that is, * ®s[1]) does not exceed the bottom of the stack to avoid * accessing data outside the task's stack. This may happen * when frame->ex_frame is a false positive.
*/ if ((unsignedlong)®s[1] > ALIGN(frame->sp, THREAD_SIZE)) return -EINVAL;
if (regs) {
start_stack_trace(&frame, NULL, regs->ARM_fp, regs->ARM_sp,
regs->ARM_lr, regs->ARM_pc);
} elseif (task != current) { #ifdef CONFIG_SMP /* * What guarantees do we have here that 'tsk' is not * running on another CPU? For now, ignore it as we * can't guarantee we won't explode.
*/ return; #else
start_stack_trace(&frame, task, thread_saved_fp(task),
thread_saved_sp(task), 0,
thread_saved_pc(task)); #endif
} else {
here:
start_stack_trace(&frame, task,
(unsignedlong)__builtin_frame_address(0),
current_stack_pointer,
(unsignedlong)__builtin_return_address(0),
(unsignedlong)&&here); /* skip this function */ if (unwind_frame(&frame)) return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.