]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: fix a few bugs found by staticcheck
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 20 May 2018 15:02:35 +0000 (16:02 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 21 May 2018 16:18:29 +0000 (16:18 +0000)
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: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/trace/annotations.go
src/cmd/trace/trace.go

index 459e67c15a8c7221c38b5da40da3f164ac0c4dae..c91f18ef6f2b925d87745cff1d8e19908a5d57ba 100644 (file)
@@ -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
index 31ef3b6892391beab7bf6f9587bbbb89d8d9af39..62ff4d68c51c5a795f3ebb458b64f397f2497813 100644 (file)
@@ -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,38 +1203,38 @@ 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
-       colorOrange                = "thread_state_iowait"          // 255, 140, 0
-       colorSeafoamGreen          = "thread_state_running"         // 126, 200, 148
-       colorVistaBlue             = "thread_state_runnable"        // 133, 160, 210
-       colorTan                   = "thread_state_unknown"         // 199, 155, 125
-       colorIrisBlue              = "background_memory_dump"       // 0, 180, 180
-       colorMidnightBlue          = "light_memory_dump"            // 0, 0, 180
-       colorDeepMagenta           = "detailed_memory_dump"         // 180, 0, 180
-       colorBlue                  = "vsync_highlight_color"        // 0, 0, 255
-       colorGrey                  = "generic_work"                 // 125, 125, 125
-       colorGreen                 = "good"                         // 0, 125, 0
-       colorDarkGoldenrod         = "bad"                          // 180, 125, 0
-       colorPeach                 = "terrible"                     // 180, 0, 0
-       colorBlack                 = "black"                        // 0, 0, 0
-       colorLightGrey             = "grey"                         // 221, 221, 221
-       colorWhite                 = "white"                        // 255, 255, 255
-       colorYellow                = "yellow"                       // 255, 255, 0
-       colorOlive                 = "olive"                        // 100, 100, 0
-       colorCornflowerBlue        = "rail_response"                // 67, 135, 253
-       colorSunsetOrange          = "rail_animation"               // 244, 74, 63
-       colorTangerine             = "rail_idle"                    // 238, 142, 0
-       colorShamrockGreen         = "rail_load"                    // 13, 168, 97
-       colorGreenishYellow        = "startup"                      // 230, 230, 0
-       colorDarkGrey              = "heap_dump_stack_frame"        // 128, 128, 128
-       colorTawny                 = "heap_dump_child_node_arrow"   // 204, 102, 0
-       colorLemon                 = "cq_build_running"             // 255, 255, 119
-       colorLime                  = "cq_build_passed"              // 153, 238, 102
-       colorPink                  = "cq_build_failed"              // 238, 136, 136
-       colorSilver                = "cq_build_abandoned"           // 187, 187, 187
-       colorManzGreen             = "cq_build_attempt_runnig"      // 222, 222, 75
-       colorKellyGreen            = "cq_build_attempt_passed"      // 108, 218, 35
-       colorAnotherGrey           = "cq_build_attempt_failed"      // 187, 187, 187
+       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
+       colorTan            = "thread_state_unknown"         // 199, 155, 125
+       colorIrisBlue       = "background_memory_dump"       // 0, 180, 180
+       colorMidnightBlue   = "light_memory_dump"            // 0, 0, 180
+       colorDeepMagenta    = "detailed_memory_dump"         // 180, 0, 180
+       colorBlue           = "vsync_highlight_color"        // 0, 0, 255
+       colorGrey           = "generic_work"                 // 125, 125, 125
+       colorGreen          = "good"                         // 0, 125, 0
+       colorDarkGoldenrod  = "bad"                          // 180, 125, 0
+       colorPeach          = "terrible"                     // 180, 0, 0
+       colorBlack          = "black"                        // 0, 0, 0
+       colorLightGrey      = "grey"                         // 221, 221, 221
+       colorWhite          = "white"                        // 255, 255, 255
+       colorYellow         = "yellow"                       // 255, 255, 0
+       colorOlive          = "olive"                        // 100, 100, 0
+       colorCornflowerBlue = "rail_response"                // 67, 135, 253
+       colorSunsetOrange   = "rail_animation"               // 244, 74, 63
+       colorTangerine      = "rail_idle"                    // 238, 142, 0
+       colorShamrockGreen  = "rail_load"                    // 13, 168, 97
+       colorGreenishYellow = "startup"                      // 230, 230, 0
+       colorDarkGrey       = "heap_dump_stack_frame"        // 128, 128, 128
+       colorTawny          = "heap_dump_child_node_arrow"   // 204, 102, 0
+       colorLemon          = "cq_build_running"             // 255, 255, 119
+       colorLime           = "cq_build_passed"              // 153, 238, 102
+       colorPink           = "cq_build_failed"              // 238, 136, 136
+       colorSilver         = "cq_build_abandoned"           // 187, 187, 187
+       colorManzGreen      = "cq_build_attempt_runnig"      // 222, 222, 75
+       colorKellyGreen     = "cq_build_attempt_passed"      // 108, 218, 35
+       colorAnotherGrey    = "cq_build_attempt_failed"      // 187, 187, 187
 )
 
 var colorForTask = []string{