-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging C++ on MacOS does not work #6327
Comments
I think we can add #1000 to the list of related issues |
And #5031 |
As a potential temporary work around, does |
@kastiglione Yes it is another workaround though I would like not to use it. I have found another workaround - disabling sandbox with |
Yup this never worked, and I don't think we'll have time to look into this in 2018. Bringing apple expertise @sergiocampama just in case the fix is simpler than it sounds :). |
I would defer to the C++ language team, I don't have much experience with debugging C++ apps. |
Also related to #2537 perhaps. |
I have the same problem on Windows 10, I get
|
For the record, it's working for apple targets via |
@steeve for me My setup is: I'm putting a breakpoint the log line you see in the output and it does not catch it. My run configuration: When I pause the debugger it seems to know where it's paused (it can read the names of the functions, for example: Can you help with that or show me what to do so I can fix it myself? |
@slonka can you try to disable the sandbox? Also, As for CLion, I don't know how to make it work, but I managed to do it in VSCode. |
@steeve I tried with "--spawn_strategy=standalone" and "--sandbox_debug" they did not work in clion. Do you think it's an issue for bazel or the clion plugin? |
Also experiencing this issue, I got this error when I debug the C++ program:
|
While
This means that only the linking steps will be run without the sandbox. |
If changing the spawn strategy doesn’t work, try running |
@depp using local for the linking strategy doesn't seem to work for me. I did the following to test my executable:
Now while in lldb:
This gives something like this:
server.cpp is my file that contains the main() function. I wanted to see the location that the debug symbols claim this file is located at, so I did:
This gives:
Note that the path is under the sandbox. And as feared, that file doesn't exist. Also, it really would be good to get this fixed, its been a year and a half :( |
+1 - would love to see this fixed |
I just tried to debug an issue in Bazel's own C++ code using I'll try to find someone who can help fix this. Thanks everyone for documenting the workaround with disabling sandboxing! Edit: Yay, it works with |
Expands the targeted actions to allow stripping the absolute build path for debug symbols from all libraries. The support in wrapped_clang is indifferent to whether we are linking a true objc or regular cpp library. When used in concert with `--features=oso_prefix_is_pwd --remote_download_outputs=all`, allows successful local debugging of executables/libraries built remotely. Probably also helps with sandboxed actions. Helps mitigate #6327 and kinda sorta #2537? See also #11671 Closes #13311. PiperOrigin-RevId: 404262861
As of today I think most of the issues are resolved, but unfortunately not enabled by default (and realistically probably can't be since some might require extra lldb configuration). Note that I'm testing with bazel HEAD (although I think the current 5.x release has the same fixes) For the original repro case here, using A while back I also made
You can set this in your If folks have more cases that don't work please post them here. |
MacOS with M1 chip. For those experiencing the same issue, this is my minimal setting to get line numbers in
|
I found that |
I proposed these originally in #273 as an initial idea for what became #275. But I have encountered another use case that makes me think they are generally useful: When [debugging on macOS](bazelbuild/bazel#6327 (comment)), lldb needs to be configured with the command `platform settings -w $execution_root`, where `$execution_root` is what's returned by `bazel info execution_root`. With `bazel.info.*` commands, you can create a launch configuration that contains: ``` "initCommands": [ "platform settings -w ${command:bazel.info.execution_root}", ] ```
Please reopen new issues if the mentioned fixes don't work for you! |
Description of the problem / feature request:
Debugging C++ on MacOS does not work. The built binary file contains debug hints which point to the location in the sandbox (which is removed after compilation).
Feature requests: what underlying problem are you trying to solve with this feature?
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
BUILD
filemain.cpp
fileBuild with
bazel build --compilation_mode=dbg sample
And debug
Debug hints in the executable:
While file built with
clang++ -g main.cpp -o sample
can be debugged normally:What operating system are you running Bazel on?
MacOS High Sierra 10.13.2
What's the output of
bazel info release
?release 0.17.2-homebrew
Have you found anything relevant by searching the web?
I have found related issue 5545 but the proposed solution was already merged to the version of Bazel I am using.
Any other information, logs, or outputs that you want to share?
I have also asked a question on Stackoverflow
The text was updated successfully, but these errors were encountered: