Lines Matching +full:function +full:- +full:mask

1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/lib/backtrace-clang.S
18 #define mask r7 macro
31 * Clang does not store pc or sp in function prologues so we don't know exactly
32 * where the function starts.
36 * call. Inserting a false stack frame allows us to reference the function
41 * but in cases such as calling function pointers we cannot. In this case,
42 * default to using the lr. This will be some address in the function, but will
43 * not be the function start.
45 * Unfortunately due to the stack frame layout we can't dump r0 - r3, but these
52 * optionally saved caller registers (r4 - r10)
53 * optionally saved arguments (r0 - r3)
60 * stmfd sp!, {r0 - r3} (optional)
77 * To print locals we must know where the function start is. If we read the
78 * function prologue opcodes we can determine which variables are stored in the
81 * To find the function start of dump_stack we can look at the stored LR of
90 * {[R4-R10]} |
91 * {[R0-R3] } | show_stack:
95 * {[R4-R10]}
96 * {[R0-R3] }
99 stmfd sp!, {r4 - r9, fp, lr} @ Save an extra register
104 tst r1, #0x10 @ 26 or 32-bit mode?
105 moveq mask, #0xfc000003
106 movne mask, #0 @ mask for 32-bit
112 for_each_frame: tst frame, mask @ Check for address exceptions
117 * function.
120 * address within the current considered function, but it is not the function
121 * start. This value gets updated to be the function start later if it is
127 teq sv_fp, mask @ make sure next frame exists
131 * sv_lr is the lr from the function that called the current function. This is
132 * a pointer to a code address in the current function's caller. sv_lr-4 is
133 * the instruction used to call the current function.
135 * This sv_lr can be used to calculate the function start if the function was
136 * called using a bl instruction. If the function start can be recovered sv_pc
137 * is overwritten with the function start.
139 * If the current function was called using a function pointer we cannot
140 * recover the function start and instead continue with sv_pc as an arbitrary
141 * value within the current function. If this is the case we cannot print
142 * registers for the current function, but the stacktrace is still printed
147 1004: ldr r0, [sv_lr, #-4] @ get call instruction
152 and r0, #0xffffff @ get call offset 24-bit int
156 add sv_pc, sv_pc, #-4 @ get call instruction address
158 add sv_pc, sv_pc, r0, lsl #2@ find function start
162 bic sv_pc, sv_pc, mask @ mask PC/LR for the mode
165 * Print the function (sv_pc) and where it was called from (sv_lr).
171 bic r1, r1, mask @ mask PC/LR for the mode
176 * Test if the function start is a stmfd instruction to determine which
177 * registers were stored in the function prologue.
179 * If we could not recover the sv_pc because we were called through a function
214 no_frame: ldmfd sp!, {r4 - r9, fp, pc}