1
0
mirror of https://github.com/golang/go synced 2024-11-17 17:04:47 -07:00

cmd/internal/objabi: add support for bisect.Matcher debug flags

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>
This commit is contained in:
Matthew Dempsky 2023-08-09 00:53:03 -07:00
parent bf2a6d1957
commit 5abf00e4f0

View File

@ -7,6 +7,7 @@ package objabi
import ( import (
"flag" "flag"
"fmt" "fmt"
"internal/bisect"
"internal/buildcfg" "internal/buildcfg"
"io" "io"
"log" "log"
@ -262,8 +263,8 @@ func NewDebugFlag(debug interface{}, debugSSA DebugSSA) *DebugFlag {
switch ptr.(type) { switch ptr.(type) {
default: default:
panic(fmt.Sprintf("debug.%s has invalid type %v (must be int or string)", f.Name, f.Type)) panic(fmt.Sprintf("debug.%s has invalid type %v (must be int, string, or *bisect.Matcher)", f.Name, f.Type))
case *int, *string: case *int, *string, **bisect.Matcher:
// ok // ok
} }
flag.tab[name] = debugField{name, help, concurrent == "ok", ptr} 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) log.Fatalf("invalid debug value %v", name)
} }
*vp = val *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: default:
panic("bad debugtab type") panic("bad debugtab type")
} }