-
Notifications
You must be signed in to change notification settings - Fork 255
Breakpoints are not getting hit
Symptom: Debugger does not stop on breakpoints / breakpoints are grayed out.
This usually means one of the two things:
-
The debugger cannot locate debugging information for the module you are setting a breakpoint in.
Please make sure that you are compiling with debug information emission enabled. Most C++ compilers, as well as the Rust compiler, use -g flag for this purpose. You can check whether your binary has debug info by following these instructions. -
The path of file you are setting a breakpoint in does not match source path stored in the debugging information. This may happen because:
- You are debugging on a different machine than the program was compiled on. This includes compiling or debugging in a Docker container if the source tree is not mounted at exactly the same location. To correct this, add
"sourceMap": { "<source tree path at compilation time>": "<source tree path during debugging>" }
to your launch configuration. The latter is usually${workspaceFolder}
. - Your build system or compiler rewrites source tree location embedded in the debug info:
- In order to achieve repeatable builds, Bazel, makes source file paths relative to the current directory. To fix, add
"sourceMap": { "/proc/self/cwd": "<source tree path> }
to your launch configuration on Linux, or"sourceMap": { ".": "<source tree path>" }
on MacOS or Windows. - If debugging a Rust program, check whether the source path contained symlinks: rustc replaces symlinks with their targets. To fix, add
"sourceMap": {"<original path>: "<symlinked path>"}
.
- In order to achieve repeatable builds, Bazel, makes source file paths relative to the current directory. To fix, add
In this case, you should still be able to set function breakpoints, which may help in diagnosing the problem: once stopped on a breakpoint, use commands such as
source info
orbreakpoint list --verbose
to see what's going on. Usedebug_info
command to dump source paths of all compilation units in the currently loaded modules. - You are debugging on a different machine than the program was compiled on. This includes compiling or debugging in a Docker container if the source tree is not mounted at exactly the same location. To correct this, add
See also: LLDB troubleshooting