aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/fuzzer/stats.go
blob: 2eda11107720e22da2803973770e17c409b9faf1 (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
// Copyright 2024 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

package fuzzer

import (
	"sync/atomic"

	"github.com/google/syzkaller/pkg/stat"
	"github.com/google/syzkaller/prog"
)

type Stats struct {
	// Indexed by prog.Syscall.ID + the last element for extra/remote.
	Syscalls []SyscallStats

	statCandidates          *stat.Val
	statNewInputs           *stat.Val
	statJobs                *stat.Val
	statJobsTriage          *stat.Val
	statJobsTriageCandidate *stat.Val
	statJobsSmash           *stat.Val
	statJobsFaultInjection  *stat.Val
	statJobsHints           *stat.Val
	statExecTime            *stat.Val
	statExecGenerate        *stat.Val
	statExecFuzz            *stat.Val
	statExecCandidate       *stat.Val
	statExecTriage          *stat.Val
	statExecMinimize        *stat.Val
	statExecSmash           *stat.Val
	statExecFaultInject     *stat.Val
	statExecHint            *stat.Val
	statExecSeed            *stat.Val
	statExecCollide         *stat.Val
	statCoverOverflows      *stat.Val
	statCompsOverflows      *stat.Val
}

type SyscallStats struct {
	// Number of times coverage buffer for this syscall has overflowed.
	CoverOverflows atomic.Uint64
	// Number of times comparisons buffer for this syscall has overflowed.
	CompsOverflows atomic.Uint64
}

func newStats(target *prog.Target) Stats {
	return Stats{
		Syscalls: make([]SyscallStats, len(target.Syscalls)+1),
		statCandidates: stat.New("candidates", "Number of candidate programs in triage queue",
			stat.Console, stat.Graph("corpus")),
		statNewInputs: stat.New("new inputs", "Potential untriaged corpus candidates",
			stat.Graph("corpus")),
		statJobs: stat.New("fuzzer jobs", "Total running fuzzer jobs", stat.NoGraph),
		statJobsTriage: stat.New("triage jobs", "Running triage jobs", stat.StackedGraph("jobs"),
			stat.Link("/jobs?type=triage")),
		statJobsTriageCandidate: stat.New("candidate triage jobs", "Running candidate triage jobs",
			stat.StackedGraph("jobs"), stat.Link("/jobs?type=triage")),
		statJobsSmash: stat.New("smash jobs", "Running smash jobs", stat.StackedGraph("jobs"),
			stat.Link("/jobs?type=smash")),
		statJobsFaultInjection: stat.New("fault jobs", "Running fault injection jobs", stat.StackedGraph("jobs")),
		statJobsHints: stat.New("hints jobs", "Running hints jobs", stat.StackedGraph("jobs"),
			stat.Link("/jobs?type=hints")),
		statExecTime: stat.New("prog exec time", "Test program execution time (ms)", stat.Distribution{}),
		statExecGenerate: stat.New("exec gen", "Executions of generated programs", stat.Rate{},
			stat.StackedGraph("exec")),
		statExecFuzz: stat.New("exec fuzz", "Executions of mutated programs",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecCandidate: stat.New("exec candidate", "Executions of candidate programs",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecTriage: stat.New("exec triage", "Executions of corpus triage programs",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecMinimize: stat.New("exec minimize", "Executions of programs during minimization",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecSmash: stat.New("exec smash", "Executions of smashed programs",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecFaultInject: stat.New("exec inject", "Executions of fault injection",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecHint: stat.New("exec hints", "Executions of programs generated using hints",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecSeed: stat.New("exec seeds", "Executions of programs for hints extraction",
			stat.Rate{}, stat.StackedGraph("exec")),
		statExecCollide: stat.New("exec collide", "Executions of programs in collide mode",
			stat.Rate{}, stat.StackedGraph("exec")),
		statCoverOverflows: stat.New("cover overflows", "Number of times the coverage buffer overflowed",
			stat.Rate{}, stat.NoGraph),
		statCompsOverflows: stat.New("comps overflows", "Number of times the comparisons buffer overflowed",
			stat.Rate{}, stat.NoGraph),
	}
}