aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mprof.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-29 15:14:24 -0400
committerRuss Cox <rsc@golang.org>2014-10-29 15:14:24 -0400
commita22c11b9957cf3f0d66dd6d1d38172d5ac0ec54a (patch)
tree5825807374a53bf2cd20283845da6476f3c722e5 /src/runtime/mprof.go
parent8db71d4ee89a505c375b550eb8fb8cc33bbabc03 (diff)
downloadgo-a22c11b9957cf3f0d66dd6d1d38172d5ac0ec54a.tar.gz
go-a22c11b9957cf3f0d66dd6d1d38172d5ac0ec54a.zip
runtime: fix line number in first stack frame in printed stack trace
Originally traceback was only used for printing the stack when an unexpected signal came in. In that case, the initial PC is taken from the signal and should be used unaltered. For the callers, the PC is the return address, which might be on the line after the call; we subtract 1 to get to the CALL instruction. Traceback is now used for a variety of things, and for almost all of those the initial PC is a return address, whether from getcallerpc, or gp->sched.pc, or gp->syscallpc. In those cases, we need to subtract 1 from this initial PC, but the traceback code had a hard rule "never subtract 1 from the initial PC", left over from the signal handling days. Change gentraceback to take a flag that specifies whether we are tracing a trap. Change traceback to default to "starting with a return PC", which is the overwhelmingly common case. Add tracebacktrap, like traceback but starting with a trap PC. Use tracebacktrap in signal handlers. Fixes #7690. LGTM=iant, r R=r, iant CC=golang-codereviews https://golang.org/cl/167810044
Diffstat (limited to 'src/runtime/mprof.go')
-rw-r--r--src/runtime/mprof.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go
index 803da56670..d64e3be695 100644
--- a/src/runtime/mprof.go
+++ b/src/runtime/mprof.go
@@ -562,7 +562,7 @@ func GoroutineProfile(p []StackRecord) (n int, ok bool) {
}
func saveg(pc, sp uintptr, gp *g, r *StackRecord) {
- n := gentraceback(pc, sp, 0, gp, 0, &r.Stack0[0], len(r.Stack0), nil, nil, false)
+ n := gentraceback(pc, sp, 0, gp, 0, &r.Stack0[0], len(r.Stack0), nil, nil, 0)
if n < len(r.Stack0) {
r.Stack0[n] = 0
}