mirror of
https://github.com/golang/go
synced 2024-09-29 23:14:29 -06: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:
parent
bf2a6d1957
commit
5abf00e4f0
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user