internal/bisect: add 'q' hash option for quiet hash behavior switching

This is intended for the specific case of 'fmahash=qn' where someone
wants to disable fma without all the hash-search-handshake output.
There are cases where arm64, ppc64, and s390x users might want to do
this.

Change-Id: Iaf46c68a00d7c9f7f82fd98a4548b72610f84bed
Reviewed-on: https://go-review.googlesource.com/c/go/+/503776
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
David Chase
2023-06-15 13:56:02 -04:00
parent 98617fd23f
commit 02789816c4

View File

@@ -198,10 +198,20 @@ func New(pattern string) (*Matcher, error) {
m := new(Matcher)
// Allow multiple v, so that “bisect cmd vPATTERN” can force verbose all the time.
p := pattern
// Special case for leading 'q' so that 'qn' quietly disables, e.g. fmahash=qn to disable fma
// Any instance of 'v' disables 'q'.
if len(p) > 0 && p[0] == 'q' {
m.quiet = true
p = p[1:]
if p == "" {
return nil, &parseError{"invalid pattern syntax: " + pattern}
}
}
// Allow multiple v, so that “bisect cmd vPATTERN” can force verbose all the time.
for len(p) > 0 && p[0] == 'v' {
m.verbose = true
m.quiet = false
p = p[1:]
if p == "" {
return nil, &parseError{"invalid pattern syntax: " + pattern}
@@ -297,7 +307,8 @@ func New(pattern string) (*Matcher, error) {
// A Matcher is the parsed, compiled form of a PATTERN string.
// The nil *Matcher is valid: it has all changes enabled but none reported.
type Matcher struct {
verbose bool
verbose bool // annotate reporting with human-helpful information
quiet bool // disables all reporting. reset if verbose is true. use case is -d=fmahash=qn
enable bool // when true, list is for “enable and report” (when false, “disable and report”)
list []cond // conditions; later ones win over earlier ones
dedup atomicPointerDedup
@@ -339,20 +350,19 @@ func (m *Matcher) ShouldEnable(id uint64) bool {
if m == nil {
return true
}
for i := len(m.list) - 1; i >= 0; i-- {
c := &m.list[i]
if id&c.mask == c.bits {
return c.result == m.enable
}
}
return false == m.enable
return m.matchResult(id) == m.enable
}
// ShouldPrint reports whether to print identifying information about the change with the given id.
func (m *Matcher) ShouldPrint(id uint64) bool {
if m == nil {
if m == nil || m.quiet {
return false
}
return m.matchResult(id)
}
// matchResult returns the result from the first condition that matches id.
func (m *Matcher) matchResult(id uint64) bool {
for i := len(m.list) - 1; i >= 0; i-- {
c := &m.list[i]
if id&c.mask == c.bits {