mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use inlining tables to generate accurate tracebacks
The code in https://play.golang.org/p/aYQPrTtzoK now produces the following stack trace: goroutine 1 [running]: main.(*point).negate(...) /tmp/go/main.go:8 main.main() /tmp/go/main.go:14 +0x23 Previously the stack trace missed the inlined call: goroutine 1 [running]: main.main() /tmp/go/main.go:14 +0x23 Fixes #10152. Updates #19348. Change-Id: Ib43c67012f53da0ef1a1e69bcafb65b57d9cecb2 Reviewed-on: https://go-review.googlesource.com/37233 Run-TryBot: David Lazar <lazard@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
1c6ef9aeed
commit
781fd3998e
3 changed files with 69 additions and 1 deletions
|
|
@ -538,3 +538,31 @@ func TestConcurrentMapIterateWrite(t *testing.T) {
|
|||
t.Fatalf("output does not start with %q:\n%s", want, output)
|
||||
}
|
||||
}
|
||||
|
||||
type point struct {
|
||||
x, y *int
|
||||
}
|
||||
|
||||
func (p *point) negate() {
|
||||
*p.x = *p.x * -1
|
||||
*p.y = *p.y * -1
|
||||
}
|
||||
|
||||
// Test for issue #10152.
|
||||
func TestPanicInlined(t *testing.T) {
|
||||
defer func() {
|
||||
r := recover()
|
||||
if r == nil {
|
||||
t.Fatalf("recover failed")
|
||||
}
|
||||
buf := make([]byte, 2048)
|
||||
n := runtime.Stack(buf, false)
|
||||
buf = buf[:n]
|
||||
if !bytes.Contains(buf, []byte("(*point).negate(")) {
|
||||
t.Fatalf("expecting stack trace to contain call to (*point).negate()")
|
||||
}
|
||||
}()
|
||||
|
||||
pt := new(point)
|
||||
pt.negate()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue