Debian Codegraph @

trace/testdata/generators/go122-syscall-steal-proc-self.go

raw symbols SCIP
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; DO NOT EDIT.
6
7 //go:build go1.23
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/testgen"
20 "golang.org/x/exp/trace/internal/tracev2"
21 "golang.org/x/exp/trace/internal/version"
22 )
23
24 func main() {
25 testgen.Main(version.Go122, gen)
26 }
27
28 func gen(t *testgen.Trace) {
29 t.DisableTimestamps()
30
31 g := t.Generation(1)
32
33 // A goroutine execute a syscall and steals its own P, then starts running
34 // on that P.
35 b0 := g.Batch(trace.ThreadID(0), 0)
36 b0.Event("ProcStatus", trace.ProcID(0), tracev2.ProcRunning)
37 b0.Event("GoStatus", trace.GoID(1), trace.ThreadID(0), tracev2.GoRunning)
38 b0.Event("GoSyscallBegin", testgen.Seq(1), testgen.NoStack)
39 b0.Event("ProcSteal", trace.ProcID(0), testgen.Seq(2), trace.ThreadID(0))
40 b0.Event("ProcStart", trace.ProcID(0), testgen.Seq(3))
41 b0.Event("GoSyscallEndBlocked")
42 }