Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I try to debug cockroach with VSCode, I found some bugs when I try to set breakpoints.
VSCode tells me that some files cannot be found in dlv sources, even if I use this to substitute the path to package path:
One of the cases is
/pkg/gossip/gossip.go
When using
dlv
as follows:dlv exec ../_bazel/bin/pkg/cmd/cockroach/cockroach_/cockroach -- start --insecure --store=node1 --listen-addr=localhost:26257 --http-addr=localhost:8080 --join=localhost:26257,localhost:26258,localhost:26259
and then use
sources
command to list all sources. You can find its path like this:github.com/cockroachdb/cockroach/pkg/gossip/pkg/gossip/gossip.go
The relpath
pkg/gossip
has been appended twice.This problem is associated with one issue in cockroach:
cockroachdb/cockroach#64379
You modified complilepkg.go as follows:
But when you debug bazel, you can get the command passed bazel looks like this:
The first src is the protobuf file and therefore
srcs.goSrcs[0].filename
isbazel-out/k8-dbg/bin/foo/foo_go_proto_/example.com/foo/foo.pb.go
, but we are expecting the source file which is not generated.so I modify this part as follows:
Once srcs has source code which is not generated, we use its path.
Then problem is fixed, and we get its path in
dlv
as follows:github.com/cockroachdb/cockroach/pkg/gossip/gossip.go