• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
12package main
13
14import (
15	"internal/trace"
16	"internal/trace/event/go122"
17	testgen "internal/trace/internal/testgen/go122"
18)
19
20func main() {
21	testgen.Main(gen)
22}
23
24func gen(t *testgen.Trace) {
25	g1 := t.Generation(1)
26
27	// A goroutine gets created on a running P, then starts running.
28	b0 := g1.Batch(trace.ThreadID(0), 0)
29	b0.Event("ProcStatus", trace.ProcID(0), go122.ProcRunning)
30	b0.Event("GoCreate", trace.GoID(5), testgen.NoStack, testgen.NoStack)
31	b0.Event("GoStart", trace.GoID(5), testgen.Seq(1))
32	b0.Event("GoStop", "whatever", testgen.NoStack)
33}
34