From cde826031afb32fc7bc854a2a0da4355f984962e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 20 Jan 2017 18:04:20 +0100 Subject: [PATCH] syz-fuzzer: expose pprof profiling --- syz-fuzzer/fuzzer.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/syz-fuzzer/fuzzer.go b/syz-fuzzer/fuzzer.go index efd7cf64..6f555973 100644 --- a/syz-fuzzer/fuzzer.go +++ b/syz-fuzzer/fuzzer.go @@ -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{})