]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: fix error message for bad goroutine state transition
authorNick Ripley <nick.ripley@datadoghq.com>
Fri, 10 Feb 2023 19:08:27 +0000 (14:08 -0500)
committerGopher Robot <gobot@golang.org>
Fri, 10 Feb 2023 21:45:16 +0000 (21:45 +0000)
The error message when an invalid goroutine state transition is found in
a trace should show the current state, not the next state, when
comparing against the expected current state.

This CL also picks up a gofmt change to the file.

Change-Id: Ic0ce6c9ce79d8a784b73b115b5db76c311b8593d
Reviewed-on: https://go-review.googlesource.com/c/go/+/467416
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/trace/trace.go

index 84fca62a044735895fdbd78832979d8137b5f2c0..895129998f57d2f12a44e2a1d8d760093717e6bb 100644 (file)
@@ -338,7 +338,7 @@ func stackFrameEncodedSize(id uint, f traceviewer.Frame) int {
        // The parent is omitted if 0. The trailing comma is omitted from the
        // last entry, but we don't need that much precision.
        const (
-               baseSize = len(`"`) + len (`":{"name":"`) + len(`"},`)
+               baseSize = len(`"`) + len(`":{"name":"`) + len(`"},`)
 
                // Don't count the trailing quote on the name, as that is
                // counted in baseSize.
@@ -647,7 +647,7 @@ func generateTrace(params *traceParams, consumer traceConsumer) error {
                        oldState = info.state
                }
                if info.state != oldState && setGStateErr == nil {
-                       setGStateErr = fmt.Errorf("expected G %d to be in state %d, but got state %d", g, oldState, newState)
+                       setGStateErr = fmt.Errorf("expected G %d to be in state %d, but got state %d", g, oldState, info.state)
                }
                ctx.gstates[info.state]--
                ctx.gstates[newState]++