From e390981747933db03a1e7a508f44a1ba2a0685b9 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 6 Apr 2022 15:27:01 +0300 Subject: [PATCH 1/2] compiler: add hash field to debug info New debugger won't work without it. --- pkg/compiler/debug.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/compiler/debug.go b/pkg/compiler/debug.go index 2389ba524..e6b16bcc5 100644 --- a/pkg/compiler/debug.go +++ b/pkg/compiler/debug.go @@ -12,6 +12,7 @@ import ( "unicode" "unicode/utf8" + "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/binding" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" @@ -22,6 +23,7 @@ import ( // DebugInfo represents smart-contract debug information. type DebugInfo struct { MainPkg string `json:"-"` + Hash util.Uint160 `json:"hash"` Documents []string `json:"documents"` Methods []MethodDebugInfo `json:"methods"` Events []EventDebugInfo `json:"events"` @@ -125,6 +127,7 @@ func (c *codegen) saveSequencePoint(n ast.Node) { func (c *codegen) emitDebugInfo(contract []byte) *DebugInfo { d := &DebugInfo{ + Hash: hash.Hash160(contract), MainPkg: c.mainPkg.Name, Events: []EventDebugInfo{}, Documents: c.documents, From f5d5019b7085d13aabc6897112ace5ebc407ed0a Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 6 Apr 2022 15:46:54 +0300 Subject: [PATCH 2/2] compiler: use absolute paths for debug data It's not a perfect thing, but neo-debugger just doesn't work at all with relative pathes. Notice that `saveSequencePoint` still used absolute ones leading to invalid debug.json data, but fixing it there doesn't help, neo-debugger can't load source code using relatives. --- pkg/compiler/analysis.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/compiler/analysis.go b/pkg/compiler/analysis.go index 845607f4d..d9f494029 100644 --- a/pkg/compiler/analysis.go +++ b/pkg/compiler/analysis.go @@ -5,7 +5,6 @@ import ( "go/ast" "go/token" "go/types" - "path/filepath" "strings" "github.com/nspcc-dev/neo-go/pkg/vm/emit" @@ -235,11 +234,6 @@ func (c *codegen) fillDocumentInfo() { fset := c.buildInfo.config.Fset fset.Iterate(func(f *token.File) bool { filePath := f.Position(f.Pos(0)).Filename - rel, err := filepath.Rel(c.buildInfo.config.Dir, filePath) - // It's OK if we can't construct relative path, e.g. for interop dependencies. - if err == nil { - filePath = rel - } c.docIndex[filePath] = len(c.documents) c.documents = append(c.documents, filePath) return true