File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -408,7 +408,19 @@ unsafe fn init_state() -> *mut bt::backtrace_state {
408
408
}
409
409
410
410
pub unsafe fn resolve ( what : ResolveWhat , cb : & mut FnMut ( & super :: Symbol ) ) {
411
- let symaddr = what. address_or_ip ( ) ;
411
+ let mut symaddr = what. address_or_ip ( ) as usize ;
412
+
413
+ // It's sort of unclear why this is necessary, but it appears that the ip
414
+ // values from stack traces are typically the instruction *after* the call
415
+ // that's the actual stack trace. Symbolizing this on Windows causes the
416
+ // filename/line number to be one ahead and perhaps into the void if it's
417
+ // near the end of the function. Apparently on Unix though it's roughly fine
418
+ // in that the filename/line number turn out alright. For now just try to
419
+ // get good backtraces with this, and hopefully one day we can figure out
420
+ // why the `-=1` is here.
421
+ if cfg ! ( windows) && symaddr > 0 {
422
+ symaddr -= 1 ;
423
+ }
412
424
413
425
// backtrace errors are currently swept under the rug
414
426
let state = init_state ( ) ;
@@ -423,7 +435,7 @@ pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) {
423
435
// Note that we do this since `syminfo` will consult the symbol table,
424
436
// finding symbol names even if there's no debug information in the binary.
425
437
let mut syminfo_state = SyminfoState {
426
- pc : symaddr as usize ,
438
+ pc : symaddr,
427
439
cb : cb,
428
440
} ;
429
441
bt:: backtrace_syminfo (
You can’t perform that action at this time.
0 commit comments