aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-02-07 16:20:16 +0100
committerAleksandr Nogikh <wp32pw@gmail.com>2023-02-16 11:29:36 +0100
commit2f0f5f6d638c8a24c1b8b04ebc9e303d330644cc (patch)
treee577540c32b8f5f45a0b7b5bbf286a180fcab82f /pkg
parent6e13575de15a4d480e4edf604d5f83ca3ee1c64e (diff)
dashboard/app: infer bug subsystems from crashes
After each saved crash, invoke the new pkg/subsystem machinery to infer the subsystem list. Use 5 crashes with biggest priority to base the inference on.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/subsystem/list.go4
-rw-r--r--pkg/subsystem/service.go44
2 files changed, 48 insertions, 0 deletions
diff --git a/pkg/subsystem/list.go b/pkg/subsystem/list.go
index 7842f8620..d512a3fe1 100644
--- a/pkg/subsystem/list.go
+++ b/pkg/subsystem/list.go
@@ -26,3 +26,7 @@ func RegisterList(name string, list []*Subsystem) {
func GetList(name string) []*Subsystem {
return lists[name]
}
+
+func ListService(name string) *Service {
+ return MustMakeService(lists[name])
+}
diff --git a/pkg/subsystem/service.go b/pkg/subsystem/service.go
new file mode 100644
index 000000000..e3dabcfce
--- /dev/null
+++ b/pkg/subsystem/service.go
@@ -0,0 +1,44 @@
+// Copyright 2023 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.
+
+package subsystem
+
+import (
+ "fmt"
+)
+
+type Service struct {
+ *Extractor
+ perName map[string]*Subsystem
+}
+
+func MustMakeService(list []*Subsystem) *Service {
+ service, err := MakeService(list)
+ if err != nil {
+ panic(fmt.Sprintf("service creation failed: %s", err))
+ }
+ return service
+}
+
+func MakeService(list []*Subsystem) (*Service, error) {
+ extractor := MakeExtractor(list)
+ perName := map[string]*Subsystem{}
+ for _, item := range list {
+ if item.Name == "" {
+ return nil, fmt.Errorf("input contains a subsystem without a name")
+ }
+ if perName[item.Name] != nil {
+ return nil, fmt.Errorf("collision on %#v name", item.Name)
+ }
+ perName[item.Name] = item
+ }
+
+ return &Service{
+ Extractor: extractor,
+ perName: perName,
+ }, nil
+}
+
+func (s *Service) ByName(name string) *Subsystem {
+ return s.perName[name]
+}