syz-fuzzer: expose pprof profiling

This commit is contained in:
Dmitry Vyukov 2017-01-20 18:04:20 +01:00
parent 0298b1afb6
commit cde826031a

View File

@ -13,10 +13,13 @@ import (
"flag"
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"net/rpc"
"net/rpc/jsonrpc"
"os"
"os/signal"
"runtime"
"runtime/debug"
"strconv"
"strings"
@ -41,6 +44,7 @@ var (
flagProcs = flag.Int("procs", 1, "number of parallel test processes")
flagLeak = flag.Bool("leak", false, "detect memory leaks")
flagOutput = flag.String("output", "stdout", "write programs to none/stdout/dmesg/file")
flagPprof = flag.String("pprof", "", "address to serve pprof profiles")
)
const (
@ -114,6 +118,15 @@ func main() {
os.Exit(1)
}()
if *flagPprof != "" {
go func() {
err := http.ListenAndServe(*flagPprof, nil)
Fatalf("failed to serve pprof profiles: %v", err)
}()
} else {
runtime.MemProfileRate = 0
}
corpusCover = make([]cover.Cover, sys.CallCount)
maxCover = make([]cover.Cover, sys.CallCount)
corpusHashes = make(map[Sig]struct{})