Debian Codegraph @

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

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