proc: change UserCurrent to exclude internal and runtime/internal (#2853)

packages

Changes UserCurrent to exclude frames stopped inside the 'internal' and
'runtime/internal' packages of the standard library.

Before this change a goroutine blocked accepting or reading from a
socket would be reported as having a user current frame of:

    internal/poll.runtime_pollWait

After this change accepting goroutines will be reported with a user
current frame of:

    net.(*netFD).accept

and reading goroutines as:

    net.(*netFD).read
This commit is contained in:
Alessandro Arzilli 2022-01-06 18:07:26 +01:00 committed by GitHub
parent a2927f6117
commit 466f9b8c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -497,7 +497,7 @@ func (g *G) UserCurrent() Location {
frame := it.Frame()
if frame.Call.Fn != nil {
name := frame.Call.Fn.Name
if strings.Contains(name, ".") && (!strings.HasPrefix(name, "runtime.") || frame.Call.Fn.exportedRuntime()) {
if strings.Contains(name, ".") && (!strings.HasPrefix(name, "runtime.") || frame.Call.Fn.exportedRuntime()) && !strings.HasPrefix(name, "internal/") && !strings.HasPrefix(name, "runtime/internal") {
return frame.Call
}
}