bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://github.com/bazelbuild/intellij/blob/master/docs/index.md
Apache License 2.0
764 stars 308 forks source link

Clion: GDB cannot find C++ sources in cache / external #6498

Open Algomorph opened 5 months ago

Algomorph commented 5 months ago

Description of the bug:

The debugger (at least GDB) is not configured to discern sources from external dependencies.

In order to debug through (and hit breakpoints in) sources from external project dependencies, the workaround is to run the (equivalent of) the following command in GDB:

set substitute-path external /home/greg/.cache/bazel/_bazel_greg/217399706ea15206fcdc8f34c121835f/external

However, this has to be done on every run, upon hitting a breakpoint in the current project sources.

image

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

This is relevant for at least projects using the old WORKSPACE dependency structure (not bzlmod).

Simplest way to reproduce is to load a Bazel project with C++ sources & external dependencies, e.g. mediapipe, and try to debug the sources of the dependencies, i.e. something inside cache's external folder.

Which Intellij IDE are you using? Please provide the specific version.

CLion 2024.1.1 Build #CL-241.15989.121

What programming languages and tools are you using? Please provide specific versions.

C++17, GCC: 11.4.0 Bundled GDB 14.1 (I'm hoping Bazel's using the bundled version, the system version is 12.1)

What Bazel plugin version are you using?

2024.06.04.0.2-api-version-241

Any other information, logs, or outputs that you want to share?

CLion 2024.1.1 Build #CL-241.15989.121, built on April 25, 2024 Licensed to Presage Security, Inc / Gregory Kramida Subscription is active until November 19, 2024. Runtime version: 17.0.10+1-b1207.14 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 6.5.0-41-generic GC: G1 Young Generation, G1 Old Generation Memory: 8192M Cores: 32 Registry: actionSystem.update.actions.warn.dataRules.on.edt=false debugger.attach.dialog.enabled=true run.processes.with.pty=TRUE ide.experimental.ui=true ide.slow.operations.assertion=false terminal.new.ui=true Non-Bundled Plugins: idea.plugin.protoeditor (241.15989.49) org.turbanov.run.configuration.as.action (3.0) com.codeium.intellij (1.8.66) dev.meanmail.plugin.nginx-intellij-plugin (2024.3) A move tab left and right using the keyboard plugin - by momomo.com (12.550) com.mikejhill.intellij.movetab (2.1.1) ru.adelf.idea.dotenv (2024.1) kemoke.net.cssmodule (1.1) com.haulmont.rcb (241.14494.140) com.google.idea.bazel.clwb (2024.06.04.0.2-api-version-241) Current Desktop: ubuntu:GNOME

tpasternak commented 5 months ago

Hey @Algomorph could you please share a minimal-reproducible example of that?

Algomorph commented 2 months ago

@tpasternak I don't have a minimal-reproducible example of that. Were you able to replicate using MediaPipe 0.10.11 or later? Perhaps you can work that down to an MRE, I doubt I will have time in the forseable future.

An even better work-around at the moment is to use .gdbinit file (e.g. in $HOME directory on your Linux system) to set the substitute path right away on every GDB run, i.e. make that file and put one line in:

set substitute-path external /home/greg/.cache/bazel/_bazel_greg/217399706ea15206fcdc8f34c121835f/external

The obvious drawback is that this would need to change for different bazel cache directories / projects.

tpasternak commented 3 days ago

partially related to this #6922