fix: multi /pkg/<module> in dlv debugging #119378
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
O-community
Originated from the community
X-blathers-triaged
blathers was able to find an owner
This issue is copied from my PR: cockroachdb/rules_go#18
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:
#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
Jira issue: CRDB-36174
The text was updated successfully, but these errors were encountered: