import (
"cmd/internal/objabi"
"fmt"
+ "log"
"math"
)
ctxt.Arch = arch
ctxt.Pathname = objabi.WorkingDir()
- ctxt.Headtype.Set(objabi.GOOS)
+ if err := ctxt.Headtype.Set(objabi.GOOS); err != nil {
+ log.Fatalf("unknown goos %s", objabi.GOOS)
+ }
ctxt.Flag_optimize = true
ctxt.Framepointer_enabled = objabi.Framepointer_enabled(objabi.GOOS, arch.Name)
heapStats, prevHeapStats heapStats
threadStats, prevThreadStats threadStats
- gstates, prevGstates [gStateCount]uint64
+ gstates, prevGstates [gStateCount]int64
}
type heapStats struct {
if setGStateErr != nil {
return ctx.data, setGStateErr
}
+ if ctx.gstates[gRunnable] < 0 || ctx.gstates[gRunning] < 0 || ctx.threadStats.insyscall < 0 {
+ return ctx.data, fmt.Errorf("invalid state after processing %v: runnable=%d running=%d insyscall=%d", ev, ctx.gstates[gRunnable], ctx.gstates[gRunning], ctx.threadStats.insyscall)
+ }
// Ignore events that are from uninteresting goroutines
// or outside of the interesting timeframe.
if ctx.prevGstates == ctx.gstates {
return
}
- ctx.emit(&ViewerEvent{Name: "Goroutines", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &goroutineCountersArg{ctx.gstates[gRunning], ctx.gstates[gRunnable], ctx.gstates[gWaitingGC]}})
+ ctx.emit(&ViewerEvent{Name: "Goroutines", Phase: "C", Time: ctx.time(ev), Pid: 1, Arg: &goroutineCountersArg{uint64(ctx.gstates[gRunning]), uint64(ctx.gstates[gRunnable]), uint64(ctx.gstates[gWaitingGC])}})
ctx.prevGstates = ctx.gstates
}