From bb0567b3042fb8003c288ee80eb4782e2e27db63 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 18 Dec 2015 11:19:38 -0500 Subject: runtime/debug: add SetTraceback Programs that call panic to crash after detecting a serious problem may wish to use SetTraceback to force printing of all goroutines first. Change-Id: Ib23ad9336f405485aabb642ca73f454a14c8baf3 Reviewed-on: https://go-review.googlesource.com/18043 Reviewed-by: Brad Fitzpatrick --- src/runtime/debug/garbage.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/runtime/debug/garbage.go') diff --git a/src/runtime/debug/garbage.go b/src/runtime/debug/garbage.go index 41202f9e3b..8d6d2782e9 100644 --- a/src/runtime/debug/garbage.go +++ b/src/runtime/debug/garbage.go @@ -157,3 +157,14 @@ func SetPanicOnFault(enabled bool) bool { // it to the given file descriptor. // The heap dump format is defined at https://golang.org/s/go13heapdump. func WriteHeapDump(fd uintptr) + +// SetTraceback sets the amount of detail printed by the runtime in +// the traceback it prints before exiting due to an unrecovered panic +// or an internal runtime error. +// The level argument takes the same values as the GOTRACEBACK +// environment variable. For example, SetTraceback("all") ensure +// that the program prints all goroutines when it crashes. +// See the package runtime documentation for details. +// If SetTraceback is called with a level lower than that of the +// environment variable, the call is ignored. +func SetTraceback(level string) -- cgit v1.3