1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:41:21 -06:00

[dev.ssa] cmd/compile: provide stack trace for caught panics

Change-Id: I9cbb6d53a8c2302222b13d2f33b081b704208b8a
Reviewed-on: https://go-review.googlesource.com/12932
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
This commit is contained in:
Josh Bleecher Snyder 2015-07-30 10:28:57 -07:00
parent 6d9362a1f7
commit 165c1c16d1

View File

@ -4,7 +4,10 @@
package ssa
import "log"
import (
"log"
"runtime"
)
// Compile is the main entry point for this package.
// Compile modifies f so that on return:
@ -21,7 +24,11 @@ func Compile(f *Func) {
phaseName := "init"
defer func() {
if phaseName != "" {
f.Fatalf("panic during %s while compiling %s\n", phaseName, f.Name)
err := recover()
stack := make([]byte, 16384)
n := runtime.Stack(stack, false)
stack = stack[:n]
f.Fatalf("panic during %s while compiling %s:\n\n%v\n\n%s\n", phaseName, f.Name, err, stack)
}
}()