golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/trace/testdata/generators/go122-go-create-without-running-g.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated by "gen.bash" from internal/trace/v2; DO NOT EDIT. 6 7 //go:build go1.21 8 9 // Regression test for an issue found in development. 10 // 11 // GoCreate events can happen on bare Ps in a variety of situations and 12 // and earlier version of the parser assumed this wasn't possible. At 13 // the time of writing, one such example is goroutines created by expiring 14 // timers. 15 16 package main 17 18 import ( 19 "golang.org/x/exp/trace" 20 "golang.org/x/exp/trace/internal/event/go122" 21 testgen "golang.org/x/exp/trace/internal/testgen/go122" 22 ) 23 24 func main() { 25 testgen.Main(gen) 26 } 27 28 func gen(t *testgen.Trace) { 29 g1 := t.Generation(1) 30 31 // A goroutine gets created on a running P, then starts running. 32 b0 := g1.Batch(trace.ThreadID(0), 0) 33 b0.Event("ProcStatus", trace.ProcID(0), go122.ProcRunning) 34 b0.Event("GoCreate", trace.GoID(5), testgen.NoStack, testgen.NoStack) 35 b0.Event("GoStart", trace.GoID(5), testgen.Seq(1)) 36 b0.Event("GoStop", "whatever", testgen.NoStack) 37 }