diff options
| author | Joey Jiao <quic_jiangenj@quicinc.com> | 2023-08-21 12:30:23 +0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-11-13 07:42:55 +0000 |
| commit | 617b12b1032fb934c8af6f425777d72c92011805 (patch) | |
| tree | 00b2e6f3874ed9f0e4b7746176ff297c17e5092e /tools/syz-db | |
| parent | 62026c85dde44786cae707cb107475e182936149 (diff) | |
tools/syz-db: add print function to print sorted db Records
Ex:
bin/syz-db print corpus.db
Diffstat (limited to 'tools/syz-db')
| -rw-r--r-- | tools/syz-db/syz-db.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/syz-db/syz-db.go b/tools/syz-db/syz-db.go index 857cf41d9..5baa6010b 100644 --- a/tools/syz-db/syz-db.go +++ b/tools/syz-db/syz-db.go @@ -20,6 +20,7 @@ import ( "github.com/google/syzkaller/pkg/tool" "github.com/google/syzkaller/prog" _ "github.com/google/syzkaller/sys" + "golang.org/x/exp/maps" ) func main() { @@ -68,6 +69,11 @@ func main() { usage() } merge(args[1], args[2:], target) + case "print": + if len(args) != 2 { + usage() + } + print(args[1]) default: usage() } @@ -91,6 +97,8 @@ offered: syz-db merge dst-corpus.db add-corpus.db* add-prog* running a deserialization benchmark and printing corpus stats: syz-db bench corpus.db + print corpus db: + syz-db print corpus.db `) os.Exit(1) } @@ -221,3 +229,16 @@ func bench(target *prog.Target, file string) { fmt.Printf("program size: min=%v avg=%v max=%v 10%%=%v 50%%=%v 90%%=%v\n", lens[0], sum/n, lens[n-1], lens[n/10], lens[n/2], lens[n*9/10]) } + +func print(file string) { + db, err := db.Open(file, false) + if err != nil { + tool.Failf("failed to open database: %v", err) + } + keys := maps.Keys(db.Records) + sort.Strings(keys) + for _, key := range keys { + rec := db.Records[key] + fmt.Printf("%v\n%v\n", key, string(rec.Val)) + } +} |
