aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-base-commit
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2026-02-05 13:19:13 +0100
committerAleksandr Nogikh <nogikh@google.com>2026-02-05 13:23:13 +0000
commit3e783f2632fd7f283ecbb0b487806681da55f97e (patch)
tree1fc8d9d6d29b50cfd46b62eff87388fa6fa73afb /tools/syz-base-commit
parentc6b49b592b6ec4a92a955593e71d847c489bf5e7 (diff)
tools: add syz-base-commit tool
The tool is aimed to facilitate debugging of the cases when the blob-based base commit functionality did not work as expected or to determine the missing remote trees.
Diffstat (limited to 'tools/syz-base-commit')
-rw-r--r--tools/syz-base-commit/main.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/syz-base-commit/main.go b/tools/syz-base-commit/main.go
new file mode 100644
index 000000000..f5af3b075
--- /dev/null
+++ b/tools/syz-base-commit/main.go
@@ -0,0 +1,50 @@
+// Copyright 2020 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+// syz-base-commit is a tool for debugging the blob-based base commit detection functionality.
+
+package main
+
+import (
+ "flag"
+ "log"
+ "os"
+
+ "github.com/google/syzkaller/pkg/debugtracer"
+ "github.com/google/syzkaller/pkg/tool"
+ "github.com/google/syzkaller/pkg/vcs"
+)
+
+var (
+ flagRepo = flag.String("sourcedir", "", "path to the Linux kernel repository")
+)
+
+func main() {
+ defer tool.Init()()
+ args := flag.Args()
+ if *flagRepo == "" || len(args) != 1 {
+ tool.Failf("expected format: syz-base-commit --sourcedir ./linux-repo some-patch.diff")
+ }
+ log.Printf("note: the tool runs much faster after a `git commit-graph write --reachable`")
+ diff, err := os.ReadFile(args[0])
+ if err != nil {
+ tool.Fail(err)
+ }
+ git := &vcs.Git{
+ Dir: *flagRepo,
+ }
+ commits, err := git.BaseForDiff(diff, &debugtracer.GenericTracer{
+ TraceWriter: os.Stderr,
+ })
+ if err != nil {
+ tool.Fail(err)
+ }
+ if len(commits) == 0 {
+ log.Printf("no suitable commits found!")
+ os.Exit(0)
+ }
+ log.Printf("found %d candidates:", len(commits))
+ for _, commit := range commits {
+ log.Printf("%+v", commit)
+ }
+}