delve icon indicating copy to clipboard operation
delve copied to clipboard

could not find symbol value for github.com/hyperledger/fabric/core/chaincode/platforms/util

Open siddjain opened this issue 4 years ago • 5 comments

  1. What version of Delve are you using (dlv version)?
$ dlv version
Delve Debugger
Version: 1.3.2
Build: $Id: 569ccbd514fc47c8b4c521b142556867ec5e6917
  1. What version of Go are you using? (go version)?
$ go version
go version go1.13.3 darwin/amd64
  1. What operating system and processor architecture are you using?
$ uname -a
Darwin WITSC02X6385JGH 18.7.0 Darwin Kernel Version 18.7.0: Thu Jan 23 06:52:12 PST 2020; root:xnu-4903.278.25~1/RELEASE_X86_64 x86_64
  1. What did you do?

I tried to debug a program using dlv and following command

/Users/sjain68/go/bin/dlv debug github.com/hyperledger/fabric/cmd/peer --api-version=2 --log=true -- node start

I then inserted breakpoints in the code and paused execution at

> github.com/hyperledger/fabric/core/chaincode/lifecycle.(*Serializer).IsSerialized() /Users/sjain68/go/src/github.com/hyperledger/fabric/core/chaincode/lifecycle/serializer.go:290 (hits goroutine(240):1 total:1) (PC: 0x4e802f9)
   285:			marshaledFieldValue, err := s.Marshaler.Marshal(stateData)
   286:			if err != nil {
   287:				return false, errors.WithMessagef(err, "could not marshal value for key %s", keyName)
   288:			}
   289:
=> 290:			if existingValue, ok := existingKeys[keyName]; !ok || !bytes.Equal(existingValue, util.ComputeSHA256(marshaledFieldValue)) {
   291:				return false, nil
   292:			}
   293:		}
   294:
   295:		return true, nil

After that I tried to run this command

(dlv) call util.ComputeSHA256(marshaledFieldValue)
  1. What did you expect to see?

I expected to see result of util.ComputeSHA256(marshaledFieldValue)

  1. What did you see instead?

This is what I saw

(dlv) call util.ComputeSHA256(marshaledFieldValue)
2020-03-03T12:24:31-08:00 debug layer=debugger function call util.ComputeSHA256(marshaledFieldValue)
> github.com/hyperledger/fabric/core/chaincode/lifecycle.(*Serializer).IsSerialized() /Users/sjain68/go/src/github.com/hyperledger/fabric/core/chaincode/lifecycle/serializer.go:290 (hits goroutine(240):3 total:3) (PC: 0x4e802f9)
Command failed: could not find symbol value for github.com/hyperledger/fabric/core/chaincode/platforms/util

I am not a Go developer btw.

some more info

(dlv) print existingValue
[]uint8 len: 32, cap: 512, [45,113,139,136,71,63,99,249,55,132,127,145,17,58,252,254,26,167,8,202,212,18,234,57,236,163,155,104,217,86,64,187]
(dlv) print marshaledFieldValue
[]uint8 len: 44, cap: 44, [18,42,10,4,118,115,99,99,18,34,18,32,47,67,104,97,110,110,101,108,47,65,112,112,108,105,99,97,116,105,111,110,47,69,110,100,111,114,115,101,109,101,110,116]

siddjain avatar Mar 03 '20 20:03 siddjain

It means debugger could not find this method, so can't use call.
You can type funcs util* to see all methods of package util.

chainhelen avatar Mar 04 '20 02:03 chainhelen

The problem here is that the util package is ambiguous, the file containing the function you are trying to debug uses github.com/hyperledger/fabric/common/util but Delve is trying to search the method inside github.com/hyperledger/fabric/core/chaincode/platforms/util. We currently do not have a way to disambiguate package names.

aarzilli avatar Mar 04 '20 09:03 aarzilli

It seem to be related to this comment

// There's no particular reason to expect the first entry to be the
// correct one if the package name is ambiguous, but trying all possible
// expansions of all types mentioned in the expression is complicated
// and, besides type assertions, users can always specify the type they
// want exactly, using a string.

chainhelen avatar Mar 04 '20 15:03 chainhelen

Thanks.

siddjain avatar Mar 04 '20 17:03 siddjain

Does this comment: We currently do not have a way to disambiguate package names. mean that even if I wanted to, there is no way to call the correct function from dlv because there is no way to disambiguate it from the dlv command line?

siddjain avatar May 12 '20 20:05 siddjain