aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/traceback.go
diff options
context:
space:
mode:
authorKeith Randall <khr@google.com>2019-01-07 12:24:01 -0800
committerKeith Randall <khr@golang.org>2019-01-08 18:24:50 +0000
commit232c9793092115870a430ef3c9ef9ae04f9e25c9 (patch)
tree31a4c66eb18b2909705b3cbdebe2e30dab1ddf3c /src/runtime/traceback.go
parenta1d5e8adfa4d2f1043f4617fe20994ddbb7cc25c (diff)
downloadgo-232c9793092115870a430ef3c9ef9ae04f9e25c9.tar.gz
go-232c9793092115870a430ef3c9ef9ae04f9e25c9.zip
runtime: store incremented PC in result of runtime.Callers
In 1.11 we stored "return addresses" in the result of runtime.Callers. I changed that behavior in CL 152537 to store an address in the call instruction itself. This CL reverts that part of 152537. The change in 152537 was made because we now store pcs of inline marks in the result of runtime.Callers as well. This CL will now store the address of the inline mark + 1 in the results of runtime.Callers, so that the subsequent -1 done in CallersFrames will pick out the correct inline mark instruction. This CL means that the results of runtime.Callers can be passed to runtime.FuncForPC as they were before. There are a bunch of packages in the wild that take the results of runtime.Callers, subtract 1, and then call FuncForPC. This CL keeps that pattern working as it did in 1.11. The changes to runtime/pprof in this CL are exactly a revert of the changes to that package in 152537 (except the locForPC comment). Update #29582 Change-Id: I04d232000fb482f0f0ff6277f8d7b9c72e97eb48 Reviewed-on: https://go-review.googlesource.com/c/156657 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/traceback.go')
-rw-r--r--src/runtime/traceback.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go
index 9b7fafcad7..a536fb2a71 100644
--- a/src/runtime/traceback.go
+++ b/src/runtime/traceback.go
@@ -344,8 +344,9 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
}
if pcbuf != nil {
+ pc := frame.pc
// backup to CALL instruction to read inlining info (same logic as below)
- tracepc := frame.pc
+ tracepc := pc
if (n > 0 || flags&_TraceTrap == 0) && frame.pc > f.entry && !waspanic {
tracepc--
}
@@ -363,12 +364,13 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
} else if skip > 0 {
skip--
} else if n < max {
- (*[1 << 20]uintptr)(unsafe.Pointer(pcbuf))[n] = tracepc
+ (*[1 << 20]uintptr)(unsafe.Pointer(pcbuf))[n] = pc
n++
}
lastFuncID = inltree[ix].funcID
// Back up to an instruction in the "caller".
tracepc = frame.fn.entry + uintptr(inltree[ix].parentPc)
+ pc = tracepc + 1
}
}
// Record the main frame.
@@ -377,7 +379,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
} else if skip > 0 {
skip--
} else if n < max {
- (*[1 << 20]uintptr)(unsafe.Pointer(pcbuf))[n] = tracepc
+ (*[1 << 20]uintptr)(unsafe.Pointer(pcbuf))[n] = pc
n++
}
lastFuncID = f.funcID