diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-08-05 15:08:42 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-08-06 08:24:55 +0000 |
| commit | 1ef9fe422410d374c9bac2194cd51329fe2a13ae (patch) | |
| tree | 0199b04c1ccccd99bd0e9c6dbdf42a550cbf02f8 | |
| parent | a3f4678cf05abc5cc55d005e3446da56f60b7ad1 (diff) | |
syz-manager: move prependExecuting() to packages
| -rw-r--r-- | pkg/rpcserver/last_executing.go | 18 | ||||
| -rw-r--r-- | 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 |
