Debian Codegraph @

trace/internal/tracev2/spec.go

raw symbols SCIP
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; DO NOT EDIT.
6
7 //go:build go1.23
8
9 package tracev2
10
11 // EventType indicates an event's type from which its arguments and semantics can be
12 // derived. Its representation matches the wire format's representation of the event
13 // types that precede all event data.
14 type EventType uint8
15
16 // EventSpec is a specification for a trace event. It contains sufficient information
17 // to perform basic parsing of any trace event for any version of Go.
18 type EventSpec struct {
19 // Name is the human-readable name of the trace event.
20 Name string
21
22 // Args contains the names of each trace event's argument.
23 // Its length determines the number of arguments an event has.
24 //
25 // Argument names follow a certain structure and this structure
26 // is relied on by the testing framework to type-check arguments
27 // and to produce Values for experimental events.
28 //
29 // The structure is:
30 //
31 // (?P<name>[A-Za-z]+)(_(?P<type>[A-Za-z]+))?
32 //
33 // In sum, it's a name followed by an optional type.
34 // If the type is present, it is preceded with an underscore.
35 // Arguments without types will be interpreted as just raw uint64s.
36 // The valid argument types and the Go types they map to are listed
37 // in the ArgTypes variable.
38 Args []string
39
40 // StringIDs indicates which of the arguments are string IDs.
41 StringIDs []int
42
43 // StackIDs indicates which of the arguments are stack IDs.
44 //
45 // The list is not sorted. The first index always refers to
46 // the main stack for the current execution context of the event.
47 StackIDs []int
48
49 // StartEv indicates the event type of the corresponding "start"
50 // event, if this event is an "end," for a pair of events that
51 // represent a time range.
52 StartEv EventType
53
54 // IsTimedEvent indicates whether this is an event that both
55 // appears in the main event stream and is surfaced to the
56 // trace reader.
57 //
58 // Events that are not "timed" are considered "structural"
59 // since they either need significant reinterpretation or
60 // otherwise aren't actually surfaced by the trace reader.
61 IsTimedEvent bool
62
63 // HasData is true if the event has trailer consisting of a
64 // varint length followed by unencoded bytes of some data.
65 //
66 // An event may not be both a timed event and have data.
67 HasData bool
68
69 // IsStack indicates that the event represents a complete
70 // stack trace. Specifically, it means that after the arguments
71 // there's a varint length, followed by 4*length varints. Each
72 // group of 4 represents the PC, file ID, func ID, and line number
73 // in that order.
74 IsStack bool
75
76 // Experiment indicates the ID of an experiment this event is associated
77 // with. If Experiment is not NoExperiment, then the event is experimental
78 // and will be exposed as an EventExperiment.
79 Experiment Experiment
80 }
81
82 // EventArgTypes is a list of valid argument types for use in Args.
83 //
84 // See the documentation of Args for more details.
85 var EventArgTypes = [...]string{
86 "seq", // sequence number
87 "pstatus", // P status
88 "gstatus", // G status
89 "g", // trace.GoID
90 "m", // trace.ThreadID
91 "p", // trace.ProcID
92 "string", // string ID
93 "stack", // stack ID
94 "value", // uint64
95 "task", // trace.TaskID
96 }
97
98 // EventNames is a helper that produces a mapping of event names to event types.
99 func EventNames(specs []EventSpec) map[string]EventType {
100 nameToType := make(map[string]EventType)
101 for i, spec := range specs {
102 nameToType[spec.Name] = EventType(byte(i))
103 }
104 return nameToType
105 }
106
107 // Experiment is an experiment ID that events may be associated with.
108 type Experiment uint
109
110 // NoExperiment is the reserved ID 0 indicating no experiment.
111 const NoExperiment Experiment = 0