In golang it's recommended to process stacktraces using runtime.CallersFrames.
But unfortunately for inlined functions the frame.Func field is going to be nil.
In this situation we can extract inlined function data from underlying low level data using FuncForPC.
func runtime.FuncForPC(pc uintptr) runtime.Func
FuncForPC returns a Func describing the function that contains the given program counter address, or else nil.
If pc represents multiple functions because of inlining, it returns the *Func describing the innermost function, but with an entry of the outermost function.
Changeset
For inline functions extract stack data from PC.
Processing frames from stack now does not exclude newest item on this line.
Tests for notifier do not match one expected line multiple times on this line
For the example in linked issue the Bugsnag UI reported this:
and after this change it now looks like this:
Testing
Changed unit tests that required us to ignore inlined functions - they are now not ignored.
Goal
Customers requested for inline functions to be visible in the stacktrace in bugsnag UI. Issue: https://github.com/bugsnag/bugsnag-go/issues/183
Design
In golang it's recommended to process stacktraces using runtime.CallersFrames. But unfortunately for inlined functions the frame.Func field is going to be nil. In this situation we can extract inlined function data from underlying low level data using FuncForPC.
Changeset
For inline functions extract stack data from PC. Processing frames from stack now does not exclude newest item on this line. Tests for notifier do not match one expected line multiple times on this line
For the example in linked issue the Bugsnag UI reported this:
and after this change it now looks like this:
Testing
Changed unit tests that required us to ignore inlined functions - they are now not ignored.