From 7d02db5adbb376babbbd3199f8c530e468292727 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 19 Nov 2024 16:10:32 +0100 Subject: pkg/manager: show number of programs that contain each syscall Currently we show number of programs that are added to the corpus b/c of a particular syscall. Also show total number of programs in the corpus that contain each syscall. This is different from the first thing. --- pkg/manager/html/syscalls.html | 4 +++- pkg/manager/http.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/manager/html/syscalls.html b/pkg/manager/html/syscalls.html index cb6991f42..e3edfcabf 100644 --- a/pkg/manager/html/syscalls.html +++ b/pkg/manager/html/syscalls.html @@ -7,7 +7,8 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the Per-syscall coverage: Syscall - Inputs + Inputs + Total Coverage Prio @@ -15,6 +16,7 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the {{$c.Name}}{{if $c.ID }} [{{$c.ID}}]{{end}} {{$c.Inputs}} + {{$c.Total}} {{$c.Cover}} prio diff --git a/pkg/manager/http.go b/pkg/manager/http.go index 65407ec90..81affcf7e 100644 --- a/pkg/manager/http.go +++ b/pkg/manager/http.go @@ -186,6 +186,7 @@ func (serv *HTTPServer) textPage(w http.ResponseWriter, r *http.Request, title s func (serv *HTTPServer) httpSyscalls(w http.ResponseWriter, r *http.Request) { var calls map[string]*corpus.CallCov + total := make(map[string]int) syscallsObj := serv.EnabledSyscalls.Load() corpusObj := serv.Corpus.Load() if corpusObj != nil && syscallsObj != nil { @@ -196,6 +197,17 @@ func (serv *HTTPServer) httpSyscalls(w http.ResponseWriter, r *http.Request) { calls[call.Name] = new(corpus.CallCov) } } + // Count number of programs that include each call. + last := make(map[string]*prog.Prog) + for _, inp := range corpusObj.Items() { + for _, call := range inp.Prog.Calls { + name := call.Meta.Name + if last[name] != inp.Prog { + total[name]++ + } + last[name] = inp.Prog + } + } } data := &UISyscallsData{ UIPageHeader: serv.pageHeader(r, "syscalls"), @@ -209,6 +221,7 @@ func (serv *HTTPServer) httpSyscalls(w http.ResponseWriter, r *http.Request) { Name: c, ID: syscallID, Inputs: cc.Count, + Total: total[c], Cover: len(cc.Cover), }) } @@ -953,6 +966,7 @@ type UICallType struct { Name string ID *int Inputs int + Total int Cover int } -- cgit mrf-deployment