Changes in kernel/arch/mips32/src/debug/stacktrace.c [76e1121f:63bdde6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/debug/stacktrace.c
r76e1121f r63bdde6 33 33 */ 34 34 35 /*36 * This stack tracing code is based on the suggested algorithm described on page37 * 3-27 and 3-28 of:38 *39 * SYSTEM V40 * APPLICATION BINARY INTERFACE41 *42 * MIPS RISC Processor43 * Supplement44 * 3rd Edition45 *46 * Unfortunately, GCC generates code which is not entirely compliant with this47 * method. For example, it places the "jr ra" instruction quite arbitrarily in48 * the middle of the function which makes the original algorithm unapplicable.49 *50 * We deal with this problem by simply not using those parts of the algorithm51 * that rely on the "jr ra" instruction occurring in the last basic block of a52 * function, which gives us still usable, but less reliable stack tracer. The53 * unreliability stems from the fact that under some circumstances it can become54 * confused and produce incorrect or incomplete stack trace. We apply extra55 * sanity checks so that the algorithm is still safe and should not crash the56 * system.57 *58 * Even though not perfect, our solution is pretty lightweight, especially when59 * compared with a prospective alternative solution based on additional60 * debugging information stored directly in the kernel image.61 */62 63 35 #include <stacktrace.h> 64 36 #include <syscall/copy.h> … … 124 96 extern char ktext_end; 125 97 126 static bool bounds_check(uintptr_t pc)127 {128 return (pc >= (uintptr_t) &ktext_start) &&129 (pc < (uintptr_t) &ktext_end);130 }131 132 98 static bool 133 99 scan(stack_trace_context_t *ctx, uintptr_t *prev_fp, uintptr_t *prev_ra) … … 140 106 do { 141 107 inst--; 142 if (!bounds_check((uintptr_t) inst))143 return false;144 108 #if 0 145 109 /* … … 216 180 return false; 217 181 /* too big offsets are suspicious */ 218 if ( (size_t) offset > sizeof(istate_t))182 if (offset > 32 * 4) 219 183 return false; 220 184 … … 243 207 { 244 208 return !((ctx->fp == 0) || ((ctx->fp % 8) != 0) || 245 (ctx->pc % 4 != 0) || !bounds_check(ctx->pc)); 209 (ctx->pc % 4 != 0) || (ctx->pc < (uintptr_t) &ktext_start) || 210 (ctx->pc >= (uintptr_t) &ktext_end)); 246 211 } 247 212
Note:
See TracChangeset
for help on using the changeset viewer.