]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: indicate sense of hash/bisect match in output
authorDavid Chase <drchase@google.com>
Mon, 22 May 2023 20:58:12 +0000 (16:58 -0400)
committerDavid Chase <drchase@google.com>
Tue, 23 May 2023 17:04:07 +0000 (17:04 +0000)
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 <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

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

index 11b9dcbb1d4c01b3bdbedc59c2c4169323f127de..167b0df4f06ea65678d75db64b049ef2594a7cb0 100644 (file)
@@ -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.
index 086801a2f076ed816e0c4eda1064a0f13ff374e0..62ef2ed4939d64bd4f8de5fc307b477a173a2bab 100644 (file)
@@ -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) {