Changes in kernel/generic/src/debug/stacktrace.c [257ceb1:49ace23] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/debug/stacktrace.c
r257ceb1 r49ace23 27 27 */ 28 28 29 /** @addtogroup genericdebug 29 /** @addtogroup genericdebug 30 30 * @{ 31 31 */ … … 42 42 43 43 void 44 stack_trace_ ctx(stack_trace_ops_t *ops, stack_trace_context_t *ctx)44 stack_trace_fp_pc(stack_trace_ops_t *ops, uintptr_t fp, uintptr_t pc) 45 45 { 46 46 int cnt = 0; 47 47 const char *symbol; 48 48 uintptr_t offset; 49 uintptr_t fp;50 uintptr_t pc;51 49 52 while (cnt++ < STACK_FRAMES_MAX && 53 ops->stack_trace_context_validate(ctx)) { 50 while (cnt++ < STACK_FRAMES_MAX && ops->frame_pointer_validate(fp)) { 54 51 if (ops->symbol_resolve && 55 ops->symbol_resolve( ctx->pc, &symbol, &offset)) {52 ops->symbol_resolve(pc, &symbol, &offset)) { 56 53 if (offset) 57 printf("%p: %s+%" PRIp "()\n", 58 ctx->fp, symbol, offset); 54 printf("%p: %s+%" PRIp "()\n", fp, symbol, offset); 59 55 else 60 printf("%p: %s()\n", 61 ctx->fp, symbol); 56 printf("%p: %s()\n", fp, symbol); 62 57 } else { 63 printf("%p: %p()\n", ctx->fp, ctx->pc);58 printf("%p: %p()\n", fp, pc); 64 59 } 65 if (!ops->return_address_get( ctx, &pc))60 if (!ops->return_address_get(fp, &pc)) 66 61 break; 67 if (!ops->frame_pointer_prev( ctx, &fp))62 if (!ops->frame_pointer_prev(fp, &fp)) 68 63 break; 69 ctx->fp = fp;70 ctx->pc = pc;71 64 } 72 65 } … … 74 67 void stack_trace(void) 75 68 { 76 stack_trace_context_t ctx = { 77 .fp = frame_pointer_get(), 78 .pc = program_counter_get(), 79 .istate = NULL 80 }; 81 82 stack_trace_ctx(&kst_ops, &ctx); 69 stack_trace_fp_pc(&kst_ops, frame_pointer_get(), program_counter_get()); 83 70 84 71 /* … … 91 78 void stack_trace_istate(istate_t *istate) 92 79 { 93 stack_trace_context_t ctx = {94 .fp = istate_get_fp(istate),95 .pc = istate_get_pc(istate),96 .istate = istate97 };98 99 80 if (istate_from_uspace(istate)) 100 stack_trace_ctx(&ust_ops, &ctx); 81 stack_trace_fp_pc(&ust_ops, istate_get_fp(istate), 82 istate_get_pc(istate)); 101 83 else 102 stack_trace_ctx(&kst_ops, &ctx); 84 stack_trace_fp_pc(&kst_ops, istate_get_fp(istate), 85 istate_get_pc(istate)); 103 86 } 104 87 105 static bool 106 kernel_symbol_resolve(uintptr_t addr, const char **sp, uintptr_t *op) 88 static bool kernel_symbol_resolve(uintptr_t addr, const char **sp, uintptr_t *op) 107 89 { 108 90 return (symtab_name_lookup(addr, sp, op) == 0); … … 110 92 111 93 stack_trace_ops_t kst_ops = { 112 . stack_trace_context_validate = kernel_stack_trace_context_validate,94 .frame_pointer_validate = kernel_frame_pointer_validate, 113 95 .frame_pointer_prev = kernel_frame_pointer_prev, 114 96 .return_address_get = kernel_return_address_get, … … 117 99 118 100 stack_trace_ops_t ust_ops = { 119 . stack_trace_context_validate = uspace_stack_trace_context_validate,101 .frame_pointer_validate = uspace_frame_pointer_validate, 120 102 .frame_pointer_prev = uspace_frame_pointer_prev, 121 103 .return_address_get = uspace_return_address_get,
Note:
See TracChangeset
for help on using the changeset viewer.