summaryrefslogtreecommitdiff
path: root/internal/globalfilter/pair.go
blob: 7aca33131223c5058d0702b067c499b54a146001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package globalfilter

import (
	"ior/internal/event"
	"ior/internal/types"
)

func MatchPair(filter Filter, pair *event.Pair) bool {
	return filter.MatchPair(pair)
}

type pairCandidate struct {
	pair *event.Pair
}

func (p pairCandidate) SyscallValue() string {
	if p.pair == nil || p.pair.EnterEv == nil {
		return ""
	}
	return p.pair.EnterEv.GetTraceId().Name()
}

func (p pairCandidate) CommValue() string {
	if p.pair == nil {
		return ""
	}
	return p.pair.Comm
}

func (p pairCandidate) FileValue() string {
	if p.pair == nil || p.pair.File == nil {
		return ""
	}
	return p.pair.File.Name()
}

func (p pairCandidate) PIDValue() uint32 {
	if p.pair == nil || p.pair.EnterEv == nil {
		return 0
	}
	return p.pair.EnterEv.GetPid()
}

func (p pairCandidate) TIDValue() uint32 {
	if p.pair == nil || p.pair.EnterEv == nil {
		return 0
	}
	return p.pair.EnterEv.GetTid()
}

func (p pairCandidate) FDValue() int32 {
	if p.pair == nil {
		return -1
	}
	fd, ok := p.pair.FileDescriptor()
	if !ok {
		return -1
	}
	return fd
}

func (p pairCandidate) LatencyValue() uint64 {
	if p.pair == nil {
		return 0
	}
	return p.pair.Duration
}

func (p pairCandidate) GapValue() uint64 {
	if p.pair == nil {
		return 0
	}
	return p.pair.DurationToPrev
}

func (p pairCandidate) BytesValue() uint64 {
	if p.pair == nil {
		return 0
	}
	return p.pair.Bytes
}

func (p pairCandidate) ReturnValue() int64 {
	if p.pair == nil {
		return 0
	}
	retEvent, ok := p.pair.ExitEv.(*types.RetEvent)
	if !ok {
		return 0
	}
	return retEvent.Ret
}

func (p pairCandidate) ErrorValue() bool {
	return p.ReturnValue() < 0
}