From 1ef9fe422410d374c9bac2194cd51329fe2a13ae Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 5 Aug 2024 15:08:42 +0200 Subject: syz-manager: move prependExecuting() to packages --- pkg/rpcserver/last_executing.go | 18 ++++++++++++++++++ syz-manager/manager.go | 16 +--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pkg/rpcserver/last_executing.go b/pkg/rpcserver/last_executing.go index 341ae6534..29b854df2 100644 --- a/pkg/rpcserver/last_executing.go +++ b/pkg/rpcserver/last_executing.go @@ -4,8 +4,12 @@ package rpcserver import ( + "bytes" + "fmt" "sort" "time" + + "github.com/google/syzkaller/pkg/report" ) // LastExecuting keeps the given number of last executed programs @@ -66,3 +70,17 @@ func (last *LastExecuting) Collect() []ExecRecord { } return procs } + +func PrependExecuting(rep *report.Report, lastExec []ExecRecord) { + buf := new(bytes.Buffer) + fmt.Fprintf(buf, "last executing test programs:\n\n") + for _, exec := range lastExec { + fmt.Fprintf(buf, "%v ago: executing program %v (id=%v):\n%s\n", exec.Time, exec.Proc, exec.ID, exec.Prog) + } + fmt.Fprintf(buf, "kernel console output (not intermixed with test programs):\n\n") + rep.Output = append(buf.Bytes(), rep.Output...) + n := len(buf.Bytes()) + rep.StartPos += n + rep.EndPos += n + rep.SkipPos += n +} diff --git a/syz-manager/manager.go b/syz-manager/manager.go index 116af87cf..14d34ccda 100644 --- a/syz-manager/manager.go +++ b/syz-manager/manager.go @@ -687,7 +687,7 @@ func (mgr *Manager) fuzzerInstance(ctx context.Context, inst *vm.Instance, updIn rep, vmInfo, err := mgr.runInstanceInner(ctx, inst, injectExec) lastExec, machineInfo := mgr.serv.ShutdownInstance(inst.Index(), rep != nil) if rep != nil { - prependExecuting(rep, lastExec) + rpcserver.PrependExecuting(rep, lastExec) if len(vmInfo) != 0 { machineInfo = append(append(vmInfo, '\n'), machineInfo...) } @@ -753,20 +753,6 @@ func (mgr *Manager) runInstanceInner(ctx context.Context, inst *vm.Instance, return rep, vmInfo, nil } -func prependExecuting(rep *report.Report, lastExec []rpcserver.ExecRecord) { - buf := new(bytes.Buffer) - fmt.Fprintf(buf, "last executing test programs:\n\n") - for _, exec := range lastExec { - fmt.Fprintf(buf, "%v ago: executing program %v (id=%v):\n%s\n", exec.Time, exec.Proc, exec.ID, exec.Prog) - } - fmt.Fprintf(buf, "kernel console output (not intermixed with test programs):\n\n") - rep.Output = append(buf.Bytes(), rep.Output...) - n := len(buf.Bytes()) - rep.StartPos += n - rep.EndPos += n - rep.SkipPos += n -} - func (mgr *Manager) emailCrash(crash *Crash) { if len(mgr.cfg.EmailAddrs) == 0 { return -- cgit mrf-deployment