move register-related code to separate files, move DWARF module & handle

to pst_context, move get_frame() from pst_handler to pst_function
This commit is contained in:
2020-01-28 14:24:32 +04:00
parent f9635841f6
commit c2fdeccd34
9 changed files with 271 additions and 180 deletions
+23 -6
View File
@@ -8,16 +8,20 @@
#include "logger/log.h"
#include "linkedlist.h"
#define USE_LIBUNWIND
typedef struct __pst_context {
__pst_context(ucontext_t* hctx) : hcontext(hctx)
{
offset = 0;
buff[0] = 0;
clean_print();
base_addr = 0;
sp = 0;
cfa = 0;
curr_frame = NULL;
next_frame = NULL;
frame = NULL;
dwfl = NULL;
module = NULL;
}
bool print(const char* fmt, ...);
@@ -25,18 +29,31 @@ typedef struct __pst_context {
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);
void clean_print() {
buff[0] = 0;
offset = 0;
}
const char* get_print() {
return buff;
}
ucontext_t* hcontext; // context of signal handler
unw_context_t context; // context of stack trace
unw_cursor_t cursor;
unw_cursor_t* curr_frame; // currently examined frame of context
unw_cursor_t* next_frame; // caller frame
unw_cursor_t* curr_frame; // callee libunwind frame
unw_cursor_t* next_frame; // caller libunwind frame
Dwarf_Addr base_addr; // base address where process loaded
char buff[8192]; // stack trace buffer
uint32_t offset; // offset in the 'buff'
Dwarf_Addr sp;
Dwarf_Addr cfa;
Dwarf_Frame* frame; // currently examined libdwfl frame
Dwfl* dwfl; // DWARF context
Dwfl_Module* module; // currently processed CU
protected:
char buff[8192]; // stack trace buffer
uint32_t offset; // offset in the 'buff'
} pst_context;