]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: provide stack trace for caught panics
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 30 Jul 2015 17:28:57 +0000 (10:28 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 30 Jul 2015 20:31:35 +0000 (20:31 +0000)
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>
src/cmd/compile/internal/ssa/compile.go

index 7a7b9926ed14a0df7679836a9aad0c4a5d499733..001530ae8011adfc50eeb89263e5854c08f2be94 100644 (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)
                }
        }()