rules_go: dlv problem

Hello,

I am trying to debug my golang program by dlv on OSX. bazel 0.7.0, rules_go latest.

If I build program by bazel, I receive error

➜ dlv attach 74960
could not attach to pid 74960: decoding dwarf section info at offset 0x0: too short

I found same issue for dlv: https://github.com/derekparker/delve/issues/79 But static linking does not work on OSX (according to rules_go documentation).

If I build program by

go build

dlv able to attach to my program

How to build golang binaries in bazel on OSX for working with dlv? Thank you

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

-c is the short form of --compilation_mode

in debug mode we disable stripping and also inlining (you can control just stripping with --strip instead) I would not recommend putting it in tools/bazel.rc. It would work, but that file is intended to be checked in, and you probably don’t want to force everyone to build slow large binaries.

Note that you can also use --run_under

bazel-run -c dbg --run_under='dlv exec' //my:binary

where bazel-run is the bazel run wrapper script you can get using

curl --output bazel-run https://raw.githubusercontent.com/bazelbuild/bazel/master/scripts/bazel-run.sh && chmod +x bazel-run

and that’s nice and easy to alias to bazel-dlv or something