diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2026-01-19 15:54:08 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2026-01-20 08:35:12 +0000 |
| commit | 75769ae79e1f7c200dfc52bd7711b2b43f88f28c (patch) | |
| tree | 081441d182ac0e3d05fcdfd9d7bbbc56b6188bc5 /pkg/subsystem/linux/path_coincidence.go | |
| parent | faf99a10ff35487a689ef7a183b1081da5369152 (diff) | |
pkg/subsystem: export debug info
Make it possible to print more debugging information when (re)generating
a subsystem list.
Include parent inference details to the source code itself and add a
-debug flag to list the source files assigned to each subsystem.
Diffstat (limited to 'pkg/subsystem/linux/path_coincidence.go')
| -rw-r--r-- | pkg/subsystem/linux/path_coincidence.go | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/pkg/subsystem/linux/path_coincidence.go b/pkg/subsystem/linux/path_coincidence.go index 44182bd6a..8dab14f28 100644 --- a/pkg/subsystem/linux/path_coincidence.go +++ b/pkg/subsystem/linux/path_coincidence.go @@ -7,22 +7,27 @@ import ( "io/fs" "regexp" "runtime" + "sort" "sync" "github.com/google/syzkaller/pkg/subsystem" ) func BuildCoincidenceMatrix(root fs.FS, list []*subsystem.Subsystem, - excludeRe *regexp.Regexp) (*CoincidenceMatrix, error) { + excludeRe *regexp.Regexp) (*CoincidenceMatrix, *matrixDebugInfo, error) { // Create a matcher. matcher := subsystem.MakePathMatcher(list) chPaths, chResult := extractSubsystems(matcher) // The final consumer goroutine. cm := MakeCoincidenceMatrix() ready := make(chan struct{}) + debug := &matrixDebugInfo{files: map[*subsystem.Subsystem][]string{}} go func() { - for items := range chResult { - cm.Record(items...) + for item := range chResult { + cm.Record(item.list...) + for _, entity := range item.list { + debug.files[entity] = append(debug.files[entity], item.path) + } } ready <- struct{}{} }() @@ -40,23 +45,38 @@ func BuildCoincidenceMatrix(root fs.FS, list []*subsystem.Subsystem, }) close(chPaths) <-ready - return cm, err + for _, list := range debug.files { + sort.Strings(list) + } + return cm, debug, err +} + +type matrixDebugInfo struct { + files map[*subsystem.Subsystem][]string } var ( includePathRe = regexp.MustCompile(`(?:/|\.(?:c|h|S))$`) ) -func extractSubsystems(matcher *subsystem.PathMatcher) (chan<- string, <-chan []*subsystem.Subsystem) { +type extracted struct { + path string + list []*subsystem.Subsystem +} + +func extractSubsystems(matcher *subsystem.PathMatcher) (chan<- string, <-chan extracted) { procs := runtime.NumCPU() - paths, output := make(chan string, procs), make(chan []*subsystem.Subsystem, procs) + paths, output := make(chan string, procs), make(chan extracted, procs) var wg sync.WaitGroup for i := 0; i < procs; i++ { wg.Add(1) go func() { defer wg.Done() for path := range paths { - output <- matcher.Match(path) + output <- extracted{ + path: path, + list: matcher.Match(path), + } } }() } |
