mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
1 changed files with 9 additions and 2 deletions
|
|
@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue