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