aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2023-06-15 13:56:02 -0400
committerDavid Chase <drchase@google.com>2023-06-20 14:35:37 +0000
commit02789816c46993c1c093500d94b8ebb4b622b77a (patch)
treef6167b98c8f130e56d4957975a148e373fb3df2b
parent98617fd23fa799173c33741987d41ee64cbb2a4f (diff)
downloadgo-02789816c46993c1c093500d94b8ebb4b622b77a.tar.gz
go-02789816c46993c1c093500d94b8ebb4b622b77a.zip
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>
-rw-r--r--src/internal/bisect/bisect.go30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/internal/bisect/bisect.go b/src/internal/bisect/bisect.go
index 37f76a4271..48c796e54a 100644
--- a/src/internal/bisect/bisect.go
+++ b/src/internal/bisect/bisect.go
@@ -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 {