@@ -31,6 +31,7 @@ const uint8_t *NativeStackTrace::stack = NULL;
3131size_t NativeStackTrace::stack_len = 0 ;
3232uintptr_t NativeStackTrace::sp = 0 ;
3333uintptr_t NativeStackTrace::ip = 0 ;
34+ uintptr_t NativeStackTrace::bp = 0 ;
3435ProcSymbolsCache NativeStackTrace::procSymbolsCache;
3536bool NativeStackTrace::insert_dso_name = false ;
3637const static double ProcSymbolsCacheTTL_S = 60 ;
@@ -43,11 +44,12 @@ static double steady_time_since_epoch() {
4344}
4445
4546NativeStackTrace::NativeStackTrace (uint32_t pid, const unsigned char *raw_stack,
46- size_t stack_len, uintptr_t ip, uintptr_t sp) : error_occurred(false ) {
47+ size_t stack_len, uintptr_t ip, uintptr_t sp, uintptr_t bp ) : error_occurred(false ) {
4748 NativeStackTrace::stack = raw_stack;
4849 NativeStackTrace::stack_len = stack_len;
4950 NativeStackTrace::ip = ip;
5051 NativeStackTrace::sp = sp;
52+ NativeStackTrace::bp = bp;
5153
5254 if (stack_len == 0 ) {
5355 return ;
@@ -157,6 +159,15 @@ NativeStackTrace::NativeStackTrace(uint32_t pid, const unsigned char *raw_stack,
157159
158160int NativeStackTrace::UPT_access_reg (unw_addr_space_t as, unw_regnum_t regnum,
159161 unw_word_t *valp, int write, void *arg) {
162+ if (regnum == UNW_X86_64_RBP ) {
163+ if (write) {
164+ logInfo (2 , " Libunwind attempts to write to BP\n " );
165+ return -UNW_EINVAL ;
166+ }
167+
168+ *valp = NativeStackTrace::bp;
169+ return 0 ;
170+ }
160171 if (regnum == UNW_REG_SP ) {
161172 if (write) {
162173 logInfo (2 , " Libunwind attempts to write to SP\n " );
@@ -234,7 +245,7 @@ int NativeStackTrace::UPT_access_mem(unw_addr_space_t as, unw_word_t addr,
234245int NativeStackTrace::UPT_access_fpreg (unw_addr_space_t as, unw_regnum_t reg, unw_fpreg_t *val,
235246 int write, void *arg) {
236247 logInfo (3 , " Libunwind unexpected UPT_access_fpreg() attempt\n " );
237- return -UNW_EINVAL ;
248+ return -UNW_EINVAL ;
238249}
239250
240251int NativeStackTrace::UPT_resume (unw_addr_space_t as, unw_cursor_t *c, void *arg) {
0 commit comments