mirror of
https://github.com/bdnugget/eggos.git
synced 2026-11-08 04:17:27 +00:00
29 lines
390 B
Go
29 lines
390 B
Go
package cmd
|
|
|
|
import (
|
|
"runtime"
|
|
|
|
"github.com/icexin/eggos/app"
|
|
)
|
|
|
|
func gostack() []byte {
|
|
buf := make([]byte, 1024)
|
|
for {
|
|
n := runtime.Stack(buf, true)
|
|
if n < len(buf) {
|
|
return buf[:n]
|
|
}
|
|
buf = make([]byte, 2*len(buf))
|
|
}
|
|
}
|
|
|
|
func pstackmain(ctx *app.Context) error {
|
|
ctx.Stderr.Write(gostack())
|
|
// tstack()
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
app.Register("pstack", pstackmain)
|
|
}
|