Skip to content

Commit

Permalink
cmd/internal/objabi: add support for bisect.Matcher debug flags
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Matthew Dempsky <[email protected]>
Reviewed-by: David Chase <[email protected]>
  • Loading branch information
mdempsky committed Aug 10, 2023
1 parent bf2a6d1 commit 5abf00e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cmd/internal/objabi/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package objabi
import (
"flag"
"fmt"
"internal/bisect"
"internal/buildcfg"
"io"
"log"
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 5abf00e

Please sign in to comment.