aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/proc.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-07-31 20:32:08 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-07-31 20:32:08 +0000
commit414925ab0cb8d0aea39cb3383b18f72f3ce887a0 (patch)
tree2f08571e507f4d5a958e113cb0fde621c42c138e /libgo/go/runtime/proc.go
parentce311a8cae4489058f8601bebdf511b7fb5fce26 (diff)
parent8810325ff666643de80110c5c6b4ce1cef921e1b (diff)
downloadgcc-414925ab0cb8d0aea39cb3383b18f72f3ce887a0.zip
gcc-414925ab0cb8d0aea39cb3383b18f72f3ce887a0.tar.gz
gcc-414925ab0cb8d0aea39cb3383b18f72f3ce887a0.tar.bz2
Merge from trunk revision 263114.
From-SVN: r263179
Diffstat (limited to 'libgo/go/runtime/proc.go')
-rw-r--r--libgo/go/runtime/proc.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go
index a6746c9..5826958 100644
--- a/libgo/go/runtime/proc.go
+++ b/libgo/go/runtime/proc.go
@@ -3418,8 +3418,36 @@ func sigprof(pc uintptr, gp *g, mp *m) {
var stklocs [maxCPUProfStack]location
n = callers(0, stklocs[:])
+ // Issue 26595: the stack trace we've just collected is going
+ // to include frames that we don't want to report in the CPU
+ // profile, including signal handler frames. Here is what we
+ // might typically see at the point of "callers" above for a
+ // signal delivered to the application routine "interesting"
+ // called by "main".
+ //
+ // 0: runtime.sigprof
+ // 1: runtime.sighandler
+ // 2: runtime.sigtrampgo
+ // 3: runtime.sigtramp
+ // 4: <signal handler called>
+ // 5: main.interesting_routine
+ // 6: main.main
+ //
+ // To ensure a sane profile, walk through the frames in
+ // "stklocs" until we find the "runtime.sigtramp" frame, then
+ // report only those frames below the frame one down from
+ // that. If for some reason "runtime.sigtramp" is not present,
+ // don't make any changes.
+ framesToDiscard := 0
+ for i := 0; i < n; i++ {
+ if stklocs[i].function == "runtime.sigtramp" && i+2 < n {
+ framesToDiscard = i + 2
+ n -= framesToDiscard
+ break
+ }
+ }
for i := 0; i < n; i++ {
- stk[i] = stklocs[i].pc
+ stk[i] = stklocs[i+framesToDiscard].pc
}
}