diff --git a/framework/common.cpp b/framework/common.cpp index 3d12f34..64a6fdc 100644 --- a/framework/common.cpp +++ b/framework/common.cpp @@ -83,6 +83,25 @@ bool dwarf_value::get_generic(uint64_t& v) return true; } +void __pst_context::print_stack(int max, uint64_t next_cfa) +{ + log(SEVERITY_DEBUG, "CFA = %#lX, NEXT_CFA = %#lX, SP = %#lX", cfa, next_cfa, sp); + buff[0] = 0; offset = 0; + int i = 0; + if(cfa > sp) { + print("Args: "); + for(; i < max && (cfa - i) > sp; ++i) { + print("#%d 0x%lX ", i, *(uint64_t*)(cfa - i)); + } + } + if((cfa - i) > next_cfa) { + print("Vars: "); + for(; i < max && (cfa - i) > next_cfa; ++i) { + print("#%d 0x%lX ", i, *(uint64_t*)(cfa - i)); + } + } +} + void __pst_context::print_registers(int from, int to) { buff[0] = 0; offset = 0; diff --git a/framework/common.h b/framework/common.h index 4f44715..2912baa 100644 --- a/framework/common.h +++ b/framework/common.h @@ -24,6 +24,7 @@ typedef struct __pst_context { void log(SC_LogSeverity severity, const char*fmt, ...); uint32_t print_expr_block(Dwarf_Op *exprs, int len, char* buff, uint32_t buff_size, Dwarf_Attribute* attr = 0); void print_registers(int from, int to); + void print_stack(int max, uint64_t next_cfa); ucontext_t* hcontext; // context of signal handler unw_context_t context; // context of stack trace