mirror of
https://github.com/golang/go
synced 2024-11-12 00:30:22 -07:00
cmd/compile: add debugging mode for import/export
Just add a simple magic number with each op, to detect when the reader gets desynchronized from the writer. Change-Id: Iac7dab7f465b0021b1d7ae31c8f8a353ac3663a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/299769 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
parent
a70eb2c9f2
commit
b60a3a8cfb
@ -246,6 +246,11 @@ const (
|
||||
interfaceType
|
||||
)
|
||||
|
||||
const (
|
||||
debug = false
|
||||
magic = 0x6742937dc293105
|
||||
)
|
||||
|
||||
func WriteExports(out *bufio.Writer) {
|
||||
p := iexporter{
|
||||
allPkgs: map[*types.Pkg]bool{},
|
||||
@ -1584,6 +1589,9 @@ func (w *exportWriter) expr(n ir.Node) {
|
||||
}
|
||||
|
||||
func (w *exportWriter) op(op ir.Op) {
|
||||
if debug {
|
||||
w.uint64(magic)
|
||||
}
|
||||
w.uint64(uint64(op))
|
||||
}
|
||||
|
||||
|
@ -1228,6 +1228,9 @@ func (r *importReader) node() ir.Node {
|
||||
}
|
||||
|
||||
func (r *importReader) op() ir.Op {
|
||||
if debug && r.uint64() != magic {
|
||||
base.Fatalf("import stream has desynchronized")
|
||||
}
|
||||
return ir.Op(r.uint64())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user