Description
I recently attempted to debug a Rust program with LLDB. I was surprised to find out that LLDB wouldn't find the debug symbols, even I had been sure to compile them in.
The problem was that on macOS, the debug symbols are stored in a directory that is separate from the binary. This directory has an extension .dSYM
. (To be sure, there is also symbol table compiled in the binary, and LLDB was able to show stack traces because of this.), This .dSYM
directory was produced in the build, but it's stored in target/debug/deps/
instead of target/debug/
. Therefore, debuggingtarget/debug/$BINARY_NAME
with LLDB caused LLDB not to find the debug symbols.
This is a problem, since it's surprising; I, and I bet that many others too, expect to be able to debug the main build artefact of a debug build. Many don't necessarily find the "debuggable" binary in the subdirectory.
There's a second problem too: using VS Code, I can modify the settings of the Launch debugger command. I can set the binary name that is going to be debugged. But the binary in the directory target/debug/deps/
doesn't have a deterministic name, because of the hash appended to the name (which is of course the point there...). One could argue that being not able to set a glob filename for the debugging command is just a shortcoming of VS Code, but I think that there should also be a deterministically named debuggable binary.
The easy fix, of course, is to create a .dSYM
directory in target/debug/
too, corresponding to the binary there.