]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: dump stack trace in Fatalf during development
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 31 Mar 2016 16:29:32 +0000 (09:29 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 31 Mar 2016 20:17:09 +0000 (20:17 +0000)
See discussion in #15029.

Change-Id: I5cc8be5737ddb7c1f5e4a6cd92cf557af45e961d
Reviewed-on: https://go-review.googlesource.com/21347
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/subr.go

index c552dd01a192d46d40b4700f5e1c2c5135e52aed..83888be6f7733199eed49a35bbd451560d83c577 100644 (file)
@@ -11,6 +11,7 @@ import (
        "encoding/binary"
        "fmt"
        "os"
+       "runtime/debug"
        "sort"
        "strconv"
        "strings"
@@ -151,6 +152,11 @@ func Fatalf(fmt_ string, args ...interface{}) {
                fmt.Printf("\n")
                fmt.Printf("Please file a bug report including a short program that triggers the error.\n")
                fmt.Printf("https://golang.org/issue/new\n")
+       } else {
+               // Not a release; dump a stack trace, too.
+               fmt.Println()
+               os.Stdout.Write(debug.Stack())
+               fmt.Println()
        }
 
        hcrash()