From f0cb44a7736df649cdb5c7b3dfe8e270ae691626 Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Fri, 10 Feb 2023 14:08:27 -0500 Subject: [PATCH] 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 --- src/cmd/trace/trace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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]++ -- 2.51.0