aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/crash_cgo_test.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2020-11-20 17:32:46 -0500
committerAustin Clements <austin@google.com>2020-11-24 21:47:44 +0000
commite8de596f04d0ea7fb6fb68b036760bf088a9c6c2 (patch)
treeac9399d5206140e2a46ef66b41715e42b3ab198a /src/runtime/crash_cgo_test.go
parentba2adc21e8c416c47dec5fbce76286758f15b177 (diff)
downloadgo-e8de596f04d0ea7fb6fb68b036760bf088a9c6c2.tar.gz
go-e8de596f04d0ea7fb6fb68b036760bf088a9c6c2.zip
runtime: use inlined function name for traceback elision
Currently, gentraceback decides which frames to print or elide when unwinding inlined frames using only the name of the outermost function. If the outermost function should be elided, then inlined functions will also be elided, even if they shouldn't be. This happens in practice in at least one situation. As of CL 258938, exported Go functions (and functions they call) can now be inlined into the generated _cgoexp_HASH_FN function. The runtime elides _cgoexp_HASH_FN from tracebacks because it doesn't contain a ".". Because of this bug, it also elides anything that was inlined into it. This CL fixes this by synthesizing a funcInfo for the inlined functions to pass to showframe. Fixes #42754. Change-Id: Ie6c663a4a1ac7f0d4beb1aa60bc26fc8cddd0f9d Reviewed-on: https://go-review.googlesource.com/c/go/+/272131 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/crash_cgo_test.go')
-rw-r--r--src/runtime/crash_cgo_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go
index 0680d07a32..140c170ddc 100644
--- a/src/runtime/crash_cgo_test.go
+++ b/src/runtime/crash_cgo_test.go
@@ -254,6 +254,24 @@ func TestCgoCrashTraceback(t *testing.T) {
}
}
+func TestCgoCrashTracebackGo(t *testing.T) {
+ t.Parallel()
+ switch platform := runtime.GOOS + "/" + runtime.GOARCH; platform {
+ case "darwin/amd64":
+ case "linux/amd64":
+ case "linux/ppc64le":
+ default:
+ t.Skipf("not yet supported on %s", platform)
+ }
+ got := runTestProg(t, "testprogcgo", "CrashTracebackGo")
+ for i := 1; i <= 3; i++ {
+ want := fmt.Sprintf("main.h%d", i)
+ if !strings.Contains(got, want) {
+ t.Errorf("missing %s", want)
+ }
+ }
+}
+
func TestCgoTracebackContext(t *testing.T) {
t.Parallel()
got := runTestProg(t, "testprogcgo", "TracebackContext")