mirror of
https://github.com/golang/go
synced 2024-11-14 13:50:23 -07:00
af134b17da
As a followon to CL 152537, modify the panic-printing traceback to also handle mid-stack inlining correctly. Also declare -fm functions (aka method functions) as wrappers, so that they get elided during traceback. This fixes part 2 of #26839. Fixes #28640 Fixes #24488 Update #26839 Change-Id: I1c535a9b87a9a1ea699621be1e6526877b696c21 Reviewed-on: https://go-review.googlesource.com/c/153477 Reviewed-by: David Chase <drchase@google.com>
39 lines
563 B
Go
39 lines
563 B
Go
// run
|
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
import (
|
|
"runtime"
|
|
"strings"
|
|
)
|
|
|
|
type Func func()
|
|
|
|
func (f Func) Foo() {
|
|
if f != nil {
|
|
f()
|
|
}
|
|
}
|
|
|
|
func (f Func) Bar() {
|
|
if f != nil {
|
|
f()
|
|
}
|
|
buf := make([]byte, 4000)
|
|
n := runtime.Stack(buf, true)
|
|
s := string(buf[:n])
|
|
if strings.Contains(s, "-fm") {
|
|
panic("wrapper present in stack trace:\n" + s)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
foo := Func(func() {})
|
|
foo = foo.Bar
|
|
foo.Foo()
|
|
}
|