github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/trace/v2/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 // Regression test for an issue found in development. 6 // 7 // GoCreate events can happen on bare Ps in a variety of situations and 8 // and earlier version of the parser assumed this wasn't possible. At 9 // the time of writing, one such example is goroutines created by expiring 10 // timers. 11 12 package main 13 14 import ( 15 "github.com/go-asm/go/trace/v2" 16 "github.com/go-asm/go/trace/v2/event/go122" 17 testgen "github.com/go-asm/go/trace/v2/github.com/go-asm/go/testgen/go122" 18 ) 19 20 func main() { 21 testgen.Main(gen) 22 } 23 24 func gen(t *testgen.Trace) { 25 g1 := t.Generation(1) 26 27 // A goroutine gets created on a running P, then starts running. 28 b0 := g1.Batch(trace.ThreadID(0), 0) 29 b0.Event("ProcStatus", trace.ProcID(0), go122.ProcRunning) 30 b0.Event("GoCreate", trace.GoID(5), testgen.NoStack, testgen.NoStack) 31 b0.Event("GoStart", trace.GoID(5), testgen.Seq(1)) 32 b0.Event("GoStop", "whatever", testgen.NoStack) 33 }