...
1
2
3
4
5 package raw
6
7 import (
8 "strconv"
9 "strings"
10
11 "internal/trace/event"
12 "internal/trace/version"
13 )
14
15
16
17
18
19
20 type Event struct {
21 Version version.Version
22 Ev event.Type
23 Args []uint64
24 Data []byte
25 }
26
27
28
29
30
31 func (e *Event) String() string {
32 spec := e.Version.Specs()[e.Ev]
33
34 var s strings.Builder
35 s.WriteString(spec.Name)
36 for i := range spec.Args {
37 s.WriteString(" ")
38 s.WriteString(spec.Args[i])
39 s.WriteString("=")
40 s.WriteString(strconv.FormatUint(e.Args[i], 10))
41 }
42 if spec.IsStack {
43 frames := e.Args[len(spec.Args):]
44 for i := 0; i < len(frames); i++ {
45 if i%4 == 0 {
46 s.WriteString("\n\t")
47 } else {
48 s.WriteString(" ")
49 }
50 s.WriteString(frameFields[i%4])
51 s.WriteString("=")
52 s.WriteString(strconv.FormatUint(frames[i], 10))
53 }
54 }
55 if e.Data != nil {
56 s.WriteString("\n\tdata=")
57 s.WriteString(strconv.Quote(string(e.Data)))
58 }
59 return s.String()
60 }
61
View as plain text