Bazel with Visual Studio Code

2,556 views
Skip to first unread message

valeri...@gmail.com

unread,
Aug 29, 2016, 7:48:45 PM8/29/16
to bazel-discuss
I'm working with Tensorflow Serving, which is built with Bazel, and trying to use Visual Studio Code (VSC). I have VSC building the projects with Bazel, but when I try to debug it can't find my code. I feel like this could be a really great cross-platform, multi-language development environment if I can only get debugging working, since VSC supports both C++ and Python and runs on Linux and MacOS.

The BUILD file puts the result in ${workspaceRoot}/bazel-bin/... and I've tried playing with the cwd a bit. I have copts="-g" to generate the symbols. VSC starts up gdb and runs the process, which spawns a bunch of threads, but it never hits any breakpoints.

Any ideas?

Thiago Farina

unread,
Aug 30, 2016, 6:32:02 AM8/30/16
to valeri...@gmail.com, bazel-discuss


On Tuesday, August 30, 2016, <valeri...@gmail.com> wrote:
I'm working with Tensorflow Serving, which is built with Bazel, and trying to use Visual Studio Code (VSC).  I have VSC building the projects with Bazel, but when I try to debug it can't find my code.  I feel like this could be a really great cross-platform, multi-language development environment if I can only get debugging working, since VSC supports both C++ and Python and runs on Linux and MacOS.

The BUILD file puts the result in ${workspaceRoot}/bazel-bin/... and I've tried playing with the cwd a bit.  I have copts="-g" to generate the symbols.  VSC starts up gdb and runs the process, which spawns a bunch of threads, but it never hits any breakpoints.

Are you building with -c dbg?


--
Thiago Farina

valeri...@gmail.com

unread,
Aug 31, 2016, 1:43:36 PM8/31/16
to bazel-discuss, valeri...@gmail.com
> Are you building with -c dbg?

No, I was using copts="-g". copts is where that would go, right? So it would be copts="-c dbg", right?

Thiago Farina

unread,
Sep 5, 2016, 5:34:50 AM9/5/16
to valeri...@gmail.com, bazel-discuss


On Wednesday, August 31, 2016, <valeri...@gmail.com> wrote:
> Are you building with -c dbg?

No, I was using copts="-g".  copts is where that would go, right?  So it would be copts="-c dbg", right?

No. Like `bazel build -c dbg`.

-c is a short hand for --compilation_mode, see more details at https://www.bazel.io/versions/master/docs/bazel-user-manual.html
 


--
Thiago Farina

Austin Schuh

unread,
Sep 5, 2016, 9:06:14 AM9/5/16
to valeri...@gmail.com, bazel-discuss
Bazel will then strip your binary (iirc), defeating the purpose of -g

bazel build --copts=-g --strip=never :foo

The following should also do what you want:
bazel build -c dbg :foo

Austin

On Wed, Aug 31, 2016 at 10:43 AM <valeri...@gmail.com> wrote:
> Are you building with -c dbg?

No, I was using copts="-g".  copts is where that would go, right?  So it would be copts="-c dbg", right?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/6b1bea1b-3fdd-4feb-b188-111aee019eaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Silverman

unread,
Sep 5, 2016, 9:06:14 AM9/5/16
to valeri...@gmail.com, bazel-discuss
No. -c is --compilation_mode, which is a Bazel flag that can automatically add -g and various other settings which attempt to make debugging easier (or optimization better, or builds faster). I'm not sure exactly what it does under Windows and Visual Studio, but it "should" work.

On Wed, Aug 31, 2016 at 10:43 AM, <valeri...@gmail.com> wrote:
> Are you building with -c dbg?

No, I was using copts="-g".  copts is where that would go, right?  So it would be copts="-c dbg", right?
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages