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