diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-10-11 22:24:29 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-10-11 22:47:40 +0200 |
| commit | 128c09f19df897ccc8e4aacebbc7d4ae5db16ae8 (patch) | |
| tree | 6c86ac2461fc31c1d505e0d79682914b44beb897 | |
| parent | f5c3010743ede1117f51360fd57b39bac2235e6c (diff) | |
syz-manager: expose raw cover in http handler
This adds /rawcover handler which returns a file with all covered so far PCs, e.g.:
0xffffffff8100763e
0xffffffff81007667
...
0xffffffff8100767d
Useful for offline coverage processing, diffing coverage, etc.
In particular allows to do:
curl http://localhost:1234/rawcover | addr2line -e vmlinux
| -rw-r--r-- | syz-manager/html.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/syz-manager/html.go b/syz-manager/html.go index 2ceb4fc48..4c7c6de51 100644 --- a/syz-manager/html.go +++ b/syz-manager/html.go @@ -4,6 +4,7 @@ package main import ( + "bufio" "fmt" "html/template" "io" @@ -35,6 +36,7 @@ func (mgr *Manager) initHttp() { http.HandleFunc("/prio", mgr.httpPrio) http.HandleFunc("/file", mgr.httpFile) http.HandleFunc("/report", mgr.httpReport) + http.HandleFunc("/rawcover", mgr.httpRawCover) ln, err := net.Listen("tcp4", mgr.cfg.Http) if err != nil { @@ -289,6 +291,30 @@ func (mgr *Manager) httpReport(w http.ResponseWriter, r *http.Request) { } } +func (mgr *Manager) httpRawCover(w http.ResponseWriter, r *http.Request) { + mgr.mu.Lock() + defer mgr.mu.Unlock() + + base, err := getVmOffset(mgr.cfg.Vmlinux) + if err != nil { + http.Error(w, fmt.Sprintf("failed to get vmlinux base: %v", err), http.StatusInternalServerError) + return + } + + var cov cover.Cover + for _, inp := range mgr.corpus { + cov = cover.Union(cov, cover.Cover(inp.Cover)) + } + + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + buf := bufio.NewWriter(w) + for _, pc := range cov { + restored := cover.RestorePC(pc, base) - callLen + fmt.Fprintf(buf, "0x%x\n", restored) + } + buf.Flush() +} + func collectCrashes(workdir string) ([]*UICrashType, error) { crashdir := filepath.Join(workdir, "crashes") dirs, err := osutil.ListDir(crashdir) |
