Commit 165c1c16 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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

Change-Id: I9cbb6d53a8c2302222b13d2f33b081b704208b8a
Reviewed-on: https://go-review.googlesource.com/12932Reviewed-by: 's avatarKeith Randall <khr@golang.org>
Reviewed-by: 's avatarTodd Neal <todd@tneal.org>
parent 6d9362a1
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
package ssa package ssa
import "log" import (
"log"
"runtime"
)
// Compile is the main entry point for this package. // Compile is the main entry point for this package.
// Compile modifies f so that on return: // Compile modifies f so that on return:
...@@ -21,7 +24,11 @@ func Compile(f *Func) { ...@@ -21,7 +24,11 @@ func Compile(f *Func) {
phaseName := "init" phaseName := "init"
defer func() { defer func() {
if phaseName != "" { 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)
} }
}() }()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment