1
0
mirror of https://github.com/golang/go synced 2024-11-26 03:47:57 -07:00

[dev.regabi] cmd/compile: iexport debug crumbs for toolstash

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>
This commit is contained in:
Matthew Dempsky 2020-12-08 01:28:57 -08:00
parent 837b35cc55
commit eae8fd519b

View 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