golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/trace/internal/event/go122/event.go (about) 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/v2; DO NOT EDIT. 6 7 //go:build go1.21 8 9 package go122 10 11 import ( 12 "fmt" 13 "golang.org/x/exp/trace/internal/event" 14 ) 15 16 const ( 17 EvNone event.Type = iota // unused 18 19 // Structural events. 20 EvEventBatch // start of per-M batch of events [generation, M ID, timestamp, batch length] 21 EvStacks // start of a section of the stack table [...EvStack] 22 EvStack // stack table entry [ID, ...{PC, func string ID, file string ID, line #}] 23 EvStrings // start of a section of the string dictionary [...EvString] 24 EvString // string dictionary entry [ID, length, string] 25 EvCPUSamples // start of a section of CPU samples [...EvCPUSample] 26 EvCPUSample // CPU profiling sample [timestamp, M ID, P ID, goroutine ID, stack ID] 27 EvFrequency // timestamp units per sec [freq] 28 29 // Procs. 30 EvProcsChange // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack ID] 31 EvProcStart // start of P [timestamp, P ID, P seq] 32 EvProcStop // stop of P [timestamp] 33 EvProcSteal // P was stolen [timestamp, P ID, P seq, M ID] 34 EvProcStatus // P status at the start of a generation [timestamp, P ID, status] 35 36 // Goroutines. 37 EvGoCreate // goroutine creation [timestamp, new goroutine ID, new stack ID, stack ID] 38 EvGoCreateSyscall // goroutine appears in syscall (cgo callback) [timestamp, new goroutine ID] 39 EvGoStart // goroutine starts running [timestamp, goroutine ID, goroutine seq] 40 EvGoDestroy // goroutine ends [timestamp] 41 EvGoDestroySyscall // goroutine ends in syscall (cgo callback) [timestamp] 42 EvGoStop // goroutine yields its time, but is runnable [timestamp, reason, stack ID] 43 EvGoBlock // goroutine blocks [timestamp, reason, stack ID] 44 EvGoUnblock // goroutine is unblocked [timestamp, goroutine ID, goroutine seq, stack ID] 45 EvGoSyscallBegin // syscall enter [timestamp, P seq, stack ID] 46 EvGoSyscallEnd // syscall exit [timestamp] 47 EvGoSyscallEndBlocked // syscall exit and it blocked at some point [timestamp] 48 EvGoStatus // goroutine status at the start of a generation [timestamp, goroutine ID, thread ID, status] 49 50 // STW. 51 EvSTWBegin // STW start [timestamp, kind] 52 EvSTWEnd // STW done [timestamp] 53 54 // GC events. 55 EvGCActive // GC active [timestamp, seq] 56 EvGCBegin // GC start [timestamp, seq, stack ID] 57 EvGCEnd // GC done [timestamp, seq] 58 EvGCSweepActive // GC sweep active [timestamp, P ID] 59 EvGCSweepBegin // GC sweep start [timestamp, stack ID] 60 EvGCSweepEnd // GC sweep done [timestamp, swept bytes, reclaimed bytes] 61 EvGCMarkAssistActive // GC mark assist active [timestamp, goroutine ID] 62 EvGCMarkAssistBegin // GC mark assist start [timestamp, stack ID] 63 EvGCMarkAssistEnd // GC mark assist done [timestamp] 64 EvHeapAlloc // gcController.heapLive change [timestamp, heap alloc in bytes] 65 EvHeapGoal // gcController.heapGoal() change [timestamp, heap goal in bytes] 66 67 // Annotations. 68 EvGoLabel // apply string label to current running goroutine [timestamp, label string ID] 69 EvUserTaskBegin // trace.NewTask [timestamp, internal task ID, internal parent task ID, name string ID, stack ID] 70 EvUserTaskEnd // end of a task [timestamp, internal task ID, stack ID] 71 EvUserRegionBegin // trace.{Start,With}Region [timestamp, internal task ID, name string ID, stack ID] 72 EvUserRegionEnd // trace.{End,With}Region [timestamp, internal task ID, name string ID, stack ID] 73 EvUserLog // trace.Log [timestamp, internal task ID, key string ID, value string ID, stack] 74 75 // Coroutines. Added in Go 1.23. 76 EvGoSwitch // goroutine switch (coroswitch) [timestamp, goroutine ID, goroutine seq] 77 EvGoSwitchDestroy // goroutine switch and destroy [timestamp, goroutine ID, goroutine seq] 78 EvGoCreateBlocked // goroutine creation (starts blocked) [timestamp, new goroutine ID, new stack ID, stack ID] 79 80 // GoStatus with stack. 81 EvGoStatusStack // goroutine status at the start of a generation, with a stack [timestamp, goroutine ID, M ID, status, stack ID] 82 ) 83 84 // EventString returns the name of a Go 1.22 event. 85 func EventString(typ event.Type) string { 86 if int(typ) < len(specs) { 87 return specs[typ].Name 88 } 89 return fmt.Sprintf("Invalid(%d)", typ) 90 } 91 92 func Specs() []event.Spec { 93 return specs[:] 94 } 95 96 var specs = [...]event.Spec{ 97 // "Structural" Events. 98 EvEventBatch: { 99 Name: "EventBatch", 100 Args: []string{"gen", "m", "time", "size"}, 101 }, 102 EvStacks: { 103 Name: "Stacks", 104 }, 105 EvStack: { 106 Name: "Stack", 107 Args: []string{"id", "nframes"}, 108 IsStack: true, 109 }, 110 EvStrings: { 111 Name: "Strings", 112 }, 113 EvString: { 114 Name: "String", 115 Args: []string{"id"}, 116 HasData: true, 117 }, 118 EvCPUSamples: { 119 Name: "CPUSamples", 120 }, 121 EvCPUSample: { 122 Name: "CPUSample", 123 Args: []string{"time", "m", "p", "g", "stack"}, 124 // N.B. There's clearly a timestamp here, but these Events 125 // are special in that they don't appear in the regular 126 // M streams. 127 }, 128 EvFrequency: { 129 Name: "Frequency", 130 Args: []string{"freq"}, 131 }, 132 133 // "Timed" Events. 134 EvProcsChange: { 135 Name: "ProcsChange", 136 Args: []string{"dt", "procs_value", "stack"}, 137 IsTimedEvent: true, 138 StackIDs: []int{2}, 139 }, 140 EvProcStart: { 141 Name: "ProcStart", 142 Args: []string{"dt", "p", "p_seq"}, 143 IsTimedEvent: true, 144 }, 145 EvProcStop: { 146 Name: "ProcStop", 147 Args: []string{"dt"}, 148 IsTimedEvent: true, 149 }, 150 EvProcSteal: { 151 Name: "ProcSteal", 152 Args: []string{"dt", "p", "p_seq", "m"}, 153 IsTimedEvent: true, 154 }, 155 EvProcStatus: { 156 Name: "ProcStatus", 157 Args: []string{"dt", "p", "pstatus"}, 158 IsTimedEvent: true, 159 }, 160 EvGoCreate: { 161 Name: "GoCreate", 162 Args: []string{"dt", "new_g", "new_stack", "stack"}, 163 IsTimedEvent: true, 164 StackIDs: []int{3, 2}, 165 }, 166 EvGoCreateSyscall: { 167 Name: "GoCreateSyscall", 168 Args: []string{"dt", "new_g"}, 169 IsTimedEvent: true, 170 }, 171 EvGoStart: { 172 Name: "GoStart", 173 Args: []string{"dt", "g", "g_seq"}, 174 IsTimedEvent: true, 175 }, 176 EvGoDestroy: { 177 Name: "GoDestroy", 178 Args: []string{"dt"}, 179 IsTimedEvent: true, 180 }, 181 EvGoDestroySyscall: { 182 Name: "GoDestroySyscall", 183 Args: []string{"dt"}, 184 IsTimedEvent: true, 185 }, 186 EvGoStop: { 187 Name: "GoStop", 188 Args: []string{"dt", "reason_string", "stack"}, 189 IsTimedEvent: true, 190 StackIDs: []int{2}, 191 StringIDs: []int{1}, 192 }, 193 EvGoBlock: { 194 Name: "GoBlock", 195 Args: []string{"dt", "reason_string", "stack"}, 196 IsTimedEvent: true, 197 StackIDs: []int{2}, 198 StringIDs: []int{1}, 199 }, 200 EvGoUnblock: { 201 Name: "GoUnblock", 202 Args: []string{"dt", "g", "g_seq", "stack"}, 203 IsTimedEvent: true, 204 StackIDs: []int{3}, 205 }, 206 EvGoSyscallBegin: { 207 Name: "GoSyscallBegin", 208 Args: []string{"dt", "p_seq", "stack"}, 209 IsTimedEvent: true, 210 StackIDs: []int{2}, 211 }, 212 EvGoSyscallEnd: { 213 Name: "GoSyscallEnd", 214 Args: []string{"dt"}, 215 StartEv: EvGoSyscallBegin, 216 IsTimedEvent: true, 217 }, 218 EvGoSyscallEndBlocked: { 219 Name: "GoSyscallEndBlocked", 220 Args: []string{"dt"}, 221 StartEv: EvGoSyscallBegin, 222 IsTimedEvent: true, 223 }, 224 EvGoStatus: { 225 Name: "GoStatus", 226 Args: []string{"dt", "g", "m", "gstatus"}, 227 IsTimedEvent: true, 228 }, 229 EvSTWBegin: { 230 Name: "STWBegin", 231 Args: []string{"dt", "kind_string", "stack"}, 232 IsTimedEvent: true, 233 StackIDs: []int{2}, 234 StringIDs: []int{1}, 235 }, 236 EvSTWEnd: { 237 Name: "STWEnd", 238 Args: []string{"dt"}, 239 StartEv: EvSTWBegin, 240 IsTimedEvent: true, 241 }, 242 EvGCActive: { 243 Name: "GCActive", 244 Args: []string{"dt", "gc_seq"}, 245 IsTimedEvent: true, 246 StartEv: EvGCBegin, 247 }, 248 EvGCBegin: { 249 Name: "GCBegin", 250 Args: []string{"dt", "gc_seq", "stack"}, 251 IsTimedEvent: true, 252 StackIDs: []int{2}, 253 }, 254 EvGCEnd: { 255 Name: "GCEnd", 256 Args: []string{"dt", "gc_seq"}, 257 StartEv: EvGCBegin, 258 IsTimedEvent: true, 259 }, 260 EvGCSweepActive: { 261 Name: "GCSweepActive", 262 Args: []string{"dt", "p"}, 263 StartEv: EvGCSweepBegin, 264 IsTimedEvent: true, 265 }, 266 EvGCSweepBegin: { 267 Name: "GCSweepBegin", 268 Args: []string{"dt", "stack"}, 269 IsTimedEvent: true, 270 StackIDs: []int{1}, 271 }, 272 EvGCSweepEnd: { 273 Name: "GCSweepEnd", 274 Args: []string{"dt", "swept_value", "reclaimed_value"}, 275 StartEv: EvGCSweepBegin, 276 IsTimedEvent: true, 277 }, 278 EvGCMarkAssistActive: { 279 Name: "GCMarkAssistActive", 280 Args: []string{"dt", "g"}, 281 StartEv: EvGCMarkAssistBegin, 282 IsTimedEvent: true, 283 }, 284 EvGCMarkAssistBegin: { 285 Name: "GCMarkAssistBegin", 286 Args: []string{"dt", "stack"}, 287 IsTimedEvent: true, 288 StackIDs: []int{1}, 289 }, 290 EvGCMarkAssistEnd: { 291 Name: "GCMarkAssistEnd", 292 Args: []string{"dt"}, 293 StartEv: EvGCMarkAssistBegin, 294 IsTimedEvent: true, 295 }, 296 EvHeapAlloc: { 297 Name: "HeapAlloc", 298 Args: []string{"dt", "heapalloc_value"}, 299 IsTimedEvent: true, 300 }, 301 EvHeapGoal: { 302 Name: "HeapGoal", 303 Args: []string{"dt", "heapgoal_value"}, 304 IsTimedEvent: true, 305 }, 306 EvGoLabel: { 307 Name: "GoLabel", 308 Args: []string{"dt", "label_string"}, 309 IsTimedEvent: true, 310 StringIDs: []int{1}, 311 }, 312 EvUserTaskBegin: { 313 Name: "UserTaskBegin", 314 Args: []string{"dt", "task", "parent_task", "name_string", "stack"}, 315 IsTimedEvent: true, 316 StackIDs: []int{4}, 317 StringIDs: []int{3}, 318 }, 319 EvUserTaskEnd: { 320 Name: "UserTaskEnd", 321 Args: []string{"dt", "task", "stack"}, 322 IsTimedEvent: true, 323 StackIDs: []int{2}, 324 }, 325 EvUserRegionBegin: { 326 Name: "UserRegionBegin", 327 Args: []string{"dt", "task", "name_string", "stack"}, 328 IsTimedEvent: true, 329 StackIDs: []int{3}, 330 StringIDs: []int{2}, 331 }, 332 EvUserRegionEnd: { 333 Name: "UserRegionEnd", 334 Args: []string{"dt", "task", "name_string", "stack"}, 335 StartEv: EvUserRegionBegin, 336 IsTimedEvent: true, 337 StackIDs: []int{3}, 338 StringIDs: []int{2}, 339 }, 340 EvUserLog: { 341 Name: "UserLog", 342 Args: []string{"dt", "task", "key_string", "value_string", "stack"}, 343 IsTimedEvent: true, 344 StackIDs: []int{4}, 345 StringIDs: []int{2, 3}, 346 }, 347 EvGoSwitch: { 348 Name: "GoSwitch", 349 Args: []string{"dt", "g", "g_seq"}, 350 IsTimedEvent: true, 351 }, 352 EvGoSwitchDestroy: { 353 Name: "GoSwitchDestroy", 354 Args: []string{"dt", "g", "g_seq"}, 355 IsTimedEvent: true, 356 }, 357 EvGoCreateBlocked: { 358 Name: "GoCreateBlocked", 359 Args: []string{"dt", "new_g", "new_stack", "stack"}, 360 IsTimedEvent: true, 361 StackIDs: []int{3, 2}, 362 }, 363 EvGoStatusStack: { 364 Name: "GoStatusStack", 365 Args: []string{"dt", "g", "m", "gstatus", "stack"}, 366 IsTimedEvent: true, 367 StackIDs: []int{4}, 368 }, 369 } 370 371 type GoStatus uint8 372 373 const ( 374 GoBad GoStatus = iota 375 GoRunnable 376 GoRunning 377 GoSyscall 378 GoWaiting 379 ) 380 381 func (s GoStatus) String() string { 382 switch s { 383 case GoRunnable: 384 return "Runnable" 385 case GoRunning: 386 return "Running" 387 case GoSyscall: 388 return "Syscall" 389 case GoWaiting: 390 return "Waiting" 391 } 392 return "Bad" 393 } 394 395 type ProcStatus uint8 396 397 const ( 398 ProcBad ProcStatus = iota 399 ProcRunning 400 ProcIdle 401 ProcSyscall 402 ProcSyscallAbandoned 403 ) 404 405 func (s ProcStatus) String() string { 406 switch s { 407 case ProcRunning: 408 return "Running" 409 case ProcIdle: 410 return "Idle" 411 case ProcSyscall: 412 return "Syscall" 413 } 414 return "Bad" 415 } 416 417 const ( 418 // Various format-specific constants. 419 MaxBatchSize = 64 << 10 420 MaxFramesPerStack = 128 421 MaxStringSize = 1 << 10 422 )