2021-11-02 23:44:28 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
"runtime/debug"
|
|
|
|
"runtime/pprof"
|
2024-01-05 12:13:21 -06:00
|
|
|
|
|
|
|
"go.wit.com/log"
|
2024-01-24 18:24:38 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
2021-11-02 23:44:28 -05:00
|
|
|
)
|
|
|
|
|
2024-01-05 12:13:21 -06:00
|
|
|
var langWin *gadgets.BasicWindow
|
2021-11-02 23:44:28 -05:00
|
|
|
|
2024-01-05 12:13:21 -06:00
|
|
|
func golangDebug() {
|
|
|
|
if langWin != nil {
|
|
|
|
langWin.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
langWin = gadgets.NewBasicWindow(myGui, "golangDebug")
|
2021-11-02 23:44:28 -05:00
|
|
|
|
|
|
|
/////////////////////////////// Column DEBUG GOLANG //////////////////////
|
2024-01-05 12:13:21 -06:00
|
|
|
gNode := langWin.Box().NewGroup("golang")
|
2021-11-02 23:44:28 -05:00
|
|
|
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("runtime.Stack() dump", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
buf := make([]byte, 1<<16)
|
|
|
|
runtime.Stack(buf, true)
|
|
|
|
log.Printf("%s", buf)
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("dumpModuleInfo", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
dumpModuleInfo()
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("debug.PrintStack", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
debug.PrintStack()
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("pprof.Lookup goroutine", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("pprof.Lookup", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
pprof.Lookup("heap").WriteTo(os.Stdout, 1)
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("pprof.Lookup block", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
pprof.Lookup("block").WriteTo(os.Stdout, 1)
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("pprof.Lookup threadcreate", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
log.Println("\tSTART")
|
|
|
|
pprof.Lookup("threadcreate").WriteTo(os.Stdout, 1)
|
|
|
|
log.Println("\tEND")
|
|
|
|
})
|
2024-01-24 18:24:38 -06:00
|
|
|
gNode.NewButton("runtime.ReadMemStats", func() {
|
2021-11-02 23:44:28 -05:00
|
|
|
var s runtime.MemStats
|
|
|
|
runtime.ReadMemStats(&s)
|
|
|
|
log.Printf("alloc: %v bytes\n", s.Alloc)
|
|
|
|
log.Printf("total-alloc: %v bytes\n", s.TotalAlloc)
|
|
|
|
log.Printf("sys: %v bytes\n", s.Sys)
|
|
|
|
log.Printf("lookups: %v\n", s.Lookups)
|
|
|
|
log.Printf("mallocs: %v\n", s.Mallocs)
|
|
|
|
log.Printf("frees: %v\n", s.Frees)
|
|
|
|
log.Printf("heap-alloc: %v bytes\n", s.HeapAlloc)
|
|
|
|
log.Printf("heap-sys: %v bytes\n", s.HeapSys)
|
|
|
|
log.Printf("heap-idle: %v bytes\n", s.HeapIdle)
|
|
|
|
log.Printf("heap-in-use: %v bytes\n", s.HeapInuse)
|
|
|
|
log.Printf("heap-released: %v bytes\n", s.HeapReleased)
|
|
|
|
log.Printf("heap-objects: %v\n", s.HeapObjects)
|
|
|
|
log.Printf("stack-in-use: %v bytes\n", s.StackInuse)
|
|
|
|
log.Printf("stack-sys: %v bytes\n", s.StackSys)
|
|
|
|
log.Printf("next-gc: when heap-alloc >= %v bytes\n", s.NextGC)
|
|
|
|
log.Printf("last-gc: %v ns\n", s.LastGC)
|
|
|
|
log.Printf("gc-pause: %v ns\n", s.PauseTotalNs)
|
|
|
|
log.Printf("num-gc: %v\n", s.NumGC)
|
|
|
|
log.Printf("enable-gc: %v\n", s.EnableGC)
|
|
|
|
log.Printf("debug-gc: %v\n", s.DebugGC)
|
|
|
|
})
|
|
|
|
}
|