1// Copyright 2014 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
5package trace
6
7// Frame is a frame in stack traces.
8type Frame struct {
9	PC   uint64
10	Fn   string
11	File string
12	Line int
13}
14
15const (
16	// Special P identifiers:
17	FakeP    = 1000000 + iota
18	TimerP   // depicts timer unblocks
19	NetpollP // depicts network unblocks
20	SyscallP // depicts returns from syscalls
21	GCP      // depicts GC state
22	ProfileP // depicts recording of CPU profile samples
23)
24
25// Event types in the trace.
26// Verbatim copy from src/runtime/trace.go with the "trace" prefix removed.
27const (
28	EvNone              = 0  // unused
29	EvBatch             = 1  // start of per-P batch of events [pid, timestamp]
30	EvFrequency         = 2  // contains tracer timer frequency [frequency (ticks per second)]
31	EvStack             = 3  // stack [stack id, number of PCs, array of {PC, func string ID, file string ID, line}]
32	EvGomaxprocs        = 4  // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack id]
33	EvProcStart         = 5  // start of P [timestamp, thread id]
34	EvProcStop          = 6  // stop of P [timestamp]
35	EvGCStart           = 7  // GC start [timestamp, seq, stack id]
36	EvGCDone            = 8  // GC done [timestamp]
37	EvSTWStart          = 9  // GC mark termination start [timestamp, kind]
38	EvSTWDone           = 10 // GC mark termination done [timestamp]
39	EvGCSweepStart      = 11 // GC sweep start [timestamp, stack id]
40	EvGCSweepDone       = 12 // GC sweep done [timestamp, swept, reclaimed]
41	EvGoCreate          = 13 // goroutine creation [timestamp, new goroutine id, new stack id, stack id]
42	EvGoStart           = 14 // goroutine starts running [timestamp, goroutine id, seq]
43	EvGoEnd             = 15 // goroutine ends [timestamp]
44	EvGoStop            = 16 // goroutine stops (like in select{}) [timestamp, stack]
45	EvGoSched           = 17 // goroutine calls Gosched [timestamp, stack]
46	EvGoPreempt         = 18 // goroutine is preempted [timestamp, stack]
47	EvGoSleep           = 19 // goroutine calls Sleep [timestamp, stack]
48	EvGoBlock           = 20 // goroutine blocks [timestamp, stack]
49	EvGoUnblock         = 21 // goroutine is unblocked [timestamp, goroutine id, seq, stack]
50	EvGoBlockSend       = 22 // goroutine blocks on chan send [timestamp, stack]
51	EvGoBlockRecv       = 23 // goroutine blocks on chan recv [timestamp, stack]
52	EvGoBlockSelect     = 24 // goroutine blocks on select [timestamp, stack]
53	EvGoBlockSync       = 25 // goroutine blocks on Mutex/RWMutex [timestamp, stack]
54	EvGoBlockCond       = 26 // goroutine blocks on Cond [timestamp, stack]
55	EvGoBlockNet        = 27 // goroutine blocks on network [timestamp, stack]
56	EvGoSysCall         = 28 // syscall enter [timestamp, stack]
57	EvGoSysExit         = 29 // syscall exit [timestamp, goroutine id, seq, real timestamp]
58	EvGoSysBlock        = 30 // syscall blocks [timestamp]
59	EvGoWaiting         = 31 // denotes that goroutine is blocked when tracing starts [timestamp, goroutine id]
60	EvGoInSyscall       = 32 // denotes that goroutine is in syscall when tracing starts [timestamp, goroutine id]
61	EvHeapAlloc         = 33 // gcController.heapLive change [timestamp, heap live bytes]
62	EvHeapGoal          = 34 // gcController.heapGoal change [timestamp, heap goal bytes]
63	EvTimerGoroutine    = 35 // denotes timer goroutine [timer goroutine id]
64	EvFutileWakeup      = 36 // denotes that the previous wakeup of this goroutine was futile [timestamp]
65	EvString            = 37 // string dictionary entry [ID, length, string]
66	EvGoStartLocal      = 38 // goroutine starts running on the same P as the last event [timestamp, goroutine id]
67	EvGoUnblockLocal    = 39 // goroutine is unblocked on the same P as the last event [timestamp, goroutine id, stack]
68	EvGoSysExitLocal    = 40 // syscall exit on the same P as the last event [timestamp, goroutine id, real timestamp]
69	EvGoStartLabel      = 41 // goroutine starts running with label [timestamp, goroutine id, seq, label string id]
70	EvGoBlockGC         = 42 // goroutine blocks on GC assist [timestamp, stack]
71	EvGCMarkAssistStart = 43 // GC mark assist start [timestamp, stack]
72	EvGCMarkAssistDone  = 44 // GC mark assist done [timestamp]
73	EvUserTaskCreate    = 45 // trace.NewTask [timestamp, internal task id, internal parent id, name string, stack]
74	EvUserTaskEnd       = 46 // end of task [timestamp, internal task id, stack]
75	EvUserRegion        = 47 // trace.WithRegion [timestamp, internal task id, mode(0:start, 1:end), name string, stack]
76	EvUserLog           = 48 // trace.Log [timestamp, internal id, key string id, stack, value string]
77	EvCPUSample         = 49 // CPU profiling sample [timestamp, real timestamp, real P id (-1 when absent), goroutine id, stack]
78	EvCount             = 50
79)
80