From 128626de5cbe45d94f6bb2489c82bd48c6b051b3 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 10 Aug 2020 17:42:53 +0300 Subject: [PATCH] compiler: save sequence points for `init` function --- pkg/compiler/debug.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index 7b297298d..5aad14726 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -85,14 +85,15 @@ type DebugParam struct { } func (c *codegen) saveSequencePoint(n ast.Node) { - if c.scope == nil { - // do not save globals for now - return + name := "init" + if c.scope != nil { + name = c.scope.name } + fset := c.buildInfo.program.Fset start := fset.Position(n.Pos()) end := fset.Position(n.End()) - c.sequencePoints[c.scope.name] = append(c.sequencePoints[c.scope.name], DebugSeqPoint{ + c.sequencePoints[name] = append(c.sequencePoints[name], DebugSeqPoint{ Opcode: c.prog.Len(), Document: c.docIndex[start.Filename], StartLine: start.Line, @@ -122,6 +123,7 @@ func (c *codegen) emitDebugInfo(contract []byte) *DebugInfo { End: uint16(c.initEndOffset), }, ReturnType: "Void", + SeqPoints: c.sequencePoints["init"], }) } for name, scope := range c.funcs {