elvish/pkg/sys/dumpstack.go
Qi Xiao fbf0bfc13b pkg/sys: Double init size of stack trace buf.
4KB is likely insufficient.
2022-06-23 21:48:12 +01:00

17 lines
262 B
Go

package sys
import "runtime"
const dumpStackBufSizeInit = 8192
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)
}
}