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