mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: record current PC for SIGPROF on non-Go thread
If we get a SIGPROF on a non-Go thread, and the program has not called runtime.SetCgoTraceback so we have no way to collect a stack trace, then record a profile that is just the PC where the signal occurred. That will at least point the user to the right area. Retrieving the PC from the sigctxt in a signal handler on a non-G thread required marking a number of trivial sigctxt methods as nosplit, and, for extra safety, nowritebarrierrec. The test shows that the existing test CgoPprofThread test does not test the stack trace, just the profile signal. Leaving that for later. Change-Id: I8f8f3ff09ac099fc9d9df94b5a9d210ffc20c4ab Reviewed-on: https://go-review.googlesource.com/30252 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
This commit is contained in:
parent
c24cc40075
commit
d03e8b226c
38 changed files with 726 additions and 491 deletions
|
|
@ -202,15 +202,12 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
|
|||
}
|
||||
g := getg()
|
||||
if g == nil {
|
||||
c := &sigctxt{info, ctx}
|
||||
if sig == _SIGPROF {
|
||||
// Ignore profiling signals that arrive on
|
||||
// non-Go threads. On some systems they will
|
||||
// be handled directly by the signal handler,
|
||||
// by calling sigprofNonGo, in which case we won't
|
||||
// get here anyhow.
|
||||
sigprofNonGoPC(c.sigpc())
|
||||
return
|
||||
}
|
||||
badsignal(uintptr(sig), &sigctxt{info, ctx})
|
||||
badsignal(uintptr(sig), c)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue