1
2
3
4
5
6
7
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
18
19
20 EvEventBatch
21 EvStacks
22 EvStack
23 EvStrings
24 EvString
25 EvCPUSamples
26 EvCPUSample
27 EvFrequency
28
29
30 EvProcsChange
31 EvProcStart
32 EvProcStop
33 EvProcSteal
34 EvProcStatus
35
36
37 EvGoCreate
38 EvGoCreateSyscall
39 EvGoStart
40 EvGoDestroy
41 EvGoDestroySyscall
42 EvGoStop
43 EvGoBlock
44 EvGoUnblock
45 EvGoSyscallBegin
46 EvGoSyscallEnd
47 EvGoSyscallEndBlocked
48 EvGoStatus
49
50
51 EvSTWBegin
52 EvSTWEnd
53
54
55 EvGCActive
56 EvGCBegin
57 EvGCEnd
58 EvGCSweepActive
59 EvGCSweepBegin
60 EvGCSweepEnd
61 EvGCMarkAssistActive
62 EvGCMarkAssistBegin
63 EvGCMarkAssistEnd
64 EvHeapAlloc
65 EvHeapGoal
66
67
68 EvGoLabel
69 EvUserTaskBegin
70 EvUserTaskEnd
71 EvUserRegionBegin
72 EvUserRegionEnd
73 EvUserLog
74
75
76 EvGoSwitch
77 EvGoSwitchDestroy
78 EvGoCreateBlocked
79
80
81 EvGoStatusStack
82 )
83
84
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
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
125
126
127 },
128 EvFrequency: {
129 Name: "Frequency",
130 Args: []string{"freq"},
131 },
132
133
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
419 MaxBatchSize = 64 << 10
420 MaxFramesPerStack = 128
421 MaxStringSize = 1 << 10
422 )
423
View as plain text