Merge pull request #2427 from nspcc-dev/add-hash-to-debug-info

Add hash to debug info and use absolute path
This commit is contained in:
Roman Khimov 2022-04-06 16:11:47 +03:00 committed by GitHub
commit 6ff11baa1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -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

View file

@ -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,