diff --git a/framework/sysutils.cpp b/framework/sysutils.cpp index e81c2a4..a02cc17 100644 --- a/framework/sysutils.cpp +++ b/framework/sysutils.cpp @@ -599,6 +599,7 @@ bool __pst_function::handle_dwarf(Dwarf_Die* d) dwarf_diename(d), lowpc, highpc, pc - ctx->base_addr, info.start_ip, info.start_ip - ctx->base_addr); ctx->print_registers(0x0, 0x10); ctx->log(SEVERITY_INFO, "Function %s(...): CFA: %#lX %s", dwarf_diename(d), parent ? parent->sp : 0, ctx->buff); + ctx->log(SEVERITY_INFO, "Function %s(...): %s", dwarf_diename(d), ctx->buff); // determine function's stack frame base attr = dwarf_attr(die, DW_AT_frame_base, &attr_mem); @@ -799,6 +800,7 @@ bool __pst_handler::get_frame(pst_function* fun) if(st.calc_expression(cfa_ops, cfa_nops, NULL) && st.get_value(v)) { //ctx.sp = v; ctx.log(SEVERITY_INFO, "Function %s(...): CFA expression: %s ==> %#lX", fun->name.c_str(), str, v); + fun->cfa = v; } else { ctx.log(SEVERITY_ERROR, "Failed to calculate CFA expression"); } @@ -921,13 +923,14 @@ bool __pst_handler::handle_dwarf() ctx.log(SEVERITY_INFO, "Function %s(...): module name: %s, base address: %p, CFA: %#lX", fun->name.c_str(), info.dli_fname, info.dli_fbase, fun->parent ? fun->parent->sp : 0); ctx.curr_frame = &fun->cursor; ctx.sp = fun->sp; - ctx.cfa = fun->parent ? fun->parent->sp : 0; + //ctx.cfa = fun->parent ? fun->parent->sp : 0; if(fun->parent) { ctx.next_frame = &fun->parent->cursor; } else { ctx.next_frame = 0; } get_frame(fun); + ctx.cfa = fun->cfa; ctx.curr_frame = &fun->cursor; ctx.next_frame = NULL; diff --git a/framework/sysutils.h b/framework/sysutils.h index bdebca1..d1de3d5 100644 --- a/framework/sysutils.h +++ b/framework/sysutils.h @@ -88,6 +88,7 @@ typedef struct __pst_function : public SC_ListNode { memcpy(&cursor, _ctx->curr_frame, sizeof(cursor)); parent = _parent; sp = 0; + cfa = 0; } ~__pst_function() { @@ -112,6 +113,7 @@ typedef struct __pst_function : public SC_ListNode { SC_ListHead params; // function's parameters unw_word_t pc; // address between lowpc & highpc (plus base address offset). actually, currently executed command unw_word_t sp; // SP register in function's frame + unw_word_t cfa; unw_cursor_t cursor; // copy of stack state of the function int line; // line in code where function is defined std::string file; // file name (DWARF Compilation Unit) where function is defined