gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/cmds/core/elvish/sys/dumpstack.go (about)

     1  package sys
     2  
     3  import "runtime"
     4  
     5  const dumpStackBufSizeInit = 4096
     6  
     7  func DumpStack() string {
     8  	buf := make([]byte, dumpStackBufSizeInit)
     9  	for {
    10  		n := runtime.Stack(buf, true)
    11  		if n < cap(buf) {
    12  			return string(buf[:n])
    13  		}
    14  		buf = make([]byte, cap(buf)*2)
    15  	}
    16  }