Skip to content

Commit 9dd0c7f

Browse files
committed
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 <[email protected]> Run-TryBot: David Chase <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent e1e10e6 commit 9dd0c7f

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/cmd/compile/internal/base/hashdebug.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,25 @@ func (d *HashDebug) matchPos(ctxt *obj.Link, pos src.XPos, note func() string) b
286286
// change is selected.
287287
func (d *HashDebug) matchAndLog(hash uint64, text, note func() string) bool {
288288
if d.bisect != nil {
289+
enabled := d.bisect.ShouldEnable(hash)
289290
if d.bisect.ShouldPrint(hash) {
291+
disabled := ""
292+
if !enabled {
293+
disabled = " [DISABLED]"
294+
}
290295
var t string
291296
if !d.bisect.MarkerOnly() {
292297
t = text()
293298
if note != nil {
294299
if n := note(); n != "" {
295-
t += ": " + n
300+
t += ": " + n + disabled
301+
disabled = ""
296302
}
297303
}
298304
}
299-
d.log(d.name, hash, t)
305+
d.log(d.name, hash, strings.TrimSpace(t+disabled))
300306
}
301-
return d.bisect.ShouldEnable(hash)
307+
return enabled
302308
}
303309

304310
// TODO: Delete rest of function body when we switch to bisect-only.

src/cmd/compile/internal/base/hashdebug_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func TestNMatch(t *testing.T) {
9393
if check {
9494
t.Errorf("GOSSAHASH=n should NOT have matched for 'bar', '0'")
9595
}
96-
wantPrefix(t, msg, "bar.0 [bisect-match ")
97-
wantContains(t, msg, "\nGOSSAHASH triggered bar.0 010100100011100101011110")
96+
wantPrefix(t, msg, "bar.0 [DISABLED] [bisect-match ")
97+
wantContains(t, msg, "\nGOSSAHASH triggered bar.0 [DISABLED] 010100100011100101011110")
9898
}
9999

100100
func TestHashNoMatch(t *testing.T) {

0 commit comments

Comments
 (0)