From: Nick Ripley Date: Fri, 10 Feb 2023 19:08:27 +0000 (-0500) Subject: cmd/trace: fix error message for bad goroutine state transition X-Git-Tag: go1.21rc1~1581 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f0cb44a7736df649cdb5c7b3dfe8e270ae691626;p=gostls13.git cmd/trace: fix error message for bad goroutine state transition 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 Reviewed-by: Michael Knyszek Reviewed-by: David Chase Run-TryBot: Michael Knyszek TryBot-Result: Gopher Robot --- diff --git a/src/cmd/trace/trace.go b/src/cmd/trace/trace.go index 84fca62a04..895129998f 100644 --- a/src/cmd/trace/trace.go +++ b/src/cmd/trace/trace.go @@ -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]++