Commit 64a832de authored by Daniel Martí's avatar Daniel Martí

cmd/trace: fix a few bugs found by staticcheck

First, the regions sort was buggy, as its last comparison was
ineffective.

Second, the insyscall and insyscallRuntime fields were unsigned, so the
check for them being negative was pointless. Make them signed instead,
to also prevent the possibility of underflows when decreasing numbers
that might realistically be 0.

Third, the color constants were all untyped strings except the first
one. Be consistent with their typing.

Change-Id: I4eb8d08028ed92589493c2a4b9cc5a88d83f769b
Reviewed-on: https://go-review.googlesource.com/113895
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: default avatarHyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent a8e67fe0
......@@ -331,7 +331,7 @@ func analyzeAnnotations() (annotationAnalysisResult, error) {
if si != sj {
return si < sj
}
return task.regions[i].lastTimestamp() < task.regions[i].lastTimestamp()
return task.regions[i].lastTimestamp() < task.regions[j].lastTimestamp()
})
}
return annotationAnalysisResult{tasks: tasks, regions: regions, gcEvents: gcEvents}, nil
......
......@@ -419,9 +419,9 @@ type heapStats struct {
}
type threadStats struct {
insyscallRuntime uint64 // system goroutine in syscall
insyscall uint64 // user goroutine in syscall
prunning uint64 // thread running P
insyscallRuntime int64 // system goroutine in syscall
insyscall int64 // user goroutine in syscall
prunning int64 // thread running P
}
type frameNode struct {
......@@ -1010,8 +1010,8 @@ func (ctx *traceContext) emitGoroutineCounters(ev *trace.Event) {
}
type threadCountersArg struct {
Running uint64
InSyscall uint64
Running int64
InSyscall int64
}
func (ctx *traceContext) emitThreadCounters(ev *trace.Event) {
......@@ -1203,7 +1203,7 @@ func viewerDataTraceConsumer(w io.Writer, start, end int64) traceConsumer {
// https://github.com/catapult-project/catapult/blob/master/tracing/tracing/base/color_scheme.html#L50
// The chrome trace viewer allows only those as cname values.
const (
colorLightMauve string = "thread_state_uninterruptible" // 182, 125, 143
colorLightMauve = "thread_state_uninterruptible" // 182, 125, 143
colorOrange = "thread_state_iowait" // 255, 140, 0
colorSeafoamGreen = "thread_state_running" // 126, 200, 148
colorVistaBlue = "thread_state_runnable" // 133, 160, 210
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment