From: David Chase Date: Mon, 22 May 2023 20:58:12 +0000 (-0400) Subject: cmd/compile: indicate sense of hash/bisect match in output X-Git-Tag: go1.21rc1~349 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9dd0c7fc78cb19000f15bd58a3a1ab5ae1c6a84b;p=gostls13.git cmd/compile: indicate sense of hash/bisect match in output If a hash match is "disabled" (!enabled) indicate that in the output with DISABLED. This is helpful in ensuring that multiple package-directed command-line flags have the intended behavior, e.g. ``` go build -a \ -gcflags=all=-d=gossahash=vn \ -gcflags=runtime=-d=gossahash=vy \ std ``` Output looks like [DISABLED] [bisect-match 0x11d0ee166d9d61b4] or (w/ "v"-prefixed hashcode ) sort/slice.go:23:29 note [DISABLED] [bisect-match 0xa5252e1c1b85f2ec] gossahash triggered sort/slice.go:23:29 note [DISABLED] 100001011111001011101100 Change-Id: I797e02b3132f9781d97bacd0dcd2e80af0035cd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/497216 Reviewed-by: Russ Cox Run-TryBot: David Chase TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/base/hashdebug.go b/src/cmd/compile/internal/base/hashdebug.go index 11b9dcbb1d..167b0df4f0 100644 --- a/src/cmd/compile/internal/base/hashdebug.go +++ b/src/cmd/compile/internal/base/hashdebug.go @@ -286,19 +286,25 @@ func (d *HashDebug) matchPos(ctxt *obj.Link, pos src.XPos, note func() string) b // change is selected. func (d *HashDebug) matchAndLog(hash uint64, text, note func() string) bool { if d.bisect != nil { + enabled := d.bisect.ShouldEnable(hash) if d.bisect.ShouldPrint(hash) { + disabled := "" + if !enabled { + disabled = " [DISABLED]" + } var t string if !d.bisect.MarkerOnly() { t = text() if note != nil { if n := note(); n != "" { - t += ": " + n + t += ": " + n + disabled + disabled = "" } } } - d.log(d.name, hash, t) + d.log(d.name, hash, strings.TrimSpace(t+disabled)) } - return d.bisect.ShouldEnable(hash) + return enabled } // TODO: Delete rest of function body when we switch to bisect-only. diff --git a/src/cmd/compile/internal/base/hashdebug_test.go b/src/cmd/compile/internal/base/hashdebug_test.go index 086801a2f0..62ef2ed493 100644 --- a/src/cmd/compile/internal/base/hashdebug_test.go +++ b/src/cmd/compile/internal/base/hashdebug_test.go @@ -93,8 +93,8 @@ func TestNMatch(t *testing.T) { if check { t.Errorf("GOSSAHASH=n should NOT have matched for 'bar', '0'") } - wantPrefix(t, msg, "bar.0 [bisect-match ") - wantContains(t, msg, "\nGOSSAHASH triggered bar.0 010100100011100101011110") + wantPrefix(t, msg, "bar.0 [DISABLED] [bisect-match ") + wantContains(t, msg, "\nGOSSAHASH triggered bar.0 [DISABLED] 010100100011100101011110") } func TestHashNoMatch(t *testing.T) {