Skip to content

Commit 5164a86

Browse files
felixgegopherbot
authored andcommitted
[release-branch.go1.23] cmd/trace: also show end stack traces
Fix a regression that appeared in 1.23 when it comes to the stack traces shown in the trace viewer. In 1.22 and earlier, the viewer was always showing end stack traces. In 1.23 and later the viewer started to exclusively show start stack traces. Showing only the start stack traces made it impossible to see the last stack trace produced by a goroutine. It also made it hard to understand why a goroutine went off-cpu, as one had to hunt down the next running slice of the same goroutine. Emit end stack traces in addition to start stack traces to fix the issue. Fixes #70592 Change-Id: Ib22ea61388c1d94cdbc99fae2d207c4dce011a59 Reviewed-on: https://go-review.googlesource.com/c/go/+/631895 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Auto-Submit: Felix Geisendörfer <[email protected]> Reviewed-by: Nick Ripley <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> (cherry picked from commit 6405e60) Reviewed-on: https://go-review.googlesource.com/c/go/+/632075 Reviewed-by: Veronica Silina <[email protected]> Auto-Submit: Veronica Silina <[email protected]>
1 parent 25f042d commit 5164a86

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cmd/trace/gstate.go

+5
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ func (gs *gState[R]) stop(ts trace.Time, stack trace.Stack, ctx *traceContext) {
257257
if gs.lastStopStack != trace.NoStack {
258258
stk = ctx.Stack(viewerFrames(gs.lastStopStack))
259259
}
260+
var endStk int
261+
if stack != trace.NoStack {
262+
endStk = ctx.Stack(viewerFrames(stack))
263+
}
260264
// Check invariants.
261265
if gs.startRunningTime == 0 {
262266
panic("silently broken trace or generator invariant (startRunningTime != 0) not held")
@@ -270,6 +274,7 @@ func (gs *gState[R]) stop(ts trace.Time, stack trace.Stack, ctx *traceContext) {
270274
Dur: ts.Sub(gs.startRunningTime),
271275
Resource: uint64(gs.executing),
272276
Stack: stk,
277+
EndStack: endStk,
273278
})
274279

275280
// Flush completed ranges.

0 commit comments

Comments
 (0)