...

Source file src/internal/trace/v2/testdata/generators/go122-syscall-steal-proc-sitting-in-syscall.go

Documentation: internal/trace/v2/testdata/generators

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

View as plain text