elvish/pkg/sys/dumpstack.go
2019-12-23 20:00:59 +00:00

17 lines
262 B
Go

package sys
import "runtime"
const dumpStackBufSizeInit = 4096
func DumpStack() string {
buf := make([]byte, dumpStackBufSizeInit)
for {
n := runtime.Stack(buf, true)
if n < cap(buf) {
return string(buf[:n])
}
buf = make([]byte, cap(buf)*2)
}
}