golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/trace/testdata/generators/go122-syscall-steal-proc-self.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 // Tests syscall P stealing. 10 // 11 // Specifically, it tests a scenario where a thread 'steals' 12 // a P from itself. It's just a ProcStop with extra steps when 13 // it happens on the same P. 14 15 package main 16 17 import ( 18 "golang.org/x/exp/trace" 19 "golang.org/x/exp/trace/internal/event/go122" 20 testgen "golang.org/x/exp/trace/internal/testgen/go122" 21 ) 22 23 func main() { 24 testgen.Main(gen) 25 } 26 27 func gen(t *testgen.Trace) { 28 t.DisableTimestamps() 29 30 g := t.Generation(1) 31 32 // A goroutine execute a syscall and steals its own P, then starts running 33 // on that P. 34 b0 := g.Batch(trace.ThreadID(0), 0) 35 b0.Event("ProcStatus", trace.ProcID(0), go122.ProcRunning) 36 b0.Event("GoStatus", trace.GoID(1), trace.ThreadID(0), go122.GoRunning) 37 b0.Event("GoSyscallBegin", testgen.Seq(1), testgen.NoStack) 38 b0.Event("ProcSteal", trace.ProcID(0), testgen.Seq(2), trace.ThreadID(0)) 39 b0.Event("ProcStart", trace.ProcID(0), testgen.Seq(3)) 40 b0.Event("GoSyscallEndBlocked") 41 }