]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: iexport debug crumbs for toolstash
authorMatthew Dempsky <mdempsky@google.com>
Tue, 8 Dec 2020 09:28:57 +0000 (01:28 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 9 Dec 2020 17:17:31 +0000 (17:17 +0000)
Prints offsets for declarations, inline bodies, and strings when -v is
used. Still not much, but hopefully useful for narrowing down the
cause of export data differences.

Change-Id: I9b2e4a3d55b92823fa45a39923e8c4b25303693c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276112
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/iexport.go

index b1cc9a3dd97e81b448cf81cc402733ea78954dc8..14356013de8bb99b9fdc6e96d7e33bbc4bf6bcb9 100644 (file)
@@ -290,6 +290,10 @@ func iexport(out *bufio.Writer) {
        w.writeIndex(p.inlineIndex, false)
        w.flush()
 
+       if *base.Flag.LowerV {
+               fmt.Printf("export: hdr strings %v, data %v, index %v\n", p.strings.Len(), dataLen, p.data0.Len())
+       }
+
        // Assemble header.
        var hdr intWriter
        hdr.WriteByte('i')
@@ -389,6 +393,10 @@ func (p *iexporter) stringOff(s string) uint64 {
                off = uint64(p.strings.Len())
                p.stringIndex[s] = off
 
+               if *base.Flag.LowerV {
+                       fmt.Printf("export: str %v %.40q\n", off, s)
+               }
+
                p.strings.uint64(uint64(len(s)))
                p.strings.WriteString(s)
        }
@@ -511,20 +519,28 @@ func (p *iexporter) doDecl(n *ir.Name) {
                base.Fatalf("unexpected node: %v", n)
        }
 
-       p.declIndex[n.Sym()] = w.flush()
+       w.finish("dcl", p.declIndex, n.Sym())
 }
 
 func (w *exportWriter) tag(tag byte) {
        w.data.WriteByte(tag)
 }
 
+func (w *exportWriter) finish(what string, index map[*types.Sym]uint64, sym *types.Sym) {
+       off := w.flush()
+       if *base.Flag.LowerV {
+               fmt.Printf("export: %v %v %v\n", what, off, sym)
+       }
+       index[sym] = off
+}
+
 func (p *iexporter) doInline(f *ir.Name) {
        w := p.newWriter()
        w.setPkg(fnpkg(f), false)
 
        w.stmtList(ir.AsNodes(f.Func().Inl.Body))
 
-       p.inlineIndex[f.Sym()] = w.flush()
+       w.finish("inl", p.inlineIndex, f.Sym())
 }
 
 func (w *exportWriter) pos(pos src.XPos) {
@@ -625,7 +641,11 @@ func (p *iexporter) typOff(t *types.Type) uint64 {
        if !ok {
                w := p.newWriter()
                w.doTyp(t)
-               off = predeclReserved + w.flush()
+               rawOff := w.flush()
+               if *base.Flag.LowerV {
+                       fmt.Printf("export: typ %v %v\n", rawOff, t)
+               }
+               off = predeclReserved + rawOff
                p.typIndex[t] = off
        }
        return off