golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/trace/testdata/generators/go122-syscall-steal-proc-sitting-in-syscall.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 from a goroutine and thread
    10  // that have been in a syscall the entire generation.
    11  
    12  package main
    13  
    14  import (
    15  	"golang.org/x/exp/trace"
    16  	"golang.org/x/exp/trace/internal/event/go122"
    17  	testgen "golang.org/x/exp/trace/internal/testgen/go122"
    18  )
    19  
    20  func main() {
    21  	testgen.Main(gen)
    22  }
    23  
    24  func gen(t *testgen.Trace) {
    25  	g := t.Generation(1)
    26  
    27  	// Steal proc from a goroutine that's been blocked
    28  	// in a syscall the entire generation.
    29  	b0 := g.Batch(trace.ThreadID(0), 0)
    30  	b0.Event("ProcStatus", trace.ProcID(0), go122.ProcSyscallAbandoned)
    31  	b0.Event("ProcSteal", trace.ProcID(0), testgen.Seq(1), trace.ThreadID(1))
    32  
    33  	// Status event for a goroutine blocked in a syscall for the entire generation.
    34  	bz := g.Batch(trace.NoThread, 0)
    35  	bz.Event("GoStatus", trace.GoID(1), trace.ThreadID(1), go122.GoSyscall)
    36  }