mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-30 23:00:29 +00:00
85d28281fb
Update #605
91 lines
2.1 KiB
Go
91 lines
2.1 KiB
Go
// Copyright 2018 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 main
|
|
|
|
import (
|
|
"sync"
|
|
"sync/atomic"
|
|
)
|
|
|
|
type Stat uint64
|
|
|
|
type Stats struct {
|
|
crashes Stat
|
|
crashTypes Stat
|
|
crashSuppressed Stat
|
|
vmRestarts Stat
|
|
newInputs Stat
|
|
execTotal Stat
|
|
hubSendProgAdd Stat
|
|
hubSendProgDel Stat
|
|
hubSendRepro Stat
|
|
hubRecvProg Stat
|
|
hubRecvProgDrop Stat
|
|
hubRecvRepro Stat
|
|
hubRecvReproDrop Stat
|
|
corpusCover Stat
|
|
corpusSignal Stat
|
|
|
|
mu sync.Mutex
|
|
namedStats map[string]uint64
|
|
}
|
|
|
|
func (stats *Stats) all() map[string]uint64 {
|
|
m := map[string]uint64{
|
|
"crashes": stats.crashes.get(),
|
|
"crash types": stats.crashTypes.get(),
|
|
"suppressed": stats.crashSuppressed.get(),
|
|
"vm restarts": stats.vmRestarts.get(),
|
|
"manager new inputs": stats.newInputs.get(),
|
|
"exec total": stats.execTotal.get(),
|
|
"hub: send prog add": stats.hubSendProgAdd.get(),
|
|
"hub: send prog del": stats.hubSendProgDel.get(),
|
|
"hub: send repro": stats.hubSendRepro.get(),
|
|
"hub: recv prog": stats.hubRecvProg.get(),
|
|
"hub: recv prog drop": stats.hubRecvProgDrop.get(),
|
|
"hub: recv repro": stats.hubRecvRepro.get(),
|
|
"hub: recv repro drop": stats.hubRecvReproDrop.get(),
|
|
"cover": stats.corpusCover.get(),
|
|
"signal": stats.corpusSignal.get(),
|
|
}
|
|
stats.mu.Lock()
|
|
defer stats.mu.Unlock()
|
|
for k, v := range stats.namedStats {
|
|
m[k] = v
|
|
}
|
|
return m
|
|
}
|
|
|
|
func (stats *Stats) mergeNamed(named map[string]uint64) {
|
|
stats.mu.Lock()
|
|
defer stats.mu.Unlock()
|
|
if stats.namedStats == nil {
|
|
stats.namedStats = make(map[string]uint64)
|
|
}
|
|
for k, v := range named {
|
|
switch k {
|
|
case "exec total":
|
|
stats.execTotal.add(int(v))
|
|
default:
|
|
stats.namedStats[k] += v
|
|
}
|
|
}
|
|
}
|
|
|
|
func (s *Stat) get() uint64 {
|
|
return atomic.LoadUint64((*uint64)(s))
|
|
}
|
|
|
|
func (s *Stat) inc() {
|
|
s.add(1)
|
|
}
|
|
|
|
func (s *Stat) add(v int) {
|
|
atomic.AddUint64((*uint64)(s), uint64(v))
|
|
}
|
|
|
|
func (s *Stat) set(v int) {
|
|
atomic.StoreUint64((*uint64)(s), uint64(v))
|
|
}
|