added print_registers() to context

This commit is contained in:
2020-01-24 14:43:43 +04:00
parent 59cf6fee85
commit f48bf41cbb
3 changed files with 17 additions and 0 deletions
+14
View File
@@ -19,6 +19,8 @@
#include "dwarf_operations.h" #include "dwarf_operations.h"
extern SC_LogBase* logger; extern SC_LogBase* logger;
extern dwarf_reg_map reg_map[];
extern int regnum;
bool dwarf_value::get_int(int64_t& v) bool dwarf_value::get_int(int64_t& v)
{ {
@@ -81,6 +83,18 @@ bool dwarf_value::get_generic(uint64_t& v)
return true; return true;
} }
void __pst_context::print_registers(int from, int to)
{
for(int i = from; i < regnum && i <= to; ++i) {
unw_word_t regval;
if(!unw_get_reg(curr_frame, reg_map[i].regno, &regval)) {
log(SEVERITY_DEBUG, "%s = %#lX%s", reg_map[i].regname, regval, i != to ? "," : "");
} else {
log(SEVERITY_DEBUG, "%s = <undef>", reg_map[i].regname);
}
}
}
bool __pst_context::print(const char* fmt, ...) bool __pst_context::print(const char* fmt, ...)
{ {
bool nret = true; bool nret = true;
+1
View File
@@ -23,6 +23,7 @@ typedef struct __pst_context {
bool print(const char* fmt, ...); bool print(const char* fmt, ...);
void log(SC_LogSeverity severity, const char*fmt, ...); 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); 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);
ucontext_t* hcontext; // context of signal handler ucontext_t* hcontext; // context of signal handler
unw_context_t context; // context of stack trace unw_context_t context; // context of stack trace
+2
View File
@@ -85,6 +85,8 @@ dwarf_reg_map reg_map[] = {
{0x1f, "XMM14", DW_OP_breg31}, {0x1f, "XMM14", DW_OP_breg31},
}; };
int regnum = sizeof(reg_map) / sizeof(dwarf_reg_map);
// not implemented operations // not implemented operations
bool dw_op_notimpl(dwarf_stack* stack, const dwarf_op_map* map, Dwarf_Word op1, Dwarf_Word op2) bool dw_op_notimpl(dwarf_stack* stack, const dwarf_op_map* map, Dwarf_Word op1, Dwarf_Word op2)
{ {