Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix file-based filtering symbolization
If file-filtered logging is enabled, V looks up its caller's source file path using runtime.Callers and runtime.FuncForPC. However, runtime.Callers returns return PCs, which aren't necessarily in the same source file as the call site. For example, if F calls V, and F's call to V is immediately followed by an inlined called to another function, say G, then symbolizing V's return PC will actually return G's file and line number, not F's. Fix this by subtracting 1 from the PC returned by runtime.Callers to back up from the return PC to the call PC. An arguably better fix would be to use runtime.CallersFrames, which abstracts away such details. Unfortunately, CallersFrames allocates (at least as of Go 1.15), so we avoid it here.
- Loading branch information