]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/objabi: add support for bisect.Matcher debug flags
authorMatthew Dempsky <mdempsky@google.com>
Wed, 9 Aug 2023 07:53:03 +0000 (00:53 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 10 Aug 2023 23:08:09 +0000 (23:08 +0000)
Makes it more convenient to add new bisection targets.

Change-Id: I7ac14018bac1e25751234a2267f8747a281b6088
Reviewed-on: https://go-review.googlesource.com/c/go/+/517616
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/internal/objabi/flag.go

index 847ed48cfb3054a24ff2f5f2ecdceba7e3ee4691..ee7d2fed49efc3ef7ad20becab544f92d9f7c800 100644 (file)
@@ -7,6 +7,7 @@ package objabi
 import (
        "flag"
        "fmt"
+       "internal/bisect"
        "internal/buildcfg"
        "io"
        "log"
@@ -262,8 +263,8 @@ func NewDebugFlag(debug interface{}, debugSSA DebugSSA) *DebugFlag {
 
                switch ptr.(type) {
                default:
-                       panic(fmt.Sprintf("debug.%s has invalid type %v (must be int or string)", f.Name, f.Type))
-               case *int, *string:
+                       panic(fmt.Sprintf("debug.%s has invalid type %v (must be int, string, or *bisect.Matcher)", f.Name, f.Type))
+               case *int, *string, **bisect.Matcher:
                        // ok
                }
                flag.tab[name] = debugField{name, help, concurrent == "ok", ptr}
@@ -328,6 +329,12 @@ func (f *DebugFlag) Set(debugstr string) error {
                                        log.Fatalf("invalid debug value %v", name)
                                }
                                *vp = val
+                       case **bisect.Matcher:
+                               var err error
+                               *vp, err = bisect.New(valstring)
+                               if err != nil {
+                                       log.Fatalf("debug flag %v: %v", name, err)
+                               }
                        default:
                                panic("bad debugtab type")
                        }