| 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 |
// Regression test for an issue found in development. |
| 6 |
// |
| 7 |
// GoCreate events can happen on bare Ps in a variety of situations and |
| 8 |
// and earlier version of the parser assumed this wasn't possible. At |
| 9 |
// the time of writing, one such example is goroutines created by expiring |
| 10 |
// timers. |
| 11 |
|
| 12 |
package main |
| 13 |
|
| 14 |
import ( |
| 15 |
"internal/trace" |
| 16 |
"internal/trace/internal/testgen" |
| 17 |
"internal/trace/tracev2" |
| 18 |
"internal/trace/version" |
| 19 |
) |
| 20 |
|
| 21 |
func main() { |
| 22 |
testgen.Main(version.Go122, gen) |
| 23 |
} |
| 24 |
|
| 25 |
func gen(t *testgen.Trace) { |
| 26 |
g1 := t.Generation(1) |
| 27 |
|
| 28 |
// A goroutine gets created on a running P, then starts running. |
| 29 |
b0 := g1.Batch(trace.ThreadID(0), 0) |
| 30 |
b0.Event("ProcStatus", trace.ProcID(0), tracev2.ProcRunning) |
| 31 |
b0.Event("GoCreate", trace.GoID(5), testgen.NoStack, testgen.NoStack) |
| 32 |
b0.Event("GoStart", trace.GoID(5), testgen.Seq(1)) |
| 33 |
b0.Event("GoStop", "whatever", testgen.NoStack) |
| 34 |
} |