mirror of
https://github.com/golang/go
synced 2024-10-05 20:31:20 -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:
parent
6d9362a1f7
commit
165c1c16d1
@ -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) {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user